APIs - Shravsssss/MovieRecommender GitHub Wiki
Movie Recommender Application API Documentation
Overview
This section details the available API endpoints in the Movie Recommender Application. These APIs allow users to interact with the platform for managing profiles, generating recommendations, filtering movies, handling watchlists, and fetching movie details from external sources.
Base URL
The base URL for all the API calls is:
http://localhost:5000/
Authentication-Related APIs
Check How)
1. User Registration (Endpoint: /register
Method: POST
Description: Allows users to create an account with a unique username, email, and password.
Request Example:
POST /register
Content-Type: application/x-www-form-urlencoded
username=johndoe&[email protected]&password=password123
Response:
- Success: Redirects to the landing page.
- Error: Error message if the username or email is already registered.
Check How)
2. User Login (Endpoint: /login
Method: POST
Description: Allows registered users to log into their accounts using their username and password.
Request Example:
POST /login
Content-Type: application/x-www-form-urlencoded
username=johndoe&password=password123
Response:
- Success: Redirects to the landing page.
- Error: Error message for invalid credentials.
Check How)
3. User Logout (Endpoint: /logout
Method: GET
Description: Logs out the currently authenticated user.
Request Example:
GET /logout
Response:
- Success: Redirects to the login or landing page.
Profile Management APIs
Check How)
4. User Profile (Endpoint: /profile
Method: GET
Description: Displays the authenticated user’s profile, including watchlist and recommendation history.
Request Example:
GET /profile
Response:
- Success: Renders the profile page showing the watchlist count and recommended movies count.
Check How)
5. Edit Profile (Endpoint: /edit_profile
Method: POST
Description: Allows the user to update their favorite genres.
Request Example:
POST /edit_profile
Content-Type: application/x-www-form-urlencoded
favorite_genres=Action,Comedy
Response:
- Success: Redirects to the profile page with a success message.
Check How)
6. Change Password (Endpoint: /change_password
Method: POST
Description: Allows users to change their password.
Request Example:
POST /change_password
Content-Type: application/x-www-form-urlencoded
current_password=oldpassword&new_password=newpassword123
Response:
- Success: Redirects to the profile page with a success message.
- Error: Error message if the current password is incorrect.
Movie Recommendation APIs
Check How)
7. Generate Recommendations (Endpoint: /predict
Method: POST
Description: Generates personalized movie recommendations based on a list of movies the user has provided.
Request Example:
POST /predict
Content-Type: application/json
{
"movie_list": ["Inception", "The Dark Knight"]
}
Response Example:
{
"recommendations": ["Interstellar", "Memento", "The Prestige"],
"rating": {
"Interstellar-r": "8.6",
"Interstellar-g": "Adventure, Drama, Sci-Fi",
"Interstellar-p": "https://image.posterlink.com",
"Interstellar-c": "Adam: Amazing visuals and storyline",
"Interstellar-s": "Netflix, Amazon Prime"
}
}
Watchlist APIs
Check How)
8. View Watchlist (Endpoint: /watchlist
Method: GET
Description: Retrieves the current user’s watchlist.
Request Example:
GET /watchlist
Response:
- Success: Displays the watchlist with movie titles and IMDb ratings.
Check How)
9. Add to Watchlist (Endpoint: /add_to_watchlist
Method: POST
Description: Adds a movie to the user’s watchlist.
Request Example:
POST /add_to_watchlist
Content-Type: application/x-www-form-urlencoded
movie_title=Inception&imdb_rating=8.8
Response:
- Success: Redirects to the watchlist page with a success message.
- Error: Error message if the movie is already in the watchlist.
Check How)
10. Remove from Watchlist (Endpoint: /remove_from_watchlist/<int:movie_id>
Method: POST
Description: Removes a movie from the user’s watchlist.
Request Example:
POST /remove_from_watchlist/1
Response:
- Success: Redirects to the watchlist page with a success message.
- Error: Error message if the movie doesn’t belong to the user.
Search and Filtering APIs
Check How)
11. Search Movies (Endpoint: /search
Method: POST
Description: Searches for movies based on a user’s query.
Request Example:
POST /search
Content-Type: application/x-www-form-urlencoded
q=Inception
Response Example:
{
"movie1": "Inception",
"movie2": "Interstellar",
...
}
Check How)
12. Filter by Rating (Endpoint: /ratingfilter
Method: POST
Description: Filters movies based on a given rating.
Request Example:
POST /ratingfilter
Content-Type: application/x-www-form-urlencoded
rating=8.0
Response Example:
{
"filtered_movies": ["The Dark Knight", "Inception"]
}
Check How)
13. Filter by Genre (Endpoint: /genrefilter
Method: POST
Description: Filters movies based on selected genres.
Request Example:
POST /genrefilter
Content-Type: application/x-www-form-urlencoded
genres=Action,Drama
Response Example:
{
"filtered_movies": ["Inception", "Interstellar"]
}
External Movie Information APIs
Check How)
14. Get Movie Reviews (Endpoint: /get_reviews/<movie_title>
Method: GET
Description: Fetches reviews for the specified movie from the TMDB API.
Request Example:
GET /get_reviews/Inception
Response Example:
{
"reviews": [
{
"author": "John Doe",
"content": "Amazing movie!"
},
{
"author": "Jane Smith",
"content": "A masterpiece!"
}
]
}
Check How)
15. Get Streaming Platforms (Endpoint: /get_streaming_platforms/<movie_title>
Method: GET
Description: Fetches available streaming platforms for the specified movie using the TMDB API.
Request Example:
GET /get_streaming_platforms/Inception
Response Example:
[
{
"name": "Netflix",
"logo": "https://netflix-logo-link"
},
{
"name": "Amazon Prime",
"logo": "https://amazon-prime-logo-link"
}
]
Feedback API
Check How)
16. Submit Feedback (Endpoint: /feedback
Method: POST
Description: Collects feedback from users.
Request Example:
POST /feedback
Content-Type: application/json
{
"Feedback": "Like",
}
Response:
- Success: Saves feedback and returns the same data.