Description
To build the server-side component of a “movies” web application an API was created. The web application will provide users with access to information about different movies, directors, and genres. Users will be able to sign up, update their personal information, and create a list of their favorite movies.
This documentation is to explain and showcase the different API points available and how to access them.
Routes
URL Endpoints and request methods
Login
Login for registered users to gain access to the API endpoints.
POST
Route | /login | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
Returns a json object of the user and its details including JWT token for authentication |
|||||||||||||
Request data |
Paramters format:
|
Paramters example:
|
||||||||||||
Response data |
Format of JSON Object: { user:{ name: String, userName: String, password: String, email: String, birthday: Date, favorites: Array, _id: ObjectId }, token: String } |
Example of JSON Object { "user": { "name": "testuser", "userName": "testuser", "pas"$2b$10$LpKeTPhygdPltfG8XrmYBuDKZTouKfWNJqwga2uwYNx3tYSmzmy8y", "email": "testuser@example.com", "birthday": "1999-05-02T00:00:00.000Z", "favorites": [], "_id": "62713a9ddfaf6d76873277b2" }, "token": ""eyXhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQ iOiI2MjcxM2E5ZGRmYWY2ZDc2ODczMjc3YjIiLCJuYW1lIjoidGVzdHVzZX I1IiwidXNlck5hbWUiOiJ0ZXN0dXNlcjUiLCJwYXNzd29yZCI6IiQyYiQ xMCRMcEtlVFBoeWdkUGx0Zkc4WHJtWUJ1REtaVG91S2ZXTkpxd2dhMnV 3WU54M3RZU216bXk4eSIsImVtYWlsIjoidGVzdHVzZXI0QGV4YW1wbGU uY29tIiwiYmlydGhkYXkiOiIxOTk5LTA1LTAyVDAwOjAwOjAwLjAwMFo iLCJmYXZvcml0ZXMiOltdLCJfX3YiOjAsImlhdCI6MTY1MTU4ODgwN SwiZXhwIjoxNjUyMTkzNjA1LCJzdWIiOiJ0ZXN0dXNlcjUifQ. 5luhq3RXg7R1-NsTTgSqkPKmDa9Dp-Kas0vz0k5ZZRY"" } |
Movies
Directory contains all the movie related APIs.
GET
Route | /movies | |
---|---|---|
Description |
Returns a json list of all the movies saved in the databse and its attributes |
|
Response data |
JSON Object format of one movie { _id: ObjectId, title: String, description: String, imageUrl: String, featured: Boolean, genre: [Array], director: { name: String, bio: String, birthYear: Date, deathYear: Date } actors:[Array] } |
JSON Object example If not logged in: If logged in: [ { "_id": "626447£5915d60485d2e243f", "title": "Pillow Talk", "description": "An interior decorator and a playboy songwriter share a telephone party line and size each other up.", "imageUrl": "https://en.wikipedia.org/wiki/Pillow_Talk_(film)#/media/File:Pillow_Talk_(1959_poster).jpg", "featured": true, "genre": [ "6263ac69915d60485d2e243a", "6263ac9f915d60485d2e243b" ], "director": { name: "Michael Gordon", bio: "Director, Michael Gordon, was born Irving Kunin Gordon on Sep 6, 1909 in Baltimore, MD. Gordon died at the age of 83 on Apr 23, 1993 in Century City, CA and was laid to rest in Mount Sinai Memorial Park Cemetery in Los Angeles, CA.", birthYear: "1909-09-06T00:00:00.000Z", deathYear: "1993-04-29T00:00:00.000Z" } "actors":[ "6263aa94915d60485d2e2438", "6263a2a6915d60485d2e2435" ] }, ... |
GET
Route | /movies/[title] | |
---|---|---|
Description |
Returns a json object with the details for the queried movie |
|
Response data |
JSON Object format { _id: ObjectId, title: String, description: String, imageUrl: String, featured: Boolean, genre: [Array], director: { name: String, bio: String, birthYear: Date, deathYear: Date } actors:[Array] } |
JSON Object example If not logged in: If logged in: [Grease] { _id: "62645d17915d60485d2e2446", title: "Grease", description: "Good girl Sandy Olsson and greaser Danny Zuko fell in love over the summer. When they unexpectedly discover they're now in the same high school, will they be able to rekindle their romance?", imageUrl: "https://en.wikipedia.org/wiki/Grease_(film)#/media/File:Grease_ver2.jpg", featured: false, genre: [ "6263ac69915d60485d2e243a", "6263ac9f915d60485d2e243b", "6263ad37915d60485d2e243d" ], director: { name: "Randal Kleiser", bio: "Randal Kleiser is an American film and television director, producer, screenwriter and actor, best known for directing the 1978 musical romantic-comedy film Grease.", birthYear: "1946-07-20T00:00:00.000Z" } actors:[ "6263aa94915d60485d2e2438", "6263a2a6915d60485d2e2435" ] } |
GET
Route | /movies/genre/[genre] | |
---|---|---|
Description |
Returns a json list of all the movies with the searched for genre |
|
Response data |
JSON Object format { _id: ObjectId, title: String, description: String, imageUrl: String, featured: Boolean, genre: [ { id: ObjectId, name: String, description: String } ], director: { name: String, bio: String, birthYear: Date, deathYear: Date } actors:[Array] } |
JSON Object example If not logged in: If logged in: [Musical] { _id: "62645d17915d60485d2e2446", title: "Grease", description: "Good girl Sandy Olsson and greaser Danny Zuko fell in love over the summer. When they unexpectedly discover they're now in the same high school, will they be able to rekindle their romance?", imageUrl: "https://en.wikipedia.org/wiki/Grease_(film)#/media/File:Grease_ver2.jpg", featured: false, genre: [ { "_id": "6263ad37915d60485d2e243d", "name": "Musical", "description": "Should contain several scenes of characters bursting into song aimed at the viewer (this excludes songs performed for the enjoyment of other characters that may be viewing) while the rest of the time, usually but not exclusively, portraying a narrative that alludes to another Genre." } ], director: { name: "Randal Kleiser", bio: "Randal Kleiser is an American film and television director, producer, screenwriter and actor, best known for directing the 1978 musical romantic-comedy film Grease.", birthYear: "1946-07-20T00:00:00.000Z" } actors:[ "6263aa94915d60485d2e2438", "6263a2a6915d60485d2e2435" ] } |
GET
Route | /movies/actor/[actor] | |
---|---|---|
Description |
Returns a json list of all the movies with the searched for actor/actress |
|
Response data |
JSON Object format { _id: ObjectId, title: String, description: String, imageUrl: String, featured: Boolean, genre: [Array], director: { name: String, bio: String, birthYear: Date, deathYear: Date } actors:[{ _id: ObjectId, name: String, bio: String, birthYear: Date }] } |
JSON Object example If not logged in: If logged in: [Kate%20Hudson] { _id: "62645b69915d60485d2e2445", title: "How to Lose a Guy in 10 Days", description: "Andie Anderson is a writer for the women’s magazine Composure as the \"How to\", subject-matter expert. She is bored and wishes she could write about more serious topics. After Andie’s best friend Michelle experiences yet another break-up, Andie is inspired to write a new article titled \"How to Lose a Guy in 10 Days\"; she will begin dating a man and drive him away within 10 days.", imageUrl: "https://en.wikipedia.org/wiki/How_to_Lose_a_Guy_in_10_Days#/media/File:HowToLoseAGuyimp.jpg", featured: fasle, genre: [ "6263ac69915d60485d2e243a", "6263ac9f915d60485d2e243b" ], director: { "name": "Donald Petrie", "bio": "Donald Petrie is an American film director and actor.", "birthYear": "1954-04-02T00:00:00.000Z" } actors:[ { "_id": "6263a187915d60485d2e2433", "name": "Kate Hudson", "bio": "Kate Garry Hudson is an American actress and businesswoman.", "birthYear": "1979-04-19T00:00:00.000Z" } ] } |
GET
Route | /movies/director/[directorName] | |
---|---|---|
Description |
Returns a json list of all the movies with the searched for director |
|
Response data |
JSON Object format { _id: ObjectId, title: String, description: String, imageUrl: String, featured: Boolean, genre: [Array], director: { name: String, bio: String, birthYear: Date, deathYear: Date } actors:[Array] } |
JSON Object example If not logged in: If logged in: [Donald%20Petrie] { _id: "62645b69915d60485d2e2445", title: "How to Lose a Guy in 10 Days", description: "Andie Anderson is a writer for the women’s magazine Composure as the \"How to\", subject-matter expert. She is bored and wishes she could write about more serious topics. After Andie’s best friend Michelle experiences yet another break-up, Andie is inspired to write a new article titled \"How to Lose a Guy in 10 Days\"; she will begin dating a man and drive him away within 10 days.", imageUrl: "https://en.wikipedia.org/wiki/How_to_Lose_a_Guy_in_10_Days#/media/File:HowToLoseAGuyimp.jpg", featured: fasle, genre: [ "6263ac69915d60485d2e243a", "6263ac9f915d60485d2e243b" ], director: { "name": "Donald Petrie", "bio": "Donald Petrie is an American film director and actor.", "birthYear": "1954-04-02T00:00:00.000Z" } actors:[ { "6263a187915d60485d2e2433", "6263a1f3915d60485d2e2434" } ] } |
Users
Directory contains all the user related APIs.
POST
Route | /users | |
---|---|---|
Description |
Creates a new user |
|
Request data |
Format: { name: String, userName: String, password: String, email: String, birthday: Date } |
Example: { "name": "testuser", "userName": "testuser", "pasword": "password", "email": "testuser@example.com", "birthday": "1999-05-02T00:00:00.000Z", "favorites": [], } |
Response data |
Format of JSON Object: { name: String, userName: String, password: String, email: String, birthday: Date, favorites: Array, _id: ObjectId } |
Example of JSON Object { "name": "testuser", "userName": "testuser", "pasword": "$2b$10$LpKeTPhygdPltfG8XrmYBuDKZTouKfWNJqwga2uwYNx3tYSmzmy8y", "email": "testuser@example.com", "birthday": "1999-05-02T00:00:00.000Z", "favorites": [], "_id": "62713a9ddfaf6d76873277b2" } |
GET
Route | /users/[userName] | |
---|---|---|
Description |
Get data of the queried username |
|
Response data |
Format of JSON Object: { name: String, userName: String, password: String, email: String, birthday: Date, favorites: Array, _id: ObjectId } |
Example of JSON Object If not logged in: If logged in: [testuser] { "name": "testuser", "userName": "testuser", "password": "$2b$10$LpKeTPhygdPltfG8XrmYBuDKZTouKfWNJqwga2uwYNx3tYSmzmy8y", "email": "testuser@example.com", "birthday": "1999-05-02T00:00:00.000Z", "favorites": [], "_id": "62713a9ddfaf6d76873277b2" } |
PUT
Route | /users/[userName] | |
---|---|---|
Description |
Update data of queried existing username. |
|
Request data |
Format: (any of the keys with new values that need to be updated { name: String, } |
Example: { "name": "updatedUser" } |
Response data |
Format of JSON Object: { name: String, userName: String, password: String, email: String, birthday: Date, favorites: Array, _id: ObjectId } |
Example of JSON Object If not logged in: If logged in: [testuser] { "name": "updatedUser", "userName": "testuser", "pas"$2b$10$LpKeTPhygdPltfG8XrmYBuDKZTouKfWNJqwga2uwYNx3tYSmzmy8y", "email": "testuser@example.com", "birthday": "1999-05-02T00:00:00.000Z", "favorites": [], "_id": "62713a9ddfaf6d76873277b2" } |
POST
Route | /users/[userName]/[movieID] | |
---|---|---|
Description |
Add movie to users favorites list. |
|
Response data |
Format of JSON Object: { name: String, userName: String, password: String, email: String, birthday: Date, favorites: Array, _id: ObjectId } |
Example of JSON Object If not logged in: If logged in: [testuser]/[62645b69915d60485d2e2445] { "name": "testuser", "userName": "testuser", "pas"$2b$10$LpKeTPhygdPltfG8XrmYBuDKZTouKfWNJqwga2uwYNx3tYSmzmy8y", "email": "testuser@example.com", "birthday": "1999-05-02T00:00:00.000Z", "favorites": [ "62645b69915d60485d2e2445" ], "_id": "62713a9ddfaf6d76873277b2" } |
DELETE
Route | /users/[userName]/[movieID] | |
---|---|---|
Description |
Delete movie from users favorites list. |
|
Response data |
Format of JSON Object: { name: String, userName: String, password: String, email: String, birthday: Date, favorites: Array, _id: ObjectId } |
Example of JSON Object If not logged in: If logged in: [testuser][62645b69915d60485d2e2445] { "name": "testuser", "userName": "testuser", "pas"$2b$10$LpKeTPhygdPltfG8XrmYBuDKZTouKfWNJqwga2uwYNx3tYSmzmy8y", "email": "testuser@example.com", "birthday": "1999-05-02T00:00:00.000Z", "favorites": [], "_id": "62713a9ddfaf6d76873277b2" } |
DELETE
Route | /users/[userName]/ | |
---|---|---|
Description |
Delete user from database (deregister). |
|
Response data |
Output Format: [userName] was deleted. |
Example of JSON Object If not logged in: If logged in: [testuser] { testuser was deleted. } |