Skip to main content

Code Coverage PyPI Version Code style: black PyPI License

themoviedb

A modern and easy to use API wrapper for The Movie Database (TMDb) API v3 written in Python. Supports sync and async requests!

themoviedb

Overview

The themoviedb is a synchronous and asynchronous wrapper, written in Python, for The Movie Database (TMDb) API v3.

The Movie Database (TMDb) is a community built movie and TV database.

The TMDb API service is for those of you interested in using our movie, TV show or actor images and/or data in your application.

A TMDb user account is required to request an API key.

Getting started

Requirements

  • python (Python >=3.8)

  • pip (Python package manager)

Install

pip install themoviedb

API Key

You will need an API key to The Movie Database to access the API. To obtain a key, follow these steps:

  1. Register for and verify an account.

  2. Log into your account.

  3. Select the API section on left side of your account page.

  4. Click on the link to generate a new API key and follow the instructions.

Usage

Sync mode

from themoviedb import TMDb

Async mode

from themoviedb import aioTMDb

Configuration

Initialize a TMDb object and set your API Key, language and region.

tmdb = TMDb(api_key="YOUR_API_KEY", language="pt-BR", region="BR")
# or: tmdb = aioTMDb(api_key="YOUR_API_KEY", language="pt-BR", region="BR")

Alternatively, set after initialize.

tmdb = TMDb()
# or: tmdb = aioTMDb()
tmdb.api_key = "YOUR_API_KEY"
tmdb.language = "pt-BR"     # default: en-US
tmdb.region = "BR"          # default: US

Alternatively too, you can export your API key, language and region logger as an environment variable.

$ export TMDB_API_KEY="YOUR_API_KEY"
$ export TMDB_LANGUAGE="pt-BR"  # ISO 639-1
$ export TMDB_REGION="BR"       # ISO-3166-1

And then you will no longer need to set your API key, language and region.

tmdb = TMDb()   # from env: TMDB_API_KEY="YOUR_API_KEY", TMDB_LANGUAGE="pt-BR", TMDB_REGION="BR"
# or: tmdb = aioTMDb()

Examples

Get the list of top rated movies (sync mode).

from themoviedb import TMDb

tmdb = TMDb()
movies = tmdb.movies().top_rated()
for movie in movies:
    print(movie)

Get the list of popular TV shows (async mode).

import asyncio
from themoviedb import aioTMDb

async def main():
    tmdb = aioTMDb()
    movies = await tmdb.tvs().popular()
    for movie in movies:
        print(movie)

asyncio.run(main())

Discover movies by different types of data.

from themoviedb import TMDb

tmdb = TMDb()
movies = tmdb.discover().movie(
    sort_by="vote_average.desc",
    primary_release_date__gte="1997-08-15",
    vote_count__gte=10000,
    vote_average__gte=6.0,
)
for movie in movies:
    print(movie)

Get the details of movie for a search.

import asyncio
from themoviedb import aioTMDb

async def main():
    tmdb = aioTMDb()
    movies = await tmdb.search().movies("fight club")
    movie_id = movies[0].id  # get first result
    movie = await tmdb.movie(movie_id).details(append_to_response="credits,external_ids,images,videos")
    print(movie.title, movie.year)
    print(movie.tagline)
    print(movie.poster_url)
    print(movie.external_ids.imdb_url)
    for person in movie.credits.cast:
        print(person.name, person.character)

asyncio.run(main())

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

themoviedb-2.0.2.tar.gz (38.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

themoviedb-2.0.2-py3-none-any.whl (67.7 kB view details)

Uploaded Python 3

File details

Details for the file themoviedb-2.0.2.tar.gz.

File metadata

  • Download URL: themoviedb-2.0.2.tar.gz
  • Upload date:
  • Size: 38.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for themoviedb-2.0.2.tar.gz
Algorithm Hash digest
SHA256 86f3344c91508f3d65c8e51d8aca3ef624bb6908b9705ef5782cb9a1325a9488
MD5 4b459bf7e9f5c932870131f682b196d3
BLAKE2b-256 a1163a0ca456647d7e399cc6c0f464179458e58add951a357241f666c33ee1eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for themoviedb-2.0.2.tar.gz:

Publisher: release.yaml on leandcesar/themoviedb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file themoviedb-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: themoviedb-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 67.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for themoviedb-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3f9a0b8e7b190d93bfa6c49f51c7e7cb225ca325da19375afd39b828a08ae7e4
MD5 113a1813424a35614d3b173e4bf720f2
BLAKE2b-256 fb4ae4487acdbeec85b3b57a1d7cc87dce4e1e52c095ffaa21417c0381ec52e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for themoviedb-2.0.2-py3-none-any.whl:

Publisher: release.yaml on leandcesar/themoviedb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

2.0.2 This release

2 files

2.0.1

2 files

2.0.0

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.4.0

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.2.2

2 files

0.2.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page