This project is a movie API that fetches data from The Movie Database (TMDB), persists it in MongoDB, and provides CRUD endpoints for interacting with the persisted movie data. The API also includes a GraphQL endpoint for querying movie data.
- Fetches movie data from TMDB API
- Persists movie data in MongoDB
- Provides CRUD endpoints for movie data
- Includes GraphQL endpoint for querying movie data
- Fully documented with OpenAPI (Swagger) specification
- Comprehensive unit tests
- Node.js
- MongoDB
- TMDB API Key
-
Clone the repository:
git clone https://github.com/hosmanoglu/movie-database-api cd movie-api
-
Install the dependencies:
npm install
-
Create a
.env
file in the root directory and add your TMDB API Key and MongoDB URI:TMDB_API_KEY=your_tmdb_api_key MONGODB_URI=your_mongodb_uri TMDB_URI=https://api.themoviedb.org
-
Run the application:
npm run start
To run the tests, use the following command:
npm run test
- POST /movies: Save a new movie
- GET /movies/:id: Retrieve a movie by ID
- GET /movies: Retrieve all movies
- PUT /movies/:id: Update a movie by ID
- DELETE /movies/:id: Remove a movie by ID
- POST /movies/fetch: Fetch and save movie data from TMDB
- GraphQL Playground: http://localhost:3000/graphql
- Swagger UI: http://localhost:3000/api
- Ensure you have Docker and Docker Compose installed on your system.
- Create a
.env
file in the root directory with the following content:TMDB_API_KEY=your_tmdb_api_key MONGODB_URI=mongodb://mongodb:27017/netflix TMDB_URI=https://api.themoviedb.org
- Build and run the Docker containers:
docker-compose up --build
- The Swagger will be available at http://localhost:3000/api
- It is free.
- An API Key is required to interact with it.
- One could check the documentation here.
Ensure you have Newman installed. You can install Newman globally using npm:
npm install -g newman
newman run postman/movie_api_tests.postman_collection.json