Documentation

Retrieve various information on various movies. Like imdb.com, but littler.

GET /movies

Request Body: None

Response: JSON Array containing objects

Get all movies as JSON. Note that it is an array. Directors are stored as references, but populated for this response.

[
    {
        "genre": {
            "name": "Action",
            "description": "Fast-paced, fighting, and of course, action is included in these films."
        },
        "actors": [],
        "_id": "6293196ff04c1332bdae9490",
        "title": "Casino Royale",
        "year": 2006,
        "description": "After earning 00 status and a licence to kill, secret agent James Bond sets out on his first mission as 007. Bond must defeat a private banker funding terrorists in a high-stakes game of poker at Casino Royale, Montenegro.",
        "director": {
            "_id": "6293196ff04c1332bdae9501",
            "name": "\"Martin Campbell\"",
            "birthdate": "1943-08-24T00:00:00.000Z",
            "bio": "Considered one of the U.K.'s top directors by the mid-'80s, he directed the highly praised British telefilm, Reilly: Ace of Spies (1983). For his work on Edge of Darkness (1985), a five-hour BBC miniseries about nuclear contamination in England that depicted murder and high-ranking corruption, he won six BAFTA awards.",
            "movies": [
                "6293196ff04c1332bdae9490"
            ]
        }
    },
    {
        "genre": {
            "name": "Action",
            "description": "Fast-paced, fighting, and of course, action is included in these films."
        },
        "actors": [],
        "_id": "6293196ff04c1332bdae9491",
        "title": "Quantum of Solace",
        "year": 2008,
        "description": "James Bond descends into mystery as he tries to stop a mysterious organisation from eliminating a country's most valuable resource.",
        "director": {
            "_id": "6293196ff04c1332bdae9502",
            "name": "Marc Forster",
            "birthdate": "1969-11-30T00:00:00.000Z",
            "bio": "Marc Forster is a German-born filmmaker and screenwriter. He is best known for directing the films Monster's Ball(2001), Finding Neverland(2004), Stay(2005), Stranger than Fiction(2006), The Kite Runner(2007), Quantum of Solace(2008), and World War Z(2013).",
            "movies": [
                "6293196ff04c1332bdae9491"
            ]
        }
    }
]

GET /movies/title/{title}

Find a specific movie by title

Request Body: None

Response: JSON Object

A GET request to /movies/title/Skyfall would return a single movie object. If a movie could not be found, response will be 404 and an error message

{
    "genre": {
        "name": "Action",
        "description": "Fast-paced, fighting, and of course, action is included in these films."
    },
    "actors": [],
    "_id": "6293196ff04c1332bdae9490",
    "title": "Casino Royale",
    "year": 2006,
    "description": "After earning 00 status and a licence to kill, secret agent James Bond sets out on his first mission as 007. Bond must defeat a private banker funding terrorists in a high-stakes game of poker at Casino Royale, Montenegro.",
    "director": {
        "_id": "6293196ff04c1332bdae9501",
        "name": "\"Martin Campbell\"",
        "birthdate": "1943-08-24T00:00:00.000Z",
        "bio": "Considered one of the U.K.'s top directors by the mid-'80s, he directed the highly praised British telefilm, Reilly: Ace of Spies (1983). For his work on Edge of Darkness (1985), a five-hour BBC miniseries about nuclear contamination in England that depicted murder and high-ranking corruption, he won six BAFTA awards.",
        "movies": [
            "6293196ff04c1332bdae9490"
        ]
    }
}

GET /directors

Get all directors.

Request Body: None

Response: JSON Array containing objects

Directors are returned in an array of objects. Movie ids are included, but not populated.

[
    {
        "_id": "6293196ff04c1332bdae949f",
        "name": "M. Night Shyamalan",
        "birthdate": "1970-09-06T00:00:00.000Z",
        "bio": "His major films include the science fiction thriller Signs (2002), the psychological thriller The Village (2004), the fantasy thriller Lady in the Water (2006), The Happening (2008), The Last Airbender (2010), After Earth (2013), and the horror films The Visit (2015) and Split (2016).",
        "movies": [
            "6293196ff04c1332bdae9496",
            "6293196ff04c1332bdae9497",
            "6293196ff04c1332bdae9503",
            "6293196ff04c1332bdae9498"
        ]
    },
    {
        "_id": "6293196ff04c1332bdae9500",
        "name": "Christopher Nolan",
        "birthdate": "1970-07-30T00:00:00.000Z",
        "bio": "Best known for his cerebral, often nonlinear, storytelling, acclaimed writer-director Christopher Nolan has, over the course of 15 years of filmmaking, gone from low-budget independent films to working on some of the biggest blockbusters ever made.",
        "movies": [
            "6293196ff04c1332bdae9493",
            "6293196ff04c1332bdae9494",
            "6293196ff04c1332bdae9495"
        ]
    }
]

GET /directors/{name}

Find a specific director

Request Body: None

Response: JSON Object

The response is a single director object. If the director cannot be found, you'll receive a 404 and an error message. Movie ids are included, but not populated.

{
    "_id": "6293196ff04c1332bdae9500",
    "name": "Christopher Nolan",
    "birthdate": "1970-07-30T00:00:00.000Z",
    "bio": "Best known for his cerebral, often nonlinear, storytelling, acclaimed writer-director Christopher Nolan has, over the course of 15 years of filmmaking, gone from low-budget independent films to working on some of the biggest blockbusters ever made.",
    "movies": [
        "6293196ff04c1332bdae9493",
        "6293196ff04c1332bdae9494",
        "6293196ff04c1332bdae9495"
    ]
}

GET /genres

A list of all genres

Request Body: None

Response: JSON Array of Objects

Response is an array of all genres, as objects. Because this is a distinct aggregate from the genre key on the movie objects, this only contains the genres currently in the database, and as movies are added this will automatically be updated.

[
    {
        "name": "Action",
        "description": "Fast-paced, fighting, and of course, action is included in these films."
    },
    {
        "name": "Horror",
        "description": "Jump scares, murder, chases, and all other scary stuff to give you the heebie-jeebies."
    }
]

GET /movies/genres/{genre}

Request Body: None

Response: JSON Array of objects

An array of movies, the same as from the /movies endpoint. This is simply a filter on the movies returned. If the genre cannot be found (i.e. it isn't returned from the /genres endpoint), a 404 and an error message are returned.

refer to the /movies endpoint

Authorization

Authorization is performed via the /login endpoint. Endpoints requiring authentication must include the returned JWT as an Authorization: Bearer header, and match the username or id in the url (where applicable).

POST /login

Obtain a JWT token for a user

Request Body: None

URL parameters: username and password

Future goals for this endpoint include making it a request body setup and not a URL param setup.

POST /login?username=myusername&password=mypassword

Response: JSON Object

A JSON object with one key: token (or error), whose value is the JWT to return with other /user endpoints.

{
    token: foo.bar.baz
}

GET /users/{username}

Request Body: None

Authorization: Yes

Response: JSON Object

A specific users's information

A JSON object representing a single user. If the user cannot be found, a 404 and an error message are returned.

{
    "_id": "6293196ff04c1332bdae949a",
    "username": "Elyssa",
    "password": "TestPassword1",
    "birthdate": "1992-02-02T00:00:00.000Z",
    "favorites": []
}

POST /user

Create a new user

Authorization: No

Request Body: JSON representing the full user object (without _id)

birthday and favorites are optional, and favorites will be initialized to an empty array if not provided.

{
    "username": "NewTestUser",
    "email": "NewTestUser@email.com",
    "password": "TestPassword123",
    "birthdate": "1992-02-02",
    "favorites": []
}

Response: JSON Object

A JSON object representing the new user with its ID.

{
    "username": "NewTestUser",
    "email": "NewTestUser@email.com",
    "birthdate": "1992-02-02T00:00:00.000Z",
    "favorites": [],
    "_id": "62965c5f09241501a71be323",
    "__v": 0
}

PUT /user/{username}

Update any of a user's information (except _id), including email, password and username. The username from the url is used for lookup, and the username is set with the username in the request body.

Authorization: Yes

Request Body: A full user object with all keys

{
    "username": "NewTestUser",
    "email": "NewTestUser@email.com",
    "password": "TestPassword123",
    "birthdate": "1992-02-02",
    "favorites": []
}

Response: JSON Object

The full, updated user object with _id

{
    "_id": "62965c5f09241501a71be323",
    "username": "NewTestUser",
    "email": "NewTestUser@email.com",
    "birthdate": "1991-01-01T00:00:00.000Z",
    "favorites": [],
    "__v": 0
}

DELETE /user/{userId}

Delete user whose id is {userId}

Request Body: None

Authorization: Yes

Response: JSON

A JSON with a deletedCount key. The count will be 1 if the user existed and was deleted, zero otherwise

{
    "acknowledged": true,
    "deletedCount": 1
}

POST /user/{user}/favorites/{newFavorite}

Add a movie to a user's favorites list. {user} should be a username, and {newFavorite} should be the _id of a movie. If a movie is already in the list, the return object is the same, and no duplicates are added. The PUT /user/{user} endpoint can also update favorites, this is a simpler endpoint that only does favorites and requires no request body. The return object is exactly the same.

Request Body: none

Authorization: Yes

Response: JSON of the full user object, with the updated favorites list.

POST /user/Bentley/favorites/6293196ff04c1332bdae9490
{
    "_id": "6293196ff04c1332bdae9499",
    "username": "Bentley",
    "birthdate": "1991-01-01T00:00:00.000Z",
    "favorites": [
        "6293196ff04c1332bdae9492",
        "6293196ff04c1332bdae9490"
    ],
    "email": "Bentley@email.com"
}

DELETE /user/{user}/favorites/{oldFavorite}

Remove a movie to a user's favorites list. {user} should be a username, and {oldFavorite} should be the _id of a movie. If a movie is already missing from the list, the return object is the same, and nothing was changed. The PUT /user/{user} endpoint can also update favorites, this is a simpler endpoint that only does favorites and requires no request body. The return object is exactly the same.

Request Body: none

Authorization: Yes

Response: JSON of the full user object, with the updated favorites list.

DELETE /user/Bentley/favorites/6293196ff04c1332bdae9490
{
    "_id": "6293196ff04c1332bdae9499",
    "username": "Bentley",
    "birthdate": "1991-01-01T00:00:00.000Z",
    "favorites": [
        "6293196ff04c1332bdae9492"
    ],
    "email": "Bentley@email.com"
}