themoviedb
A modern and easy to use API wrapper for The Movie Database (TMDb) API v3 written in Python. Supports sync and async requests!
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:
Register for and verify an account.
Log into your account.
Select the API section on left side of your account page.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file themoviedb-2.0.1.tar.gz.
File metadata
- Download URL: themoviedb-2.0.1.tar.gz
- Upload date:
- Size: 38.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
239be1dd5152306ae04907208ab78a484ca6c26e8c091b950930cd0238137898
|
|
| MD5 |
01b539c6af187ff20423e58477ea6644
|
|
| BLAKE2b-256 |
f05552183e2d30c2754602f3b7a7f81198e237da8ad3a0508a1a676cbc6423a4
|
Provenance
The following attestation bundles were made for themoviedb-2.0.1.tar.gz:
Publisher:
release.yaml on leandcesar/themoviedb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
themoviedb-2.0.1.tar.gz -
Subject digest:
239be1dd5152306ae04907208ab78a484ca6c26e8c091b950930cd0238137898 - Sigstore transparency entry: 2621498415
- Sigstore integration time:
-
Permalink:
leandcesar/themoviedb@6727c7ab3f957809cd7ee512d3e3d223c4de88e6 -
Branch / Tag:
refs/tags/2.0.1 - Owner: https://github.com/leandcesar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@6727c7ab3f957809cd7ee512d3e3d223c4de88e6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file themoviedb-2.0.1-py3-none-any.whl.
File metadata
- Download URL: themoviedb-2.0.1-py3-none-any.whl
- Upload date:
- Size: 67.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1791f962771949bccc36c17acf6012de1dd83259ceb634ca5918627a8728c77
|
|
| MD5 |
0b77f6001bd7dfcde005b1fb828c511e
|
|
| BLAKE2b-256 |
6c87290058db0e1f1199eb2b4a7d9c6eef33f5cb182497d60f41e6e4e1d7ac8b
|
Provenance
The following attestation bundles were made for themoviedb-2.0.1-py3-none-any.whl:
Publisher:
release.yaml on leandcesar/themoviedb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
themoviedb-2.0.1-py3-none-any.whl -
Subject digest:
a1791f962771949bccc36c17acf6012de1dd83259ceb634ca5918627a8728c77 - Sigstore transparency entry: 2621498422
- Sigstore integration time:
-
Permalink:
leandcesar/themoviedb@6727c7ab3f957809cd7ee512d3e3d223c4de88e6 -
Branch / Tag:
refs/tags/2.0.1 - Owner: https://github.com/leandcesar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@6727c7ab3f957809cd7ee512d3e3d223c4de88e6 -
Trigger Event:
release
-
Statement type: