### Complete Example - Fetching and Displaying Genres Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbgenre.md A comprehensive example showing how to fetch both movie and TV genres, create a lookup map, and use it for display. Demonstrates the full lifecycle of genre data retrieval and utilization. ```java TmdbGenre genreHandler = tmdbApi.getGenre(); // Get movie genres Genres movieGenres = genreHandler.getMovieGenres("en-US"); System.out.println("Movie Genres:"); for (Genre g : movieGenres.getGenres()) { System.out.println(" " + g.getId() + ": " + g.getName()); } // Get TV genres Genres tvGenres = genreHandler.getTvGenres("en-US"); System.out.println("\nTV Genres:"); for (Genre g : tvGenres.getGenres()) { System.out.println(" " + g.getId() + ": " + g.getName()); } // Create a lookup map Map genreMap = movieGenres.getGenres().stream() .collect(Collectors.toMap(Genre::getId, Genre::getName)); // Use for display for (Integer genreId : Arrays.asList(18, 28)) { System.out.println("Selected: " + genreMap.get(genreId)); } ``` -------------------------------- ### Complete Trending Example Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtrending.md Demonstrates fetching and processing trending movies, TV shows, and a combined list using TmdbTrending. Requires TmdbApi instance. ```java TmdbTrending trending = tmdbApi.getTrending(); // Get movies trending today MovieResultsPage moviesDay = trending.getMovieTrending(TimeWindow.DAY, "en-US"); System.out.println("Trending Movies Today: " + moviesDay.getResults().size()); // Get shows trending this week TvSeriesResultsPage tvWeek = trending.getTvTrending(TimeWindow.WEEK, "en-US"); System.out.println("Trending Shows This Week: " + tvWeek.getResults().size()); // Get all trending mixed together MultiResultsPage allTrending = trending.getAllTrending(TimeWindow.DAY, "en-US"); for (Multi item : allTrending.getResults()) { String type = item.getMediaType(); String title = item.getTitle() != null ? item.getTitle() : item.getName(); System.out.println(title + " (" + type + ")"); } ``` -------------------------------- ### Get All Trending Items Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtrending.md Get trending movies, TV shows, and people combined, based on the specified time window and language. Results are paginated. ```java public MultiResultsPage getAllTrending(TimeWindow timeWindow, String language) throws TmdbException ``` -------------------------------- ### Append Images to Movie Details (Successful Example) Source: https://github.com/c-eg/themoviedbapi/blob/master/README.md Fetch movie details and successfully retrieve images by specifying MovieAppendToResponse.IMAGES. ```java TmdbMovies tmdbMovies = tmdbApi.getMovies(); MovieDb movie = tmdbMovies.getDetails(5353, "en-US", MovieAppendToResponse.IMAGES); Images images = movie.getImages(); // this will NOT be null ``` -------------------------------- ### Get TV Season Videos Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvseasons.md Retrieves videos, such as trailers and clips, for a specific TV season. The language can be specified. ```java public VideoResults getVideos(int seriesId, int seasonNumber, String language) throws TmdbException ``` -------------------------------- ### Get TV Episode Images Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvepisodes.md Retrieves still images associated with a specific TV episode. ```java public Images getImages(int seriesId, int seasonNumber, int episodeNumber) throws TmdbException ``` -------------------------------- ### Get Movie Details Source: https://github.com/c-eg/themoviedbapi/blob/master/README.md Fetch details for a specific movie using its ID and desired language. ```java TmdbMovies tmdbMovies = tmdbApi.getMovies(); MovieDb movie = tmdbMovies.getDetails(5353, "en-US"); ``` -------------------------------- ### Get Collection Images Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbcollections.md Fetches the posters and backdrops associated with a specific movie collection. ```APIDOC ## getImages(int collectionId) ### Description Get posters and backdrops for a collection. ### Method GET ### Endpoint /collection/{collectionId}/images ### Parameters #### Path Parameters - **collectionId** (int) - Required - The TMDB collection ID ### Response #### Success Response (200) - **Images** - Collection images ### Throws - **TmdbException** - If the request fails ``` -------------------------------- ### Verify JReleaser Configuration Source: https://github.com/c-eg/themoviedbapi/blob/master/devel_notes.md Runs a Gradle task to verify that the JReleaser configuration is set up correctly. This is useful for troubleshooting setup issues. ```bash ./gradlew jreleaserConfig ``` -------------------------------- ### Get TV Season Images Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvseasons.md Retrieves posters and other images associated with a specific TV season. ```java public Images getImages(int seriesId, int seasonNumber) throws TmdbException ``` -------------------------------- ### Get Profile Images for a Person Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbpeoplewithgenres.md Fetches all profile images and headshots associated with a person, identified by their unique ID. ```java public PersonImages getImages(int personId) throws TmdbException ``` -------------------------------- ### Get Movie Videos Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbmovies.md Retrieves videos such as trailers and clips for a specific movie using its ID and an optional language code. ```java public VideoResults getVideos(int movieId, String language) throws TmdbException ``` -------------------------------- ### Handle Multiple Results Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbfind.md This example illustrates how to handle cases where a search query might return multiple results across different categories (movies, TV, people, episodes). It iterates through the results to display information. ```APIDOC ## Handle Multiple Results ### Description Searches for content using a query string and demonstrates how to process potentially multiple results across movies, TV series, and people. ### Method `tmdbApi.getFind().find(String query, ExternalSource externalSource, String language)` ### Parameters #### Path Parameters None #### Query Parameters - **query** (String) - Required - The search query string (e.g., "Breaking Bad"). - **externalSource** (ExternalSource) - Required - The type of external source (e.g., `ExternalSource.TVDB_ID` or a general search). - **language** (String) - Optional - The ISO 639-1 language code (e.g., "en-US"). ### Request Example ```java FindResults results = tmdbApi.getFind() .find("Breaking Bad", ExternalSource.TVDB_ID, "en-US"); // Note: TVDB ID search may return multiple results System.out.println("Movies: " + results.getMovieResults().size()); System.out.println("TV: " + results.getTvResults().size()); System.out.println("Episodes: " + results.getTvEpisodeResults().size()); System.out.println("People: " + results.getPersonResults().size()); // Check all results for (FindMovie movie : results.getMovieResults()) { System.out.println("Movie: " + movie.getTitle()); } for (FindTvSeries tv : results.getTvResults()) { System.out.println("TV: " + tv.getName()); } for (FindPerson person : results.getPersonResults()) { System.out.println("Person: " + person.getName()); } ``` ### Response #### Success Response (200) `FindResults` object containing lists of movies, TV series, episodes, and people that match the search criteria. The sizes of these lists can vary. #### Response Example (See Java code for structure and output) ``` -------------------------------- ### Get Collection Images Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbcollections.md Fetches posters and backdrops associated with a movie collection. Requires the collection ID. ```java public Images getImages(int collectionId) throws TmdbException ``` -------------------------------- ### Usage in Discover - Get and Map Genres Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbgenre.md Demonstrates how to fetch movie genres and create a map for easy lookup by ID. This map can then be used for display or filtering. ```java // Get available movie genres Genres genres = tmdbApi.getGenre().getMovieGenres("en-US"); // Build a map for easy lookup Map genreMap = genres.getGenres().stream() .collect(Collectors.toMap(Genre::getId, Genre::getName)); System.out.println("Available genres:"); for (Genre g : genres.getGenres()) { System.out.println(g.getId() + " -> " + g.getName()); } // Use genre IDs in discover MovieResultsPage results = tmdbApi.getDiscover().getMovie( new DiscoverMovieParamBuilder() .withGenres(18, 28) // Drama and Action .page(1) .build() ); ``` -------------------------------- ### Get Images Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbpeoplewithgenres.md Fetches all profile images and headshots associated with a person, identified by their TMDB ID. ```APIDOC ## getImages(int personId) ### Description Get profile images for a person. ### Parameters #### Path Parameters - **personId** (int) - Required - The TMDB person ID ### Returns `PersonImages` - Profile images and headshots ### Throws `TmdbException` - If the request fails ``` -------------------------------- ### Get Alternative Titles Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbmovies.md Retrieves alternative titles for a movie, specified by its ID and an optional country code. ```java public AlternativeTitles getAlternativeTitles(int movieId, String country) throws TmdbException ``` -------------------------------- ### Get Account Details Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbaccount.md Retrieves the authenticated user's account details. Requires a valid session ID. ```java Account account = tmdbApi.getAccount().getDetails(sessionId); System.out.println("Username: " + account.getUsername()); System.out.println("Avatar: " + account.getAvatar()); ``` -------------------------------- ### Get Movie Recommendations with Pagination Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/configuration.md Retrieves a paginated list of movie recommendations for a given movie ID and language. Each page contains 20 items, and requests can be made for pages 1 through 500. ```java MovieResultsPage page1 = tmdbApi.getMovies().getRecommendations(550, "en-US", 1); MovieResultsPage page2 = tmdbApi.getMovies().getRecommendations(550, "en-US", 2); ``` -------------------------------- ### Append Images to Movie Details (Null Example) Source: https://github.com/c-eg/themoviedbapi/blob/master/README.md Demonstrates that calling getImages() without specifying appendable responses will result in null. ```java TmdbMovies tmdbMovies = tmdbApi.getMovies(); MovieDb movie = tmdbMovies.getDetails(5353, "en-US"); Images images = movie.getImages(); // this will be null ``` -------------------------------- ### Get Movie Details with Language Parameter Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/configuration.md Fetches movie details for a specific movie ID and language. The default language is 'en-US'. ```java MovieDb movie = tmdbApi.getMovies().getDetails(550, "en-US"); ``` -------------------------------- ### Get Account Details Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbapi.md Retrieves handler for account-related API calls and then fetches account details using a session ID. ```java TmdbAccount account = tmdbApi.getAccount(); Account accountDetails = account.getDetails(sessionId); ``` -------------------------------- ### Get TV Episode Account States Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvepisodes.md Fetches the account state, including rating and watchlist status, for a specific TV episode. Requires session or guest session IDs. ```java public AccountStates getAccountStates(int seriesId, int seasonNumber, int episodeNumber, String sessionId, String guestSessionId) throws TmdbException ``` -------------------------------- ### Get Trending People Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtrending.md Get trending people based on the specified time window and language. Results are paginated. ```java public PopularPersonResultsPage getPersonTrending(TimeWindow timeWindow, String language) throws TmdbException ``` -------------------------------- ### Search for Movies Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbsearch.md Search for movies by title, including options for adult content, language, release year, and region. This example demonstrates iterating through movie results. ```java public MovieResultsPage searchMovie(String query, Boolean includeAdult, String language, String primaryReleaseYear, Integer page, String region, String year) throws TmdbException ``` ```java MovieResultsPage results = search.searchMovie("Inception", false, "en-US", null, 1, "US", null); for (Movie movie : results.getResults()) { System.out.println(movie.getTitle() + " (" + movie.getReleaseDate() + ")"); } ``` -------------------------------- ### Get Trending Movies Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtrending.md Get trending movies based on the specified time window and language. Results are paginated. ```java public MovieResultsPage getMovieTrending(TimeWindow timeWindow, String language) throws TmdbException ``` ```java MovieResultsPage trendingToday = tmdbApi.getTrending() .getMovieTrending(TimeWindow.DAY, "en-US"); for (Movie movie : trendingToday.getResults()) { System.out.println(movie.getTitle() + " (trending score: " + movie.getPopularity() + ")"); } ``` -------------------------------- ### Get Account States for a Movie Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbmovies.md Fetches the rating, watchlist, and favorite status for a movie for an authenticated user. Use either a sessionId or guestSessionId. ```java public AccountStates getAccountStates(int movieId, String sessionId, String guestSessionId) throws TmdbException ``` ```java AccountStates states = movies.getAccountStates(550, sessionId, null); if (states.getRated() != null) { System.out.println("User rating: " + states.getRated()); } ``` -------------------------------- ### TmdbApi Initialization with API Key Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbapi.md Instantiate the TmdbApi client using your TMDB API read access token. This is the standard way to begin using the library. ```java public TmdbApi(String apiKey) ``` ```java TmdbApi tmdbApi = new TmdbApi("your-api-key-here"); ``` -------------------------------- ### Get Trending TV Shows Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtrending.md Get trending TV shows based on the specified time window and language. Results are paginated. ```java public TvSeriesResultsPage getTvTrending(TimeWindow timeWindow, String language) throws TmdbException ``` -------------------------------- ### Clean, Publish, and Deploy Project Source: https://github.com/c-eg/themoviedbapi/blob/master/devel_notes.md Executes the Gradle tasks for cleaning the project, publishing artifacts, and deploying releases. Ensure all prerequisites are met before running. ```bash ./gradlew clean && ./gradlew publish && ./gradlew jreleaserDeploy ``` -------------------------------- ### Complete TMDb Account API Example Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbaccount.md Demonstrates fetching account details, favorite movies, watchlist, and rated movies. Also shows how to mark a movie as favorite and add it to the watchlist. Requires a valid session ID. ```java TmdbAccount account = tmdbApi.getAccount(); // Get account details Account accountInfo = account.getDetails(sessionId); System.out.println("Welcome, " + accountInfo.getUsername()); // Get favorite movies MovieResultsPage favorites = account.getFavoriteMovies(sessionId, "en-US", 1); for (Movie movie : favorites.getResults()) { System.out.println(movie.getTitle()); } // Get watchlist MovieResultsPage watchlist = account.getWatchlistMovies(sessionId, "en-US", 1); System.out.println("Watchlist: " + watchlist.getTotalResults() + " movies"); // Get rated movies RatedMovieResultsPage rated = account.getRatedMovies(sessionId, "en-US", 1); for (RatedMovie movie : rated.getResults()) { System.out.println(movie.getTitle() + " - Rating: " + movie.getRating()); } // Add a movie to favorites ResponseStatus status = account.markAsFavorite(550, sessionId, true, "movie"); if (status.isSuccess()) { System.out.println("Added to favorites"); } // Add a movie to watchlist status = account.addToWatchlist(550, sessionId, true, "movie"); if (status.isSuccess()) { System.out.println("Added to watchlist"); } ``` -------------------------------- ### Get TV Episode Videos Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvepisodes.md Retrieves video clips and trailers for a specific TV episode using its series ID, season number, episode number, and language code. ```java public VideoResults getVideos(int seriesId, int seasonNumber, int episodeNumber, String language) throws TmdbException ``` -------------------------------- ### Get TV Season Account States Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvseasons.md Fetches the account states (ratings) for all episodes within a given TV season. Requires a user session ID or guest session ID. ```java public AccountStateResults getAccountStates(int seriesId, int seasonNumber, String sessionId, String guestSessionId) throws TmdbException ``` -------------------------------- ### Initialize TmdbApi with String API Key Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/configuration.md Use this constructor for most use cases. It internally creates a default HTTP client. ```java TmdbApi tmdbApi = new TmdbApi("your-api-key"); ``` -------------------------------- ### Get TV Episode Translations Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvepisodes.md Fetches translations for the episode's name and overview. ```java public Translations getTranslations(int seriesId, int seasonNumber, int episodeNumber) throws TmdbException ``` -------------------------------- ### Get Combined Credits for a Person Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbpeoplewithgenres.md Fetches all movie and TV credits for a specified person, across all their roles. Requires the person's ID and optionally a language code. ```java public CombinedPersonCredits getCombinedCredits(int personId, String language) throws TmdbException ``` -------------------------------- ### Get Collection Translations Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbcollections.md Retrieves translated titles and overviews for a given movie collection. ```APIDOC ## getTranslations(int collectionId) ### Description Get translated titles and overviews for a collection. ### Method GET ### Endpoint /collection/{collectionId}/translations ### Parameters #### Path Parameters - **collectionId** (int) - Required - The TMDB collection ID ### Response #### Success Response (200) - **Translations** - Translated collection data ### Throws - **TmdbException** - If the request fails ``` -------------------------------- ### User Authentication Flow Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/INDEX.md Demonstrates the multi-step process for user authentication, including creating a request token, user approval, and creating a session. It concludes by fetching account details using the established session. ```java // Step 1: Create request token RequestToken token = tmdbApi.getAuthentication().createRequestToken(); // Step 2: User approves at https://www.themoviedb.org/auth/access?request_token={token} // Step 3: Create session RequestToken approved = tmdbApi.getAuthentication() .createSessionWithLogin(username, password, token.getRequestToken()); Session session = tmdbApi.getAuthentication() .createSessionFromToken(approved.getRequestToken()); // Now use the session Account account = tmdbApi.getAccount().getDetails(session.getSessionId()); ``` -------------------------------- ### Initialize TmdbApi with Environment Variable API Key Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/configuration.md Recommended approach for securely providing your API key. It internally creates a default HTTP client. ```java String apiKey = System.getenv("TMDB_API_KEY"); TmdbApi tmdbApi = new TmdbApi(apiKey); ``` -------------------------------- ### Get TV Episode Images Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvepisodes.md Retrieves still images associated with a specific TV episode. ```APIDOC ## Get TV Episode Images ### Description Fetches images for a specific TV episode. ### Method GET ### Endpoint `/tv/episode/{episode_number}/images` (This is a conceptual representation, actual SDK method is `getImages`) ### Parameters #### Path Parameters - **series_id** (integer) - Required - The ID of the TV series. - **season_number** (integer) - Required - The number of the season. - **episode_number** (integer) - Required - The number of the episode. ### Request Example ```java TmdbTvEpisodes episodes = tmdbApi.getTvEpisodes(); Images images = episodes.getImages(1396, 1, 1); ``` ### Response #### Success Response (200) - **backdrops** (array) - List of backdrop images. - **stills** (array) - List of still images. #### Response Example ```json { "backdrops": [], "stills": [] } ``` ``` -------------------------------- ### Rate Content with User or Guest Session Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/INDEX.md Shows how to rate content using either a user's session ID or a guest session ID. A guest session can be created if a user is not logged in. ```java // With user session ResponseStatus status = tmdbApi.getMovies() .addRating(550, null, sessionId, 8.5); // With guest session (no account required) GuestSession guest = tmdbApi.getAuthentication().createGuestSession(); status = tmdbApi.getMovies() .addRating(550, guest.getGuestSessionId(), null, 8.5); ``` -------------------------------- ### Get TV Episode Credits Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvepisodes.md Retrieves the cast and crew information for a specific TV episode. ```APIDOC ## Get TV Episode Credits ### Description Fetches the cast and crew credits for a specific TV episode. ### Method GET ### Endpoint `/tv/episode/{episode_number}/credits` (This is a conceptual representation, actual SDK method is `getCredits`) ### Parameters #### Path Parameters - **series_id** (integer) - Required - The ID of the TV series. - **season_number** (integer) - Required - The number of the season. - **episode_number** (integer) - Required - The number of the episode. #### Query Parameters - **language** (string) - Optional - ISO 639-1 code to specify the language of the result. ### Request Example ```java TmdbTvEpisodes episodes = tmdbApi.getTvEpisodes(); EpisodeCredits credits = episodes.getCredits(1396, 1, 1, "en-US"); ``` ### Response #### Success Response (200) - **cast** (array) - List of cast members. - **crew** (array) - List of crew members. #### Response Example ```json { "cast": [ { "name": "Actor Name", "character": "Character Name" } ], "crew": [] } ``` ``` -------------------------------- ### Initialize TmdbApi with Custom TmdbHttpClient Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/configuration.md Instantiate TmdbApi using a pre-configured TmdbHttpClient. This allows for custom HTTP configurations. ```java TmdbApi tmdbApi = new TmdbApi(new TmdbHttpClient(apiKey)); ``` -------------------------------- ### Basic API Client Initialization and Usage Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/INDEX.md Initialize the TmdbApi client with your API key and retrieve movie details. Ensure you have a valid API key. ```java // Initialize the API client TmdbApi tmdbApi = new TmdbApi("your-api-key"); // Get a handler for the resource you want TmdbMovies movies = tmdbApi.getMovies(); // Make requests MovieDb movie = movies.getDetails(550, "en-US"); System.out.println(movie.getTitle()); ``` -------------------------------- ### Get TV Season Images Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvseasons.md Retrieves posters and other images associated with a specific TV season. ```APIDOC ## GET /tv/season/{season_number}/images ### Description Get posters and other images for a season. ### Method GET ### Endpoint `/tv/{series_id}/season/{season_number}/images` ### Parameters #### Path Parameters - **series_id** (int) - Required - The TMDB TV series ID - **season_number** (int) - Required - Season number ### Response #### Success Response (200) - **Images** - Posters and other images ``` -------------------------------- ### Get TV Season Translations Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvseasons.md Fetches translated versions of the season's name and overview. ```java public Translations getTranslations(int seriesId, int seasonNumber) throws TmdbException ``` -------------------------------- ### Constructor for TmdbTvEpisodes Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvepisodes.md Initializes a new TmdbTvEpisodes instance. This is typically accessed via TmdbApi.getTvEpisodes() rather than direct instantiation. ```java public TmdbTvEpisodes(TmdbApi tmdbApi) ``` -------------------------------- ### Handle Multiple Search Results Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbfind.md Demonstrates how to handle cases where a search query might return multiple results across different categories (movies, TV, people). It iterates through each result type to display relevant information. ```java FindResults results = tmdbApi.getFind() .find("Breaking Bad", ExternalSource.TVDB_ID, "en-US"); // Note: TVDB ID search may return multiple results System.out.println("Movies: " + results.getMovieResults().size()); System.out.println("TV: " + results.getTvResults().size()); System.out.println("Episodes: " + results.getTvEpisodeResults().size()); System.out.println("People: " + results.getPersonResults().size()); // Check all results for (FindMovie movie : results.getMovieResults()) { System.out.println("Movie: " + movie.getTitle()); } for (FindTvSeries tv : results.getTvResults()) { System.out.println("TV: " + tv.getName()); } for (FindPerson person : results.getPersonResults()) { System.out.println("Person: " + person.getName()); } ``` -------------------------------- ### Get Movie Watch Providers Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbmovies.md Fetches the streaming providers and availability for a movie based on its ID. ```java public ProviderResults getWatchProviders(int movieId) throws TmdbException ``` -------------------------------- ### Configure Logback for TheMovieDB API Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/configuration.md Use this XML configuration to set up Logback for logging TheMovieDB API library events at the INFO level. Ensure the logback-classic dependency is on your classpath. ```xml %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n ``` -------------------------------- ### Get Trending Movies Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/INDEX.md Fetches a list of trending movies for the current day in a specified language. ```java TmdbTrending trending = tmdbApi.getTrending(); MovieResultsPage trendy = trending.getMovieTrending(TimeWindow.DAY, "en-US"); ``` -------------------------------- ### Get Translations Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbpeoplewithgenres.md Retrieves translations of a person's biography and name, identified by their TMDB ID. ```APIDOC ## getTranslations(int personId) ### Description Get translations of a person's biography and name. ### Parameters #### Path Parameters - **personId** (int) - Required - The TMDB person ID ### Returns `Translations` - Translated biographies and names ### Throws `TmdbException` - If the request fails ``` -------------------------------- ### API Reference Overview Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt This section outlines the structure and content of the API reference documentation, detailing the different API handlers and their coverage. ```APIDOC ## API Reference This API reference details 13 distinct handlers, each covering specific functionalities of TheMovieDB. ### Handlers: - **tmdbapi.md**: Main entry point and factory. - **tmdbmovies.md**: Movie details and operations. - **tmdbsearch.md**: Search functionality. - **tmdbdiscover.md**: Advanced discovery and filtering. - **tmdbtvepisodes.md**: TV episode operations. - **tmdbtvseasons.md**: TV season operations. - **tmdbpeoplewithgenres.md**: People/actor details. - **tmdbgenre.md**: Genre reference data. - **tmdbgenreauth.md**: Authentication. - **tmdbaccount.md**: Account operations. - **tmdbtrending.md**: Trending content. - **tmdbfind.md**: Find by external ID. - **tmdbcollections.md**: Movie collections. Each handler is documented with public methods, parameter details, return types, exceptions, and usage examples. ``` -------------------------------- ### Instantiate TmdbApi Source: https://github.com/c-eg/themoviedbapi/blob/master/README.md Instantiate the TmdbApi class with your API Read Access Token to begin using the library. ```java TmdbApi tmdbApi = new TmdbApi(""); ``` -------------------------------- ### Guest Session Authentication Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbgenreauth.md This snippet demonstrates how to create a guest session, which provides a session ID for immediate use without requiring user login or approval. This is useful for actions like rating movies anonymously. ```APIDOC ## Guest Session Authentication ### Description This method allows for immediate access to certain API features without requiring a user to log in. A guest session ID is generated, which can be used for actions like rating content. ### Method `createGuestSession()` ### Response - **guestSessionId** (string) - The ID for the guest session. ### Code Example (Java) ```java GuestSession guest = tmdbApi.getAuthentication().createGuestSession(); String guestSessionId = guest.getGuestSessionId(); // Can immediately use for rating without user login ResponseStatus status = tmdbApi.getMovies() .addRating(550, guestSessionId, null, 8.5); ``` ``` -------------------------------- ### Get TV Season Translations Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvseasons.md Fetches translations for the season's name and overview in various languages. ```APIDOC ## GET /tv/season/{season_number}/translations ### Description Get translations of season name and overview. ### Method GET ### Endpoint `/tv/{series_id}/season/{season_number}/translations` ### Parameters #### Path Parameters - **series_id** (int) - Required - The TMDB TV series ID - **season_number** (int) - Required - Season number ### Response #### Success Response (200) - **Translations** - Translated names and overviews ``` -------------------------------- ### Create Guest Session Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbgenreauth.md Generates a guest session for temporary anonymous access. Guest sessions allow actions like rating movies without requiring user login but have limited functionality. ```java GuestSession guest = tmdbApi.getAuthentication().createGuestSession(); System.out.println("Guest Session: " + guest.getGuestSessionId()); System.out.println("Expires: " + guest.getExpiresAt()); ``` -------------------------------- ### Create Session from Token Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbgenreauth.md Establishes a user session using an approved request token. This is the final step in the 3-step authentication process. ```APIDOC ## createSessionFromToken(String requestToken) ### Description Create a session from an approved request token. This is step 3 of the 3-step authentication process. ### Method ```java public Session createSessionFromToken(String requestToken) throws TmdbException ``` ### Parameters #### Path Parameters - **requestToken** (String) - Required - Approved request token from createSessionWithLogin() ### Returns `Session` - Contains the session ID for authenticated requests ### Throws `TmdbException` - If the token is not approved or has expired ### Example ```java Session session = tmdbApi.getAuthentication().createSessionFromToken(approvedToken.getRequestToken()); String sessionId = session.getSessionId(); System.out.println("Session Created: " + sessionId); ``` ``` -------------------------------- ### Gradle Properties Configuration Source: https://github.com/c-eg/themoviedbapi/blob/master/devel_notes.md Configuration for signing and PGP key usage in Gradle. Ensure the paths and values are correctly set in your global gradle.properties file. ```properties signing.keyId = signing.password = signing.secretKeyRingFile = C:/gpg/secring.gpg ``` -------------------------------- ### Get TV Season Credits Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvseasons.md Retrieves the cast and crew credits for a specific TV season. Language can be specified. ```java public Credits getCredits(int seriesId, int seasonNumber, String language) throws TmdbException ``` -------------------------------- ### Guest Session Authentication Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbgenreauth.md This snippet shows how to create a guest session ID instantly without user login or approval. Guest sessions are suitable for performing actions like rating movies anonymously. The obtained guest session ID can be used immediately. ```java GuestSession guest = tmdbApi.getAuthentication().createGuestSession(); String guestSessionId = guest.getGuestSessionId(); // Can immediately use for rating without user login ResponseStatus status = tmdbApi.getMovies() .addRating(550, guestSessionId, null, 8.5); ``` -------------------------------- ### Get Collection Translations Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbcollections.md Retrieves translated titles and overviews for a movie collection. The collection ID is required for this operation. ```java public Translations getTranslations(int collectionId) throws TmdbException ``` -------------------------------- ### TmdbApi Initialization with Custom URL Reader Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbapi.md Create a TmdbApi client with a custom TmdbUrlReader. This is useful for testing purposes or when integrating with custom HTTP client implementations. ```java public TmdbApi(TmdbUrlReader tmdbUrlReader) ``` -------------------------------- ### Search for Movies, TV Shows, and People Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbsearch.md Search across multiple media types (movies, TV shows, people) in a single request. The results include a media_type field to distinguish between them. This example shows how to extract the media type and name from the results. ```java public MultiResultsPage searchMulti(String query, Boolean includeAdult, String language, Integer page) throws TmdbException ``` ```java MultiResultsPage results = search.searchMulti("Tom Cruise", false, "en-US", 1); for (Multi multi : results.getResults()) { String mediaType = multi.getMediaType(); // "movie", "tv", or "person" String name = multi.getTitle() != null ? multi.getTitle() : multi.getName(); System.out.println(name + " (" + mediaType + ")"); } ``` -------------------------------- ### Get TV Genres Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbgenre.md Retrieves a list of all available TV genres. This is useful for filtering TV discovery results. ```APIDOC ## getTvGenres(String language) ### Description Get all TV genres. Useful for filtering discover results. ### Method GET ### Endpoint /genre/tv/list ### Parameters #### Query Parameters - **language** (String) - Optional - Language code (default: en-US) ### Response #### Success Response (200) - **genres** (List) - List of genre objects ### Response Example ```json { "genres": [ { "id": 10759, "name": "Action & Adventure" }, { "id": 16, "name": "Animation" } ] } ``` ``` -------------------------------- ### Configure Log4j2 for TheMovieDB API Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/configuration.md This XML configuration sets up Log4j2 for logging TheMovieDB API library events. It directs logs to the console at the INFO level. Ensure the log4j-core dependency is available. ```xml ``` -------------------------------- ### Get Movie Genres Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbgenre.md Retrieves a list of all available movie genres. This is useful for filtering movie discovery results. ```APIDOC ## getMovieGenres(String language) ### Description Get all movie genres. Useful for filtering discover results. ### Method GET ### Endpoint /genre/movie/list ### Parameters #### Query Parameters - **language** (String) - Optional - Language code (default: en-US) ### Response #### Success Response (200) - **genres** (List) - List of genre objects ### Response Example ```json { "genres": [ { "id": 28, "name": "Action" }, { "id": 12, "name": "Adventure" } ] } ``` ``` -------------------------------- ### Get TV Episode External IDs Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvepisodes.md Fetches external identifiers such as IMDb and TVDb IDs for a specific TV episode. ```java public ExternalIds getExternalIds(int seriesId, int seasonNumber, int episodeNumber) throws TmdbException ``` -------------------------------- ### Create Session with Login Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbgenreauth.md Approves a request token by providing TMDB user credentials. This is the second step in the 3-step authentication process. ```APIDOC ## createSessionWithLogin(String username, String password, String requestToken) ### Description Approve the request token by providing TMDB user credentials. This is step 2 of the 3-step authentication process. ### Method ```java public RequestToken createSessionWithLogin(String username, String password, String requestToken) throws TmdbException ``` ### Parameters #### Path Parameters - **username** (String) - Required - TMDB username - **password** (String) - Required - TMDB password - **requestToken** (String) - Required - Request token from createRequestToken() ### Returns `RequestToken` - Approved request token ### Throws `TmdbException` - If credentials are invalid or token is expired ### Example ```java RequestToken approved = tmdbApi.getAuthentication() .createSessionWithLogin("myusername", "mypassword", requestToken.getRequestToken()); ``` ``` -------------------------------- ### Get TV Episode Credits Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvepisodes.md Retrieves the cast and crew credits for a specific TV episode. Supports language filtering. ```java public EpisodeCredits getCredits(int seriesId, int seasonNumber, int episodeNumber, String language) throws TmdbException ``` -------------------------------- ### getConfiguration() Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbapi.md Returns a handler for configuration-related API calls. This is useful for retrieving API configuration settings. ```APIDOC ## getConfiguration() ### Description Returns handler for configuration-related API calls. ### Returns `TmdbConfiguration` - An object to interact with configuration endpoints. ``` -------------------------------- ### Get TV Season Videos Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvseasons.md Retrieves videos, such as trailers and clips, for a specific TV season. Supports language specification. ```APIDOC ## GET /tv/season/{season_number}/videos ### Description Get videos (trailers, clips) for a season. ### Method GET ### Endpoint `/tv/{series_id}/season/{season_number}/videos` ### Parameters #### Path Parameters - **series_id** (int) - Required - The TMDB TV series ID - **season_number** (int) - Required - Season number #### Query Parameters - **language** (String) - Optional - Language code (default: en-US) ### Response #### Success Response (200) - **VideoResults** - Videos for the season ``` -------------------------------- ### getSimilar Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbmovies.md Fetches movies that are similar to a given movie, with support for language and pagination. ```APIDOC ## getSimilar(int movieId, String language, Integer page) ### Description Get movies similar to this movie. ### Method GET ### Endpoint /movie/{movieId}/similar ### Parameters #### Path Parameters - **movieId** (int) - Required - The TMDB movie ID #### Query Parameters - **language** (String) - Optional - Language code (default: en-US) - **page** (Integer) - Optional - Results page number (default: 1) ### Response #### Success Response (200) - **MovieResultsPage** - Paginated list of similar movies #### Error Response - **TmdbException** - If the request fails ``` -------------------------------- ### Create Request Token Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbgenreauth.md Initiates the authentication flow by creating a request token. This is the first step in the 3-step authentication process. Obtain the RequestToken object and extract the token string for subsequent steps. ```java RequestToken requestToken = tmdbApi.getAuthentication().createRequestToken(); System.out.println("Request Token: " + requestToken.getRequestToken()); System.out.println("Expires At: " + requestToken.getExpiresAt()); ``` -------------------------------- ### Get TV Season External IDs Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvseasons.md Fetches external IDs, such as TVDb and IMDb identifiers, for a given TV season. ```APIDOC ## GET /tv/season/{season_number}/external_ids ### Description Get external IDs (TVDb, IMDb, etc.) for a season. ### Method GET ### Endpoint `/tv/{series_id}/season/{season_number}/external_ids` ### Parameters #### Path Parameters - **series_id** (int) - Required - The TMDB TV series ID - **season_number** (int) - Required - Season number ### Response #### Success Response (200) - **ExternalIds** - External identifiers ``` -------------------------------- ### Get TV Season Credits Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvseasons.md Retrieves the cast and crew credits for a specific TV season. Supports language specification. ```APIDOC ## GET /tv/season/{season_number}/credits ### Description Get cast and crew credits for a season. ### Method GET ### Endpoint `/tv/{series_id}/season/{season_number}/credits` ### Parameters #### Path Parameters - **series_id** (int) - Required - The TMDB TV series ID - **season_number** (int) - Required - Season number #### Query Parameters - **language** (String) - Optional - Language code (default: en-US) ### Response #### Success Response (200) - **Credits** - Season-level cast and crew ``` -------------------------------- ### TmdbTvSeasons Constructor Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvseasons.md Instantiates a TmdbTvSeasons object. This is typically accessed via TmdbApi.getTvSeasons() rather than direct instantiation. ```java public TmdbTvSeasons(TmdbApi tmdbApi) ``` -------------------------------- ### Get TV Season External IDs Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtvseasons.md Fetches external identifiers such as TVDb and IMDb IDs for a given TV season. ```java public ExternalIds getExternalIds(int seriesId, int seasonNumber) throws TmdbException ``` -------------------------------- ### TmdbAccount Constructor Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbaccount.md Instantiates a TmdbAccount. It's typically accessed via TmdbApi.getAccount() instead of direct instantiation. ```java public TmdbAccount(TmdbApi tmdbApi) ``` -------------------------------- ### TmdbTrending Constructor Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbtrending.md Creates a new TmdbTrending instance. Typically obtained via TmdbApi.getTrending() rather than direct instantiation. ```java public TmdbTrending(TmdbApi tmdbApi) ``` -------------------------------- ### Using Session IDs for Account Operations Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbgenreauth.md This snippet demonstrates how to use an existing session ID (either user or guest) to interact with account-specific API endpoints. It covers fetching account details, retrieving favorite movies, adding items to a watchlist, and rating movies. ```java String sessionId = session.getSessionId(); // Get account details Account account = tmdbApi.getAccount().getDetails(sessionId); // Get account favorite movies MovieResultsPage favorites = tmdbApi.getAccount() .getFavoriteMovies(sessionId, "en-US", 1); // Add to watchlist ResponseStatus status = tmdbApi.getMovies() .addToWatchlist(550, sessionId, null, true); // Rate a movie ResponseStatus rating = tmdbApi.getMovies() .addRating(550, null, sessionId, 8.5); ``` -------------------------------- ### Get Tagged Images for a Person Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbpeoplewithgenres.md Fetches images where a specific person has been tagged. Supports pagination by specifying a page number. ```java public TaggedImageResults getTaggedImages(int personId, Integer page) throws TmdbException ``` -------------------------------- ### TmdbMovies Constructor Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbmovies.md Creates a new TmdbMovies instance. Typically obtained via TmdbApi.getMovies() rather than direct instantiation. ```java public TmdbMovies(TmdbApi tmdbApi) ``` -------------------------------- ### Get TV Credits for a Person Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbpeoplewithgenres.md Fetches all TV credits (both cast and crew) for a person, identified by their ID. The language can be specified. ```java public TvCredits getTvCredits(int personId, String language) throws TmdbException ``` -------------------------------- ### Get Person Details Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbpeoplewithgenres.md Retrieves detailed information for a person by their ID, optionally specifying the language and additional response objects. ```java public PersonDb getDetails(int personId, String language, PersonAppendToResponse... appendToResponse) throws TmdbException ``` ```java PersonDb person = tmdbApi.getPeople().getDetails(500, "en-US"); System.out.println(person.getName()); System.out.println(person.getBiography()); ``` -------------------------------- ### Create Guest Session Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbgenreauth.md Generates a guest session for temporary, anonymous access to certain API features like rating content. ```APIDOC ## createGuestSession() ### Description Create a guest session for temporary anonymous access. Guest sessions allow rating movies/shows without user authentication but with limited functionality. ### Method ```java public GuestSession createGuestSession() throws TmdbException ``` ### Returns `GuestSession` - Contains the guest session ID and expiration time ### Throws `TmdbException` - If the request fails ### Example ```java GuestSession guest = tmdbApi.getAuthentication().createGuestSession(); System.out.println("Guest Session: " + guest.getGuestSessionId()); System.out.println("Expires: " + guest.getExpiresAt()); ``` ``` -------------------------------- ### TmdbSearch Constructor Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbsearch.md Creates a new TmdbSearch instance. Typically obtained via TmdbApi.getSearch() rather than direct instantiation. ```java public TmdbSearch(TmdbApi tmdbApi) ``` -------------------------------- ### Get TV Genres Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbgenre.md Retrieves a list of all TV genres. Useful for filtering discover results. Requires a language code. ```java public Genres getTvGenres(String language) throws TmdbException ``` ```java Genres tvGenres = tmdbApi.getGenre().getTvGenres("en-US"); for (Genre genre : tvGenres.getGenres()) { System.out.println(genre.getId() + ": " + genre.getName()); } ``` -------------------------------- ### Create Session with Login Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbgenreauth.md Approves a request token using TMDB user credentials. This is the second step in the 3-step authentication process. Ensure you have a valid username, password, and a previously created request token. ```java RequestToken approved = tmdbApi.getAuthentication() .createSessionWithLogin("myusername", "mypassword", requestToken.getRequestToken()); ``` -------------------------------- ### Get Movie Genres Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbgenre.md Retrieves a list of all movie genres. Useful for filtering discover results. Requires a language code. ```java public Genres getMovieGenres(String language) throws TmdbException ``` ```java Genres movieGenres = tmdbApi.getGenre().getMovieGenres("en-US"); for (Genre genre : movieGenres.getGenres()) { System.out.println(genre.getId() + ": " + genre.getName()); } ``` -------------------------------- ### Get Collection Details and Full Movie Info Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbcollections.md Retrieves details for a movie collection and then fetches comprehensive information for each movie within that collection. It prints the budget and revenue for each movie. Requires initialized TmdbCollections and TmdbMovies objects. ```java TmdbCollections collections = tmdbApi.getCollections(); TmdbMovies movies = tmdbApi.getMovies(); // Get collection CollectionInfo collection = collections.getDetails(2344, "en-US"); // Get detailed info for all movies List fullMovies = new ArrayList<>(); for (Part part : collection.getParts()) { MovieDb movie = movies.getDetails(part.getId(), "en-US"); fullMovies.add(movie); System.out.printf("%s: Budget=$%d, Revenue=$%d\n", movie.getTitle(), movie.getBudget(), movie.getRevenue() ); } ``` -------------------------------- ### Get External IDs Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbmovies.md Fetches external identifiers for a movie, such as IMDb, Wikidata, and social media links, using its TMDB ID. ```java public ExternalIds getExternalIds(int movieId) throws TmdbException ``` -------------------------------- ### Get Movie Credits Source: https://github.com/c-eg/themoviedbapi/blob/master/_autodocs/api-reference/tmdbmovies.md Retrieves cast and crew credits for a movie by its ID and language. Iterates through the cast to print names and characters. ```java public Credits getCredits(int movieId, String language) throws TmdbException ``` ```java Credits credits = movies.getCredits(550, "en-US"); for (Cast cast : credits.getCast()) { System.out.println(cast.getName() + " as " + cast.getCharacter()); } ```