Api fetches movie data from www.omdbapi.com and saves it to database.
Api was developed using Django and Django REST frameworks. Additionally requests library was used to interact with www.omdbapi.com api. Database on production server is Postgresql (instead of sqlite which was used only for development) so psycopg2 database adapter was added to requirements file.
Api tested with Python 3.7
Clone repository and got to project's root directory afterwards follow steps:
-
Activate python virtual environment
source /path/to/local/env
-
Install requirements
pip install -r requirements.txt
-
Run server
python manage.py runserver
-
Api can be tested by sending requests to address
http://127.0.0.1:8000/resource_name
Download all movies.
Download movie data from external api and save it in database.
Required Headers:
Content-Type: application/json
Required json body fields:
title
Delete movie
movie-id from URL is used to determine which movie should be deleted
Update movie
Required Headers:
Content-Type: application/json
Json body should contain field names and values which supposed to be updated. For instance:
{
"title": "Terminator",
"year": "1993",
"rated": "",
"released": "2019-01-02",
"runtime": 39,
"genre": "Short, Action, Sci-Fi",
"director": "Ben Hernandez",
}
movie-id from URL is used to determine which movie should be updated
Create comment attached to movie
Required Headers:
Content-Type: application/json
Json body requires body and movie_id fields.
{
"body": "Good movie",
"movie_id": 1
}
Show all created comments or only comments attached to specific movie
To get comments attached to specific movie add query params so that url will look like comments/?movie_id=1
Show movie ranking based on number of comments
Required query params date_from, date_to
Api deployed to https://movie-db-api.cleverapps.io