Skip to content

Movies_get

Luigi Minardi edited this page Mar 1, 2022 · 1 revision

Return to Movies

Get all movies

Return all the movies of the database.

Endpoint: /
Request:

Go to the endpoint and you'll get the response.

Response Body:
Response code: 200
[
    {
        "id": 1,
        "title": "My Movie",
        "description": "This is a movie",
        "adult": true,
        "popularity": 7,
        "image": "http:/your.site/image-folder/any.jpg",
        "date": "2022-02-24 15:42:47",
        "createdAt": "2022-02-26T22:29:05.000Z",
        "updatedAt": "2022-02-26T22:29:05.000Z"
    },
    {
        "id": 2,
        "title": "My SFW Movie",
        "description": "This is a movie for the family",
        "adult": false,
        "popularity": 7,
        "image": "http:/your.site/image-folder/any.jpg",
        "date": "2022-02-24 15:42:47",
        "createdAt": "2022-02-26T20:18:37.000Z",
        "updatedAt": "2022-02-26T20:18:37.000Z"
    }
]

Get all adult movies with title and popularity

Return all adult movies with specified title and popularity of the database.

Endpoint: /favorites

Request:

After being logged in, go to the endpoint and you'll get the response.

If you're using postman or insomnia to check the API remember to put the token of the logged user on the header, as Authorization: Bearer <token>.

Query Params

?title=<string>&adult=<boolean>&popularity=<float>

All the fields needs to exists on the database.

adult will be 0 or 1, being false and true respectively.

popularity needs to be a number between 0 and 10.

Response Body:
Response code: 200
[
    {
        "id": 1,
        "title": "My Movie",
        "description": "This is a movie",
        "adult": true,
        "popularity": 7,
        "image": "http:/your.site/image-folder/any.jpg",
        "date": "2022-02-24 15:42:47",
        "createdAt": "2022-02-26T22:29:05.000Z",
        "updatedAt": "2022-02-26T22:29:05.000Z"
    }
]

Get all adult movies

Return all the adult movies of the database.

Endpoint: /adult
Request:

After being logged in, go to the endpoint and you'll get the response IF the user has more than 18yo.

If you're using postman or insomnia to check the API remember to put the token of the logged user on the header, as Authorization: Bearer <token>.

Response Body:
Response code: 200
[
    {
        "id": 1,
        "title": "My Movie",
        "description": "This is a movie",
        "adult": true,
        "popularity": 7,
        "image": "http:/your.site/image-folder/any.jpg",
        "date": "2022-02-24 15:42:47",
        "createdAt": "2022-02-26T22:29:05.000Z",
        "updatedAt": "2022-02-26T22:29:05.000Z"
    },
    {
        "id": 3,
        "title": "One NSFW Movie",
        "description": "This is a movie for the lewds",
        "adult": true,
        "popularity": 7,
        "image": "http:/your.site/image-folder/any.jpg",
        "date": "2022-02-24 15:42:47",
        "createdAt": "2022-02-26T20:18:37.000Z",
        "updatedAt": "2022-02-26T20:18:37.000Z"
    }
]

Get one movie

Return one movie of the database, if the movie is for adult it will return just for adult users.

Endpoint: /:pk
Request:

After being logged in, go to the endpoint and you'll get the response, if the movie is for adults the user will need to have more than 18yo to access.

If you're using postman or insomnia to check the API remember to put the token of the logged user on the header, as Authorization: Bearer <token>.

Response Body:
Response code: 200
{
    "id": 1,
    "title": "My Movie",
    "description": "This is a movie",
    "adult": true,
    "popularity": 7,
    "image": "http:/your.site/image-folder/any.jpg",
    "date": "2022-02-24 15:42:47",
    "createdAt": "2022-02-26T22:29:05.000Z",
    "updatedAt": "2022-02-26T22:29:05.000Z"
}