MyFlix Backend API Documentation

The following 12 endpoints provide consumers of this API with access to information about different movies, users, directors, and genres. Other than the "get all movies" endpoint, the registration endpoint, and the login endpoint, all other routes require a valid JSON web token, which can be obtained by registering and/or logging in. Include a valid token in the authorization header of your request to access all other protected routes. Only the currently signed-in users will be authorised (again via JWT) to view or update information associated with their own account. (View source).

Please note that all passwords submitted by users (during registration and password changes) are encrypted prior to being stored.

Endpoints:

Business Logic URL HTTP Method Request body data format Response body data format
Create a new user /users POST { "username": "Charlie", "password": "ExamplePassword" } { "id": "3", "username": "Charlie", "password": "ExamplePassword--HASHED" "favouriteMovies": [] }
Log a user in /login?username={username}&password={password}

e.g. /login?username=Charlie&password=ExamplePassword
POST None A JSON object holding data about the logged in user and a JSON web token.
Get info on all users /users GET None A JSON object holding data about all users.
Get info on a single user by username /users/{username} GET None A JSON object holding data about the particular user.
Get a list of all movies /movies GET None A JSON object holding data about all movies.
Get data about a single movie by title /movies/{Example%20Movie%20Title}

e.g. /movies/(500)%20Days%20of%20Summer
GET None A JSON object holding all data about the target movie "(500) Days of Summer".
Get data about a genre by name /movies/genre/Example%20Genre

e.g. /movies/genre/Romantic%20Comedy
GET None A JSON object holding all data about the target genre "Romantic Comedy".
Get data about a director by name /movies/directors/Name%20Of%20Director

e.g. /movies/directors/Jean-Pierre%20Jeunet
GET None {
"name": "Jean-Pierre Jeunet",
"bio": "Jean-Pierre Jeunet is a French filmdirector known for his distinctive visual style. He gained international acclaim for directing the film 'Amélie.'",
"dob": "03/09/1953"
}
Update user information (username and/or password) /users/{username}

e.g. /users/Abraham
PUT { "username": "Denise", "password": "ChangedPassword" } { _id: ObjectId('6685793cf67a085dc3261cde'), "username": "Denise", "password": "ChangedPassword--HASHED", "favouriteMovies": [] }
Add a movie to a user's favorite movies /users/{username}/movies/{Example%20Movie%20Id}

e.g. /users/Abraham/6685570bf67a085dc3261cd7
PATCH None A JSON object holding updated info about the user and their favourite movies.
Remove a movie from a user's favorite movies /users/{username}/movies/{Example%20Movie%20Id}}

e.g. /users/Bessie/6685570bf67a085dc3261cd7
DELETE None A JSON object holding updated info about the user and their favourite movies.
Deregister a user /users/{username}}

e.g. /users/Charles
DELETE None A text messeage indicating whether the user was successfully removed