-
-
Notifications
You must be signed in to change notification settings - Fork 545
Description
Description
Add movie titles to API responses that return lists of media items
Currently, some API endpoints that return a list of media items (e.g., movies) do not include the movie title in the response. Instead, they only provide the TMDB ID (tmdbId
). This forces API consumers to make an additional API call for each item in the list to retrieve its title. This is inefficient and adds unnecessary latency.
Desired Behavior
All API endpoints that return a list of media items should include the title of the media (movie or TV show) in the response, alongside the tmdbId
. This will eliminate the need for extra API calls to enrich the data, making the API more efficient and easier to use.
Additional Context
Suggested Code Changes for Feature Request: Include Movie Title in Media List API Responses
This document outlines the potential code changes required to implement the feature request "Include Movie Title in Media List API Responses." The goal is to ensure that all API endpoints returning lists of media items also include the title
of the movie or TV show, eliminating the need for subsequent API calls to retrieve this information.
1. Backend API Endpoints Modification:
- Identify relevant endpoints: Review all API endpoints under
server/api
andserver/routes
that return lists ofMedia
objects,MediaRequest
objects, or any other data structure containingtmdbId
for movies/TV shows. Examples might include:- Endpoints related to
get_all_requests
- Discovery endpoints (e.g.,
discover_movies
,discover_tv
). - Search endpoints.
- User-specific media lists (e.g., requested media, watchlists).
- Endpoints related to
- Modify response structures: For each identified endpoint, ensure that the JSON response for each media item includes a
title
field. Thistitle
should be the primary display title of the movie or TV show.
2. Data Models/Entities Update:
Media
Entity/Interface: Examine theMedia
entity or interface definition (likely inserver/entity
orserver/interfaces
). If atitle
field is not already explicitly defined and consistently populated for both movies and TV shows, it should be added.- Consider if a separate
displayTitle
or similar field is needed if the raw title from TMDB requires formatting.
- Consider if a separate
3. Service Layer and External API Integration:
- TMDB Integration: The services responsible for interacting with The Movie Database (TMDB) (likely in
server/api/themoviedb
orserver/lib/themoviedb
) will need to ensure that when media details are fetched, thetitle
(for movies) orname
(for TV shows) is consistently extracted and stored/passed along. - Data Population Logic: Review the logic where
Media
objects (or similar) are constructed and populated. Ensure that thetitle
field is always populated when atmdbId
is present, even if it means making an initial call to TMDB during the media object creation/retrieval process. This initial population would be more efficient than multiple subsequent calls from the client.
4. Database Schema (if applicable):
- If the
Media
entity is persisted in a database, the database schema might need to be updated to include atitle
column in the relevant table(s). This would involve creating a new migration.
Example Scenario (Illustrative):
Consider an endpoint like /api/v1/request/all
. Currently, its response for a movie request might look like:
{
"id": 123,
"media": {
"mediaId": 550, // TMDB ID for Fight Club
"mediaType": "movie"
},
"status": 2
}
After changes, the desired response would be:
{
"id": 123,
"media": {
"mediaId": 550,
"mediaType": "movie",
"title": "Fight Club" // New field
},
"status": 2
}
This approach ensures that the necessary information is available directly in the initial API response, reducing client-side complexity and improving performance.
Code of Conduct
- I agree to follow Overseerr's Code of Conduct