Many TMDb API endpoints require specific IDs, such as movie IDs, TV show IDs, person IDs, and more. This guide will help you retrieve these IDs efficiently.

Movie and TV Show IDs

To find a movie or TV show ID, use the Search API:

GET /search/movie?query=your_movie_name&api_key=YOUR_API_KEY
GET /search/tv?query=your_tv_show_name&api_key=YOUR_API_KEY

Example Response:

{
  "results": [
    {
      "id": 550,
      "title": "Fight Club"
    }
  ]
}

The id field (e.g., 550) is the Movie ID you need.

Person (Actor, Director, etc.) IDs

To get an actor’s or director’s ID, use the Person Search API:

GET /search/person?query=your_person_name&api_key=YOUR_API_KEY

Example Response:

{
  "results": [
    {
      "id": 287,
      "name": "Brad Pitt"
    }
  ]
}

The id field (e.g., 287) is the Person ID.

Collection IDs

Some movies belong to collections, and you can retrieve collection IDs via the Movie Details API:

GET /movie/{movie_id}?api_key=YOUR_API_KEY

Example Response:

{
  "id": 550,
  "title": "Fight Club",
  "belongs_to_collection": {
    "id": 2344,
    "name": "Fight Club Collection"
  }
}

The id inside belongs_to_collection (e.g., 2344) is the Collection ID.

Genre IDs

To fetch available genres and their IDs, use the Genres API:

GET /genre/movie/list?api_key=YOUR_API_KEY
GET /genre/tv/list?api_key=YOUR_API_KEY

Example Response:

{
  "genres": [
    {
      "id": 28,
      "name": "Action"
    }
  ]
}

The id (e.g., 28) is the Genre ID.

TV Season and Episode IDs

To get season and episode details, use the TV Show Details API:

GET /tv/{tv_id}/season/{season_number}?api_key=YOUR_API_KEY
GET /tv/{tv_id}/season/{season_number}/episode/{episode_number}?api_key=YOUR_API_KEY

Example Response:

{
  "id": 1101,
  "episodes": [
    {
      "id": 23456,
      "name": "Pilot"
    }
  ]
}

The id (e.g., 23456) is the Episode ID.

Alternative Method: TMDb Website

You can also manually find IDs by searching for a movie, TV show, or person on TMDb and checking the URL:

  • Movie: https://www.themoviedb.org/movie/550 → ID = 550
  • TV Show: https://www.themoviedb.org/tv/1101 → ID = 1101
  • Person: https://www.themoviedb.org/person/287 → ID = 287

Conclusion

By using these methods, you can quickly obtain the required IDs for API requests. Be sure to store and manage these IDs efficiently to avoid unnecessary API calls. Happy coding! 🚀