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

1. User Registration (Check How)

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.

2. User Login (Check How)

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.

3. User Logout (Check How)

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

4. User Profile (Check How)

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.

5. Edit Profile (Check How)

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.

6. Change Password (Check How)

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

7. Generate Recommendations (Check How)

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

8. View Watchlist (Check How)

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.

9. Add to Watchlist (Check How)

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.

10. Remove from Watchlist (Check How)

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

11. Search Movies (Check How)

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",
  ...
}

12. Filter by Rating (Check How)

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"]
}

13. Filter by Genre (Check How)

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

14. Get Movie Reviews (Check How)

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!"
    }
  ]
}

15. Get Streaming Platforms (Check How)

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

16. Submit Feedback (Check How)

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.