This is a FastAPI-based application that suggests movies and TV shows using The Movie Database (TMDb) API. Users can:
- Search for movies 🎬
- Get popular & top-rated movies ⭐
- Get recommendations based on input
- Browse top-rated TV shows 📺
- Use a simple frontend to explore movies
✅ FastAPI backend
✅ TMDb API integration for movie data
✅ HTML & JavaScript frontend
✅ Dynamic search with movie posters & descriptions
✅ Deployment-ready for local or cloud hosting
Open a terminal and run:
# Clone the repository
git clone https://github.com/YOUR_USERNAME/fastapi-movie-recommender.git
# Navigate to the project directory
cd fastapi-movie-recommender
Use Python's venv
to isolate dependencies:
# Create virtual environment
python -m venv venv
# Activate it
# On macOS/Linux:
source venv/bin/activate
# On Windows:
venv\Scripts\activate
pip install -r requirements.txt
To fetch movies & TV shows, you must register for an API key at TMDb:
- Visit TMDb API
- Sign up & create a developer account
- Get your API Key (v3 auth)
- Store it in a
.env
file
# Create the .env file in your project directory
nano .env
Inside .env
, add:
TMDB_API_KEY=your_api_key_here
uvicorn app.main:app --reload
This will run the server at: http://127.0.0.1:8000/
Open a browser and go to:
- Frontend: http://127.0.0.1:8000/static/index.html
- API Docs (Swagger UI): http://127.0.0.1:8000/docs
- Redoc UI: http://127.0.0.1:8000/redoc
Endpoint | Method | Description |
---|---|---|
/movies/popular |
GET |
Get popular movies |
/movies/top-rated |
GET |
Get top-rated movies |
/movies/search/?query=movie_name |
GET |
Search for a movie |
/tv/top-rated |
GET |
Get top-rated TV shows |
uvicorn app.main:app --host 0.0.0.0 --port 8000
What is Render? A Cloud Application Service provider
Think of "Render" as a service that takes your website or application code and makes it live on the internet.
- Push your code to GitHub
git add .
git commit -m "Ready for deployment"
git push origin main
- Go to Render & create a new Web Service
- Connect your GitHub repo & set up environment variables:
TMDB_API_KEY=your_api_key_here
- Deploy & test it at your Render URL 🚀
✅ Use Postman or httpie to test API requests:
http GET http://127.0.0.1:8000/movies/popular
✅ Enable caching (if needed) using Redis:
pip install fastapi-cache2 redis
✅ Customize the frontend (static/index.html
, static/style.css
)
✅ Secure the API with authentication if required
- Found a bug? Open an issue on GitHub!
- Want to contribute? Fork & submit a PR ✨
📌 Made with ❤️ using FastAPI & TMDb API