movie_api Project Documentation
Objective
To build the server-side component of a “movies” web application. 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.
Table of Contents:
API Endpoints Format Example:
HTTP METHOD
/folderName/[Parameter]
A description of the API call functionality.
Request Parameters
Parameter1 : Description of Parameter1
Parameter2 : Description of Parameter2
...
ParameterN : Description of ParameterN
Request Body Format
JSON
Description of the request body:
{
"Field1" : "Value1",
"Field2" : "Value2",
...
}
Response Body Format
JSON/Text
Description of the response body:
{
"Field1" : "Value1",
"Field2" : "Value2",
...
}
Back to Table of Contents
API Endpoints & Descriptions
HTTP POST
/users
Registers a new user account with their desired username (if available),
password, email and birthdate (optional).
Request Parameters
None
Request Body Format
JSON
JSON object holding the desired information to register a new account:
{
"Username" : "Saffron",
"Password" : "meow1234!",
"Email" : "risotto@email.com",
"Birthdate" : "2022/10/31" (optional)
}
Response Body Format
JSON/Text
JSON object holding the new account information or error message if creation
failed:
{
"_id": "672646c255a517151e82293c",
"Username" : "Saffron",
"Password" : "(Hashed Password)",
"Email" : "risotto@email.com",
"Birthdate" : "ISODate('2022-10-31T04:00:00.000Z')",
"FavoriteMovies" : []
}
Back to Table of Contents
HTTP POST
/login
Allows a registered user to login to access the user's account.
Request Parameters
None
Request Body Format
JSON
JSON object with Username and Password fields:
{
"Username" : "Saffron" , "Password" : "meow1234!"
}
Response Body Format
JSON/Text
A JSON response containing the User document as well as JWT token for
authentication or text error message:
{
"user":{
"_id": "672646c255a517151e82293c",
"Username" : "Saffron",
"Password" : "(Hashed Password)",
"Email" : "risotto@email.com",
"Birthdate" : "ISODate('2022-10-31T04:00:00.000Z')",
"FavoriteMovies" : [],
"__v": 0
},
"token": "s25df6S6dfA6S4dFa788sD9G9A9Sg5a5wGuHW..."
}
Back to Table of Contents
HTTP PUT
/users/[Username]
Updates an exisiting user's account information.
Request Parameters
Username : The account with Username
to receive the update.
Request Body Format
JSON
A JSON object with account information to be updated--ALL information is
required and will overwrite current account info:
{
"Password" : "abc555!",
"Email" : "fred09@email.com",
"Birthdate" : "1978/05/26"
}
Response Body Format
JSON/Text
JSON object holding the updated account information or message of failure to
update:
{
"_id": "672646c255a517151e82293c",
"Username" : "Fred09",
"Password" : "(Hashed Password)",
"Email" : "fred09@email.com",
"Birthdate" : "ISODate('1978-05-26T04:00:00.000Z')",
"FavoriteMovies" : []
}
Back to Table of Contents
HTTP GET
/movies
Returns a list of ALL movie data, including embedded documents.
Request Parameters
None
Request Body Format
N/A
No request body.
Response Body Format
JSON/Text
JSON format response containing movie data for each movie (data example for one
movie seen below) or failure message retreiving list:
{
"Genre" {
"Name" : "Horror",
"Description" : "The horror genre features stories that aim to elicit fear, suspense, and a sense of
dread in its audience. Horror stories often explore themes related to the unknown, the supernatural,
and the macabre, and they frequently evoke strong emotional reactions such as anxiety, terror, and
unease."
},
"Director": {
"Name": "John Carpenter",
"Bio": "This is the biography of John Carpenter...",
"BirthYear": "1948",
"DeathYear": null,
"Movies": [
"Halloween",
"The Fog",
"The Thing",
"Escape from New York"
]
},
"_id": "671eb218577ed8cab386b01f",
"Title": "Halloween",
"ReleaseYear": "1978",
"Rating": "7.7",
"Description": "Fifteen years after murdering his sister on Halloween night 1963, Michael Myers escapes
from a mental hospital and returns to the small town of Haddonfield, Illinois, to kill again.",
"Actors": [
"Donald Pleasence",
"Jamie Lee Curtis",
"Tony Moran"
],
"ImageURL": "https://www.imageURL.com/movie-image.jpg",
"Featured": true
}
Back to Table of Contents
HTTP GET
/movies/[Title]
Returns the following data about a movie title: release year, rating,
description, director, genre, actors, image URL and whether it is featured (does not include embedded
documents).
Request Parameters
Title : The Title field of the movie
the user is looking for information about.
Request Body Format
N/A
No request body.
Response Body Format
JSON/Text
JSON format response containing information about a single movie or failure
message:
{
"Title" : "Stand by Me",
"ReleaseYear : "1986",
"Rating" : "8.1",
"Description" : "A plot summary.",
"Director" : "Rob Reiner",
"Genre" : "Drama",
"Actors" : ["Wil Wheaton", "River Phoenix", "Corey Feldman", "Keifer Sutherland"],
"ImageURL" : "https://someplace.com/stand-by-me.jpg",
"Featured" : "true"
}
Back to Table of Contents
HTTP GET
/genre/[Name]
Returns data about a genre (description) by name (e.g., "Thriller").
Request Parameters
Name : The Name field of the genre
the user is looking for information about.
Request Body Format
N/A
No request body.
Response Body Format
JSON/Text
JSON format response containing the description of the genre or failure message:
{
"Name" : "Drama",
"Description" : "The drama genre is characterized by..."
}
Back to Table of Contents
HTTP GET
/director/[Name]
Returns data about a director (bio, birth/death year, movies) by name.
Request Parameters
Name : The Name field of the
director the user is looking for information about.
Request Body Format
N/A
No request body.
Response Body Format
JSON/Text
JSON format object holding data about the director or failure message:
{
"Name" : "Rob Reiner",
"Bio" : "A short biography."
"BirthYear" : "1947",
"DeathYear" : "",
"Movies" : ["Stand by Me", "When Harry Met Sally", "Misery", "A Few Good Men"]
}
Back to Table of Contents
HTTP POST
/movies/favorites/[MovieID]
Adds a movie by MovieID to a user's favorites list.
Request Parameters
MovieID : The _id field of the movie
to be added to the user's list.
Request Body Format
N/A
No request body.
Response Body Format
JSON/Text
JSON response with updated User favorite movies or error due to failure:
{
"_id": "672646c255a517151e82293c",
"Username" : "Saffron",
"Password" : "(Hashed Password)",
"Email" : "risotto@email.com",
"Birthdate" : "ISODate('2022-10-31T04:00:00.000Z')",
"FavoriteMovies" : ["671ebe39577ed8cab386b022"]
}
Back to Table of Contents
HTTP DELETE
/movies/favorites/[MovieID]
Removes a movie by MovieID from a user's favorites list.
Request Parameters
MovieID : The _id field of the movie
to be removed from the user's list.
Request Body Format
N/A
No request body.
Response Body Format
JSON/Text
JSON response with updated User favorite movies or error due to failure:
{
"_id": "672646c255a517151e82293c",
"Username" : "Saffron",
"Password" : "(Hashed Password)",
"Email" : "risotto@email.com",
"Birthdate" : "ISODate('2022-10-31T04:00:00.000Z')",
"FavoriteMovies" : []
}
Back to Table of Contents
HTTP DELETE
/users
Deregisters a user account.
Request Parameters
None
Request Body Format
N/A
No request body.
Response Body Format
Text
A text response confirming success/failure of deregister operation.
Responses:
- Success: "DELETE successful : Account Test123 has been removed."
- Failure: "DELETE failed - Could not remove account Test123 due to server error: This is an error
message..."
- Not Found: "DELETE failed - User Test123 could not be found."
Back to Table of Contents