### Get and Hide Movie/Show Recommendations Source: https://context7.com/trakt/trakt-api/llms.txt Fetch personalized movie and show recommendations for the authenticated user. Use the hide method to dismiss individual items so they do not reappear. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Get movie recommendations const movieRecs = await api.recommendations.movies.recommend({ query: { extended: 'full' }, }); // movieRecs.body: paginated list of recommended MovieResponse objects // Get show recommendations const showRecs = await api.recommendations.shows.recommend({ query: { extended: 'full' }, }); // Hide a movie recommendation (so it won't appear again) await api.recommendations.movies.hide({ params: { id: 'tt1375666' } }); // Hide a show recommendation await api.recommendations.shows.hide({ params: { id: 'breaking-bad' } }); ``` -------------------------------- ### Scrobble Operations Source: https://context7.com/trakt/trakt-api/llms.txt Track real-time playback progress for movies and episodes. Call `start` when playback begins, `pause` when paused, and `stop` when done. ```APIDOC ## Scrobble — Start, Pause, Stop (Movie and Episode) Track real-time playback progress for movies and episodes. Call `start` when playback begins, `pause` when paused, and `stop` when done. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Start scrobbling a movie at 0% progress await api.scrobble.movie.start({ body: { movie: { ids: { trakt: 56360 } }, progress: 0, }, query: {}, }); // Pause scrobbling at 45% progress await api.scrobble.movie.pause({ body: { movie: { ids: { trakt: 56360 } }, progress: 45.5, }, query: {}, }); // Stop scrobbling (marks as watched if progress >= 80%) await api.scrobble.movie.stop({ body: { movie: { ids: { trakt: 56360 } }, progress: 95, }, query: {}, }); // Scrobble a TV episode await api.scrobble.episode.start({ body: { episode: { season: 1, number: 1 }, show: { ids: { trakt: 1388 } }, progress: 0, }, query: {}, }); ``` ``` -------------------------------- ### Scrobble Movie and Episode Playback Progress Source: https://context7.com/trakt/trakt-api/llms.txt Track real-time playback progress for movies and episodes by calling 'start', 'pause', or 'stop'. Stopping with progress >= 80% marks the item as watched. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Start scrobbling a movie at 0% progress await api.scrobble.movie.start({ body: { movie: { ids: { trakt: 56360 } }, progress: 0, }, query: {}, }); // Pause scrobbling at 45% progress await api.scrobble.movie.pause({ body: { movie: { ids: { trakt: 56360 } }, progress: 45.5, }, query: {}, }); // Stop scrobbling (marks as watched if progress >= 80%) await api.scrobble.movie.stop({ body: { movie: { ids: { trakt: 56360 } }, progress: 95, }, query: {}, }); // Scrobble a TV episode await api.scrobble.episode.start({ body: { episode: { season: 1, number: 1 }, show: { ids: { trakt: 1388 } }, progress: 0, }, query: {}, }); ``` -------------------------------- ### Retrieve Content Certifications with Trakt API Source: https://context7.com/trakt/trakt-api/llms.txt Fetch content rating certifications for movies and shows. Use this to get age-rating information. Requires API key initialization. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Movie certifications const movieCerts = await api.certifications.movies({}); // movieCerts.body: { us: [{ certification, description, country }] } // Show certifications const showCerts = await api.certifications.shows({}); ``` -------------------------------- ### Get Person Summary and Credits Source: https://context7.com/trakt/trakt-api/llms.txt Retrieve a person's profile summary, including their acting and crew credits across movies and shows. Requires the person's ID. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Person summary const person = await api.people.summary({ params: { id: 'bryan-cranston' }, query: { extended: 'full,images' }, }); // person.body: { name, ids, biography, birthday, death, birthplace, images, ... } // Movie credits const movieCredits = await api.people.movies({ params: { id: 'bryan-cranston' }, query: { extended: 'full' }, }); // movieCredits.body: { cast: [{ character, movie }], crew: { directing: [...], ... } } // Show credits const showCredits = await api.people.shows({ params: { id: 'bryan-cranston' }, query: { extended: 'full' }, }); ``` -------------------------------- ### Get User Profile and Stats with Trakt API Source: https://context7.com/trakt/trakt-api/llms.txt Retrieve detailed user profile information, including stats, followers, following, friends, and current watching status. Use the 'extended' query parameter for more data. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Get user profile const profile = await api.users.profile({ params: { id: 'justin' }, query: { extended: 'full,vip' }, }); // profile.body: { username, name, vip, vip_ep, joined_at, location, about, images, ... } ``` ```typescript // User stats const stats = await api.users.stats({ params: { id: 'justin' } }); // stats.body: { movies: { plays, watched, minutes }, shows: { ... }, episodes: { ... }, ... } ``` ```typescript // Followers const followers = await api.users.followers({ params: { id: 'justin' }, query: { extended: 'full' }, }); ``` ```typescript // Following const following = await api.users.following({ params: { id: 'justin' }, query: {} }); ``` ```typescript // Friends (mutual follows) const friends = await api.users.friends({ params: { id: 'justin' }, query: {} }); ``` ```typescript // What a user is currently watching const watching = await api.users.watching({ params: { id: 'justin' }, query: {}, }); // Returns 200 with current media, or 204 if not watching ``` ```typescript // Month in review const mir = await api.users.month_in_review({ params: { id: 'justin', year: 2024, month: 5 }, query: {}, }); ``` ```typescript // Year in review const yir = await api.users.year_in_review({ params: { id: 'justin', year: 2023 }, query: {}, }); ``` ```typescript // Follow / Unfollow a user (authenticated) await api.users.follow({ params: { id: 'someuser' }, body: undefined }); await api.users.unfollow({ params: { id: 'someuser' } }); ``` -------------------------------- ### Initialize Trakt API Client Source: https://context7.com/trakt/trakt-api/llms.txt Create a typed Trakt API client using `traktApi`. Specify the environment, API key, and optionally a custom fetch implementation or cancellation settings. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, // 'https://api.trakt.tv' apiKey: 'YOUR_CLIENT_ID', }); // All sub-routers are available on the returned client: // api.movies, api.shows, api.search, api.users, api.sync, // api.oauth, api.calendars, api.checkin, api.scrobble, // api.recommendations, api.people, api.comments, api.lists, // api.watchnow, api.seasons, api.episodes, api.certifications, // api.media, api.team, api.social_recommendations ``` -------------------------------- ### `traktApi` / `traktApiFactory` Source: https://context7.com/trakt/trakt-api/llms.txt Initializes and returns a fully typed Trakt API client. This client is bound to the `traktContract` router and can be configured with an environment, API key, custom fetch implementation, and request cancellation settings. ```APIDOC ## `traktApi` / `traktApiFactory` — Create a Trakt API client Initializes and returns a fully typed Trakt API client bound to the `traktContract` router. Accepts an environment target, API key, optional custom `fetch` implementation, and optional request cancellation settings. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, // 'https://api.trakt.tv' apiKey: 'YOUR_CLIENT_ID', }); // All sub-routers are available on the returned client: // api.movies, api.shows, api.search, api.users, api.sync, // api.oauth, api.calendars, api.checkin, api.scrobble, // api.recommendations, api.people, api.comments, api.lists, // api.watchnow, api.seasons, api.episodes, api.certifications, // api.media, api.team, api.social_recommendations ``` ``` -------------------------------- ### Check-in to Movies or TV Episodes Source: https://context7.com/trakt/trakt-api/llms.txt Initiate a check-in for a movie or TV episode. Only one active check-in is allowed at a time; a 409 conflict is returned if one is already active. The current check-in can also be deleted. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Check in to a movie const movieCheckin = await api.checkin.start({ body: { movie: { ids: { trakt: 56360 } }, sharing: { twitter: false }, message: 'Watching Inception!', }, }); // Returns 200 with checkin details, or 409 if already checked in // Check in to a show episode const showCheckin = await api.checkin.start({ body: { episode: { season: 1, number: 1 }, show: { ids: { trakt: 1388 } }, message: 'Starting Breaking Bad', }, }); // Delete (cancel) the current check-in const deleted = await api.checkin.delete({}); // Returns 204 on success ``` -------------------------------- ### Search Movies, Shows, People, and Lists Source: https://context7.com/trakt/trakt-api/llms.txt Use text queries or exact titles to search for various content types. Recent searches can be managed for authenticated users. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Text search across movies const results = await api.search.query({ params: { type: 'movie' }, query: { query: 'inception', extended: 'full,images', page: 1, limit: 5 }, }); // results.body: Array<{ score, type, movie?: MovieResponse, show?: ShowResponse, person?: PersonResponse }> // Exact title match for shows const exact = await api.search.exact({ params: { type: 'show' }, query: { query: 'Breaking Bad', page: 1, limit: 3 }, }); // Trending search terms for people const trendingPeople = await api.search.trending({ params: { type: 'people' }, query: { page: 1, limit: 10 }, }); // Add a search to the user's recent searches (authenticated) await api.search.recent.add({ body: { query: 'inception', type: 'movie' } }); // Remove from recent searches (authenticated) await api.search.recent.remove({ body: { query: 'inception', type: 'movie' } }); ``` -------------------------------- ### Retrieve Calendar Data for Shows, Movies, and Releases Source: https://context7.com/trakt/trakt-api/llms.txt Fetch scheduled air dates for episodes, premieres, finales, and movie/DVD releases. The 'target' parameter can be set to 'all' or 'my' (user-specific). ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // All shows airing in the next 7 days starting today const shows = await api.calendars.shows({ params: { target: 'all', start_date: '2024-06-01', days: 7 }, query: { extended: 'full' }, }); // shows.body: Array<{ first_aired, episode: EpisodeResponse, show: ShowResponse }> // New shows premiering const newShows = await api.calendars.newShows({ params: { target: 'all', start_date: '2024-06-01', days: 7 }, query: {}, }); // Season premieres const premieres = await api.calendars.seasonPremieres({ params: { target: 'all', start_date: '2024-06-01', days: 30 }, query: { extended: 'full' }, }); // Season finales const finales = await api.calendars.finales({ params: { target: 'all', start_date: '2024-06-01', days: 30 }, query: {}, }); // Movie releases const movies = await api.calendars.movies({ params: { target: 'all', start_date: '2024-06-01', days: 14 }, query: { extended: 'full' }, }); // DVD releases const dvd = await api.calendars.dvdReleases({ params: { target: 'all', start_date: '2024-06-01', days: 14 }, query: {}, }); ``` -------------------------------- ### Shows - Summary, Trending, Popular, Watched, Seasons, Episodes Source: https://context7.com/trakt/trakt-api/llms.txt Comprehensive show endpoints including season/episode navigation and show-level progress. ```APIDOC ## Shows — Summary, Trending, Popular, Watched, Seasons, Episodes Comprehensive show endpoints including season/episode navigation and show-level progress. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Show summary const show = await api.shows.summary({ params: { id: 'breaking-bad' }, query: { extended: 'full' }, }); // show.body: { title, year, ids, overview, first_aired, runtime, network, status, rating, genres, ... } // All seasons const seasons = await api.shows.seasons({ params: { id: 'breaking-bad' }, query: { extended: 'full' }, }); // seasons.body: Array<{ number, ids, title, overview, episode_count, aired_episodes, ... }> // Episodes in a season const episodes = await api.shows.season.episodes({ params: { id: 'breaking-bad', season: 1 }, query: { extended: 'full' }, }); // Specific episode summary const episode = await api.shows.episode.summary({ params: { id: 'breaking-bad', season: 1, episode: 1 }, query: { extended: 'full' }, }); // Show watch progress (authenticated) const progress = await api.shows.progress.watched({ params: { id: 'breaking-bad' }, query: {}, }); // progress.body: { aired, completed, last_episode, next_episode, seasons: [...] } // Trending shows const trending = await api.shows.trending({ query: { extended: 'full', page: 1, limit: 10 } }); // Watched shows in a period const watched = await api.shows.watched({ params: { period: 'monthly' }, query: {} }); ``` ``` -------------------------------- ### Recommendations Source: https://context7.com/trakt/trakt-api/llms.txt Retrieve personalized movie and show recommendations for the authenticated user. You can also dismiss individual items to refine future recommendations. ```APIDOC ## Recommendations — Movies and Shows Get personalized movie and show recommendations for the authenticated user, with the ability to dismiss (hide) individual items. ### Get movie recommendations ```typescript const movieRecs = await api.recommendations.movies.recommend({ query: { extended: 'full' }, }); // movieRecs.body: paginated list of recommended MovieResponse objects ``` ### Get show recommendations ```typescript const showRecs = await api.recommendations.shows.recommend({ query: { extended: 'full' }, }); ``` ### Hide a movie recommendation ```typescript await api.recommendations.movies.hide({ params: { id: 'tt1375666' } }); ``` ### Hide a show recommendation ```typescript await api.recommendations.shows.hide({ params: { id: 'breaking-bad' } }); ``` ``` -------------------------------- ### Retrieve Streaming Sources with Trakt API Source: https://context7.com/trakt/trakt-api/llms.txt Fetch global or country-specific streaming providers. Use this to find where content is available. Requires API key initialization. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // All global streaming sources const allSources = await api.watchnow.sources.all({}); // allSources.body: Array<{ name, country_code, display_priority, ... }> // Streaming sources available in a specific country const usSources = await api.watchnow.sources.country({ params: { countryCode: 'us' }, }); // Streaming availability for a specific movie in a country const movieStreaming = await api.movies.watchnow({ params: { id: 'inception-2010', country: 'us' }, query: {}, }); // Streaming availability for a specific show in a country const showStreaming = await api.shows.watchnow({ params: { id: 'breaking-bad', country: 'us' }, query: {}, }); ``` -------------------------------- ### Fetch Show Summaries and Lists Source: https://context7.com/trakt/trakt-api/llms.txt Retrieve show summaries, trending shows, and watched shows. This section also covers fetching all seasons for a show, episodes within a season, and specific episode summaries. Progress tracking requires authentication. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Show summary const show = await api.shows.summary({ params: { id: 'breaking-bad' }, query: { extended: 'full' }, }); // show.body: { title, year, ids, overview, first_aired, runtime, network, status, rating, genres, ... } ``` ```typescript // All seasons const seasons = await api.shows.seasons({ params: { id: 'breaking-bad' }, query: { extended: 'full' }, }); // seasons.body: Array<{ number, ids, title, overview, episode_count, aired_episodes, ... }> ``` ```typescript // Episodes in a season const episodes = await api.shows.season.episodes({ params: { id: 'breaking-bad', season: 1 }, query: { extended: 'full' }, }); ``` ```typescript // Specific episode summary const episode = await api.shows.episode.summary({ params: { id: 'breaking-bad', season: 1, episode: 1 }, query: { extended: 'full' }, }); ``` ```typescript // Show watch progress (authenticated) const progress = await api.shows.progress.watched({ params: { id: 'breaking-bad' }, query: {}, }); // progress.body: { aired, completed, last_episode, next_episode, seasons: [...] } ``` ```typescript // Trending shows const trending = await api.shows.trending({ query: { extended: 'full', page: 1, limit: 10 } }); ``` ```typescript // Watched shows in a period const watched = await api.shows.watched({ params: { period: 'monthly' }, query: {} }); ``` -------------------------------- ### Check-in Operations Source: https://context7.com/trakt/trakt-api/llms.txt Check a user in to a movie or TV episode they are currently watching. Only one active check-in at a time is permitted; a 409 conflict is returned if one is already active. ```APIDOC ## Check-in — Start / Delete Check a user in to a movie or TV episode they are currently watching. Only one active check-in at a time is permitted; a 409 conflict is returned if one is already active. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Check in to a movie const movieCheckin = await api.checkin.start({ body: { movie: { ids: { trakt: 56360 } }, sharing: { twitter: false }, message: 'Watching Inception!', }, }); // Returns 200 with checkin details, or 409 if already checked in // Check in to a show episode const showCheckin = await api.checkin.start({ body: { episode: { season: 1, number: 1 }, show: { ids: { trakt: 1388 } }, message: 'Starting Breaking Bad', }, }); // Delete (cancel) the current check-in const deleted = await api.checkin.delete({}); // Returns 204 on success ``` ``` -------------------------------- ### Fetch Movie Summaries and Lists Source: https://context7.com/trakt/trakt-api/llms.txt Use these methods to retrieve movie summaries, trending lists, watched lists, anticipated movies, popular movies, hot movies, and recently streaming movies. Supports extended query parameters and pagination. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Movie summary (extended full + images) const summary = await api.movies.summary({ params: { id: 'inception-2010' }, query: { extended: 'full,images' }, }); // summary.body: { title, year, ids, tagline, overview, released, runtime, rating, votes, genres, ... } ``` ```typescript // Trending movies with pagination const trending = await api.movies.trending({ query: { extended: 'full', page: 1, limit: 10 }, }); // trending.body: Array<{ watchers: number, movie: MovieResponse }> ``` ```typescript // Most watched movies in a period const watched = await api.movies.watched({ params: { period: 'weekly' }, query: { extended: 'full', page: 1, limit: 10 }, }); // watched.body: Array<{ watcher_count, play_count, collector_count, movie: MovieResponse }> ``` ```typescript // Anticipated movies const anticipated = await api.movies.anticipated({ query: { page: 1, limit: 5 } }); ``` ```typescript // Popular movies const popular = await api.movies.popular({ query: { extended: 'images' } }); ``` ```typescript // Hot movies (trending by engagement) const hot = await api.movies.hot({ query: {} }); ``` ```typescript // Recently streaming movies const streaming = await api.movies.streaming({ params: { period: 'daily' }, query: {}, }); ``` -------------------------------- ### Watch Now - Streaming Sources Source: https://context7.com/trakt/trakt-api/llms.txt Retrieve available streaming providers globally or filtered by country code. This includes fetching all global sources, sources for a specific country, and streaming availability for movies and shows in a given country. ```APIDOC ## Watch Now — Streaming Sources Retrieve available streaming providers globally or filtered by country code. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // All global streaming sources const allSources = await api.watchnow.sources.all({}); // allSources.body: Array<{ name, country_code, display_priority, ... }> // Streaming sources available in a specific country const usSources = await api.watchnow.sources.country({ params: { countryCode: 'us' }, }); // Streaming availability for a specific movie in a country const movieStreaming = await api.movies.watchnow({ params: { id: 'inception-2010', country: 'us' }, query: {}, }); // Streaming availability for a specific show in a country const showStreaming = await api.shows.watchnow({ params: { id: 'breaking-bad', country: 'us' }, query: {}, }); ``` ``` -------------------------------- ### OAuth Device Flow (`api.oauth.device.code` / `api.oauth.device.token`) Source: https://context7.com/trakt/trakt-api/llms.txt Implements the Trakt device authorization flow. This involves first requesting a device code using the client ID, and then polling for an access token using the obtained device code and client secret after the user has authorized the application. ```APIDOC ## OAuth Device Flow — `api.oauth.device.code` / `api.oauth.device.token` Implements the Trakt device authorization flow. First, request a device code with the client ID, then poll for a token using the device code and client secret once the user has authorized. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Step 1: Request device code const codeResponse = await api.oauth.device.code({ body: { client_id: 'YOUR_CLIENT_ID' }, }); // codeResponse.body: { device_code, user_code, verification_url, expires_in, interval } // Direct the user to: `${verification_url}/${user_code}` // Step 2: Poll for token (interval seconds between attempts) const tokenResponse = await api.oauth.device.token({ body: { code: codeResponse.body.device_code, client_id: 'YOUR_CLIENT_ID', client_secret: 'YOUR_CLIENT_SECRET', }, }); if (tokenResponse.status === 200) { const { access_token, refresh_token, expires_in } = tokenResponse.body; // Store access_token for authenticated requests } ``` ``` -------------------------------- ### Trakt OAuth Device Flow - Step 1: Request Device Code Source: https://context7.com/trakt/trakt-api/llms.txt Initiates the Trakt device authorization flow by requesting a device code. The user should be directed to the provided verification URL with their user code. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Step 1: Request device code const codeResponse = await api.oauth.device.code({ body: { client_id: 'YOUR_CLIENT_ID' }, }); // codeResponse.body: { device_code, user_code, verification_url, expires_in, interval } // Direct the user to: `${verification_url}/${user_code}` ``` -------------------------------- ### Sync User Data with Trakt API Source: https://context7.com/trakt/trakt-api/llms.txt Use this to add or remove movies/episodes from watch history, manage watchlists, add ratings, retrieve 'Up Next' episodes, access movie collections, and manage favorites. Ensure you have initialized the API with your client ID. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Add movies/episodes to watch history const historyAdd = await api.sync.history.add({ body: { movies: [ { ids: { trakt: 56360 }, watched_at: '2024-06-01T20:00:00.000Z' }, ], episodes: [], }, }); // historyAdd.body: { added: { movies, episodes }, not_found: { movies, episodes } } ``` ```typescript // Remove from history await api.sync.history.remove({ body: { movies: [{ ids: { trakt: 56360 } }] }, }); ``` ```typescript // Add to watchlist await api.sync.watchlist.add({ body: { movies: [{ ids: { trakt: 56360 } }], shows: [] }, }); ``` ```typescript // Add ratings (1–10 scale) await api.sync.ratings.add({ body: { movies: [{ ids: { trakt: 56360 }, rating: 9 }], shows: [], episodes: [], }, }); ``` ```typescript // Get "Up Next" — shows with unwatched episodes const upNext = await api.sync.progress.upNext.standard({ query: { extended: 'full', page: 1, limit: 10 }, }); // upNext.body: Array<{ show, progress, next_episode, ... }> ``` ```typescript // Collection movies const collection = await api.sync.collection.movies({ query: {} }); ``` ```typescript // Favorites await api.sync.favorites.add({ body: { movies: [{ ids: { trakt: 56360 } }] }, }); ``` -------------------------------- ### Lists Source: https://context7.com/trakt/trakt-api/llms.txt Browse public community lists or fetch items from a specific list. This includes trending and popular lists, as well as the ability to like and retrieve likes for lists. ```APIDOC ## Lists — Trending, Popular, Summary, Items, Like Browse public community lists or fetch items from a specific list. ### Trending lists ```typescript const trending = await api.lists.trending({ query: { extended: 'full', page: 1, limit: 10 }, }); // trending.body: Array<{ like_count, comment_count, list: ListResponse }> ``` ### Popular lists ```typescript const popular = await api.lists.popular({ query: { page: 1, limit: 10 } }); ``` ### List summary by ID ```typescript const listSummary = await api.lists.summary({ params: { id: '1234567' }, query: {}, }); ``` ### List items (movies and shows) ```typescript const items = await api.lists.items.media({ params: { id: '1234567' }, query: { extended: 'full', page: 1, limit: 20 }, }); ``` ### Like a list (authenticated) ```typescript await api.lists.like({ params: { id: '1234567' }, body: undefined }); ``` ### Get list likes ```typescript const likes = await api.lists.likes({ params: { id: '1234567' }, query: { page: 1, limit: 10 }, }); ``` ``` -------------------------------- ### Browse and Interact with Community Lists Source: https://context7.com/trakt/trakt-api/llms.txt Fetch trending and popular community lists, retrieve details and items from a specific list by its ID, and manage likes on lists. Requires list IDs for specific operations. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Trending lists const trending = await api.lists.trending({ query: { extended: 'full', page: 1, limit: 10 }, }); // trending.body: Array<{ like_count, comment_count, list: ListResponse }> // Popular lists const popular = await api.lists.popular({ query: { page: 1, limit: 10 } }); // List summary by ID const listSummary = await api.lists.summary({ params: { id: '1234567' }, query: {}, }); // List items (movies and shows) const items = await api.lists.items.media({ params: { id: '1234567' }, query: { extended: 'full', page: 1, limit: 20 }, }); // Like a list (authenticated) await api.lists.like({ params: { id: '1234567' }, body: undefined }); // Get list likes const likes = await api.lists.likes({ params: { id: '1234567' }, query: { page: 1, limit: 10 }, }); ``` -------------------------------- ### Fetch Movie Entity-Level Details Source: https://context7.com/trakt/trakt-api/llms.txt Retrieve detailed information for a specific movie, including ratings, statistics, cast and crew, related movies, streaming availability, and videos. Requires a movie ID. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Ratings distribution const ratings = await api.movies.ratings({ params: { id: 'inception-2010' }, query: {}, }); // ratings.body: { rating, votes, distribution: { "1": n, ..., "10": n } } ``` ```typescript // Watch stats const stats = await api.movies.stats({ params: { id: 'inception-2010' } }); // stats.body: { watchers, plays, collectors, comments, lists, votes, favorited } ``` ```typescript // Cast and crew const people = await api.movies.people({ params: { id: 'inception-2010' }, query: { extended: 'images' }, }); // people.body: { cast: [...], crew: { directing: [...], writing: [...], ... } } ``` ```typescript // Related movies const related = await api.movies.related({ params: { id: 'inception-2010' }, query: { extended: 'full', page: 1, limit: 5 }, }); ``` ```typescript // Streaming availability for a country const watchNow = await api.movies.watchnow({ params: { id: 'inception-2010', country: 'us' }, query: {}, }); ``` ```typescript // Trailers and videos const videos = await api.movies.videos({ params: { id: 'inception-2010' } }); ``` -------------------------------- ### Sync Operations Source: https://context7.com/trakt/trakt-api/llms.txt Operations for synchronizing user data such as watch history, watchlist, ratings, collection, and favorites with Trakt. ```APIDOC ## Sync Operations ### Add movies/episodes to watch history This method adds movies or episodes to the user's watch history. #### Method POST #### Endpoint `/sync/history #### Request Body - **movies** (array) - Optional - List of movies to add to history. - **ids** (object) - Required - Trakt IDs for the movie. - **trakt** (integer) - Required - Trakt movie ID. - **watched_at** (string) - Optional - Timestamp when the movie was watched. - **episodes** (array) - Optional - List of episodes to add to history. ### Response #### Success Response (200) - **body** (object) - Contains information about added and not found items. - **added** (object) - Items that were successfully added. - **movies** (integer) - Number of movies added. - **episodes** (integer) - Number of episodes added. - **not_found** (object) - Items that were not found. - **movies** (array) - List of movies not found. - **episodes** (array) - List of episodes not found. ### Remove from history This method removes movies or episodes from the user's watch history. #### Method DELETE #### Endpoint `/sync/history #### Request Body - **movies** (array) - Optional - List of movies to remove from history. - **ids** (object) - Required - Trakt IDs for the movie. - **trakt** (integer) - Required - Trakt movie ID. - **episodes** (array) - Optional - List of episodes to remove from history. ### Add to watchlist This method adds movies or shows to the user's watchlist. #### Method POST #### Endpoint `/sync/watchlist #### Request Body - **movies** (array) - Optional - List of movies to add to watchlist. - **ids** (object) - Required - Trakt IDs for the movie. - **trakt** (integer) - Required - Trakt movie ID. - **shows** (array) - Optional - List of shows to add to watchlist. ### Add ratings (1–10 scale) This method adds ratings to movies, shows, or episodes. #### Method POST #### Endpoint `/sync/ratings #### Request Body - **movies** (array) - Optional - List of movies to rate. - **ids** (object) - Required - Trakt IDs for the movie. - **trakt** (integer) - Required - Trakt movie ID. - **rating** (integer) - Required - Rating from 1 to 10. - **shows** (array) - Optional - List of shows to rate. - **episodes** (array) - Optional - List of episodes to rate. ### Get "Up Next" — shows with unwatched episodes This method retrieves a list of shows with unwatched episodes, ordered by when they are expected to air next. #### Method GET #### Endpoint `/sync/progress/up_next/standard #### Query Parameters - **extended** (string) - Optional - Extended options for the response. - **page** (integer) - Optional - Page number for pagination. - **limit** (integer) - Optional - Maximum number of items per page. #### Response #### Success Response (200) - **body** (array) - List of shows with upcoming episodes. - **show** (object) - Show details. - **progress** (object) - Progress information. - **next_episode** (object) - Details of the next episode. ### Collection movies This method retrieves the user's movie collection. #### Method GET #### Endpoint `/sync/collection/movies #### Query Parameters - **extended** (string) - Optional - Extended options for the response. ### Favorites This method adds movies to the user's favorites. #### Method POST #### Endpoint `/sync/favorites #### Request Body - **movies** (array) - Optional - List of movies to add to favorites. - **ids** (object) - Required - Trakt IDs for the movie. - **trakt** (integer) - Required - Trakt movie ID. ``` -------------------------------- ### Trakt OAuth Device Flow - Step 2: Poll for Token Source: https://context7.com/trakt/trakt-api/llms.txt Polls for an OAuth token using the device code obtained in the previous step. This should be done periodically at the specified interval until the user authorizes the application. ```typescript // Step 2: Poll for token (interval seconds between attempts) const tokenResponse = await api.oauth.device.token({ body: { code: codeResponse.body.device_code, client_id: 'YOUR_CLIENT_ID', client_secret: 'YOUR_CLIENT_SECRET', }, }); if (tokenResponse.status === 200) { const { access_token, refresh_token, expires_in } = tokenResponse.body; // Store access_token for authenticated requests } ``` -------------------------------- ### Movies - Entity-level endpoints (ratings, stats, people, related, videos, watch now) Source: https://context7.com/trakt/trakt-api/llms.txt Fetch detailed information for a specific movie by its Trakt slug or ID. ```APIDOC ## Movies — Entity-level endpoints (ratings, stats, people, related, videos, watch now) Fetch detailed information for a specific movie by its Trakt slug or ID. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Ratings distribution const ratings = await api.movies.ratings({ params: { id: 'inception-2010' }, query: {}, }); // ratings.body: { rating, votes, distribution: { "1": n, ..., "10": n } } // Watch stats const stats = await api.movies.stats({ params: { id: 'inception-2010' } }); // stats.body: { watchers, plays, collectors, comments, lists, votes, favorited } // Cast and crew const people = await api.movies.people({ params: { id: 'inception-2010' }, query: { extended: 'images' }, }); // people.body: { cast: [...], crew: { directing: [...], writing: [...], ... } } // Related movies const related = await api.movies.related({ params: { id: 'inception-2010' }, query: { extended: 'full', page: 1, limit: 5 }, }); // Streaming availability for a country const watchNow = await api.movies.watchnow({ params: { id: 'inception-2010', country: 'us' }, query: {}, }); // Trailers and videos const videos = await api.movies.videos({ params: { id: 'inception-2010' } }); ``` ``` -------------------------------- ### Certifications and Enums Source: https://context7.com/trakt/trakt-api/llms.txt Retrieve content rating certifications for movies and shows, and access typed enums for genres and other metadata. This allows for filtering and displaying content based on official ratings. ```APIDOC ## Certifications and Enums Retrieve content rating certifications (e.g., PG-13, TV-MA) for movies and shows, and access typed enums for genres and other metadata. ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // Movie certifications const movieCerts = await api.certifications.movies({}); // movieCerts.body: { us: [{ certification, description, country }] } // Show certifications const showCerts = await api.certifications.shows({}); ``` ``` -------------------------------- ### Calendar Operations Source: https://context7.com/trakt/trakt-api/llms.txt Retrieve scheduled air dates for episodes, show premieres, finales, movie releases, and DVD releases. Target can be 'all' (global) or 'my' (user-specific, requires auth). ```APIDOC ## Calendars — Shows, New Shows, Premieres, Finales, Movies, DVD Releases Retrieve scheduled air dates for episodes, show premieres, finales, movie releases, and DVD releases. Target can be `all` (global) or `my` (user-specific, requires auth). ```typescript import { traktApi, Environment } from '@trakt/api'; const api = traktApi({ environment: Environment.production, apiKey: 'YOUR_CLIENT_ID' }); // All shows airing in the next 7 days starting today const shows = await api.calendars.shows({ params: { target: 'all', start_date: '2024-06-01', days: 7 }, query: { extended: 'full' }, }); // shows.body: Array<{ first_aired, episode: EpisodeResponse, show: ShowResponse }> // New shows premiering const newShows = await api.calendars.newShows({ params: { target: 'all', start_date: '2024-06-01', days: 7 }, query: {}, }); // Season premieres const premieres = await api.calendars.seasonPremieres({ params: { target: 'all', start_date: '2024-06-01', days: 30 }, query: { extended: 'full' }, }); // Season finales const finales = await api.calendars.finales({ params: { target: 'all', start_date: '2024-06-01', days: 30 }, query: {}, }); // Movie releases const movies = await api.calendars.movies({ params: { target: 'all', start_date: '2024-06-01', days: 14 }, query: { extended: 'full' }, }); // DVD releases const dvd = await api.calendars.dvdReleases({ params: { target: 'all', start_date: '2024-06-01', days: 14 }, query: {}, }); ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.