A comprehensive API that provides access to trending, popular, and upcoming anime, movies, and TV shows. This API leverages the Jikan API for anime data and the TMDB API for movie & TV show data.
- Anime Endpoints: Fetch trending, popular, and upcoming anime.
- Movies Endpoints: Fetch trending, popular, and upcoming movies.
- TV Shows Endpoints: Fetch trending and popular TV shows.
- Search Functionality: Search across movies, TV shows, and anime with advanced query filtering.
- Caching: Implemented with Redis for efficient data retrieval.
- Rate Limiting: Protects the API from abuse with rate limiting for Jikan and TMDB endpoints.
- Deployed on AWS and Railway: Can be easily deployed on AWS Elastic Beanstalk or Railway.
- Postman Documentation: Postman Collection Link
GET /trending/anime: Fetch trending anime.GET /popular/anime: Fetch popular anime.GET /upcoming/anime: Fetch upcoming anime.GET /search/anime: Search anime based on various filters.
GET /trending/movies: Fetch trending movies.GET /popular/movies: Fetch popular movies.GET /upcoming/movies: Fetch upcoming movies.GET /search/movies: Search for movies.
GET /trending/tv: Fetch trending TV shows.GET /popular/tv: Fetch popular TV shows.GET /search/tv: Search TV shows based on various filters.
GET /images/movie/:id: Fetch movie images (backdrops and posters).GET /images/tv/:id: Fetch TV show images (backdrops and posters).
- Node.js (version 18 or higher)
- Docker (for running Redis locally)
- Redis CLI (for managing Redis, if needed)
To use the movie and TV show endpoints, you'll need to generate a TMDB API key.
- Visit TMDB to generate your API key.
- Store the API key in your environment variables:
AUTH_TOKEN=<your_tmdb_api_key>- Clone the repository
git clone https://github.com/Harshitv21/Anime-Movie-API.git
cd Anime-Movie-API- Install dependencies
npm install- Set up environment variables
Create a
.envfile in the root directory with the following values (for local setup only):
AUTH_TOKEN=<your_tmdb_api_key>
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASSWORD=<in_case_using_redis_cloud>- Run Redis in Docker
Much clear instructions on installation here
Exposing docker port to localhost:8001,
docker run -d -p 6379:8001 redis- Start the server
npm start- Test the API locally by accessing
http://localhost:3000.
You can either setup the Redis server through Docker (as shown above) or use Redis cloud if you want to deploy it for yourself more on that here.
After creating a Database use the credentials in middlewares/rateLimiter.js + .env file and Redis on cloud is ready for your deployment!
You may need to create an AWS account and enter your card details (In case one doesn't exists already 😛) Which might cost you some money (it costed me around a dollar or something for a month) so proceed with this step carefully!
To deploy this project on AWS Elastic Beanstalk, follow these steps:
- Install Elastic Beanstalk CLI
pip install awsebcli- Initialize Elastic Beanstalk
eb initGo through the configuration
- Create an environment and deploy
eb create
eb deploy- Environment Variables on AWS:
After deploying, go to AWS Elastic Beanstalk dashboard and add the necessary environment variables likeAUTH_TOKEN,REDIS_HOST, andREDIS_PORT(optionallyREDIS_PASSWORD).
The project is also deployable on Railway:
- Fork the repository and link your Railway account to GitHub.
- Add environment variables in Railway under the project settings and then copy the content of your
.envfile in variables section. - Deploy: The app should automatically deploy on pushes to the main branch.
To avoid abuse, rate limiting has been implemented for both Jikan and TMDB endpoints:
- Jikan API: Limit is set to 50 requests/minute and 2 requests/second.
- TMDB API: Limit is set to 36 requests/second.
The API uses Redis to cache popular, trending, and search results to improve performance and reduce API calls.
- Caches the results for 1 hour (
EX 3600).
You can explore and interact with the API using the Postman collection which provides a much comprehensive documentation: Postman Collection Link
Feel free to contribute to this project by opening an issue or submitting a pull request. All contributions are welcome!
If you have any questions, feel free to reach out:
- Author: Harshit Kumar Verma
- GitHub: Harshitv21
- LinkedIn: harshitkverma