Skip to main content

PyPI Version PyPI License Code style: black

TMDb Python

tmdb-python, an async Python library for TMDb API.


Overview

The tmdb-python is an 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.9)

  • pip (Python package manager)

Install

The easiest way to install tmdb-python is via pip.

pip install tmdb-python

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

The first step is to initialize a TMDB object and set your API Key.

import asyncio
from tmdb import route, schema

async def main():
    base = route.Base()
    base.key = "YOUR_API_KEY"

    movies = await route.Movie().search("fight club")
    for movie in movies:
        print(movie["name"])

    movies = movies.to(schema.Movies)  # convert `dict` to `schema.Movies`
    for movie in movies:
        print(movie.name)

asyncio.run(main())

Alternatively, you can export your API key as an environment variable.

$ export TMDB_KEY="YOUR_API_KEY"

And then you will no longer need to set your API key.

import asyncio
from tmdb import route

async def main():
    # implicit env var: TMDB_KEY="YOUR_API_KEY"
    movies = await route.Movie().popular()
    for movie in movies:
        print(movie["name"])

asyncio.run(main())

For more information, see the docs.

Configuration

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

from tmdb import route

async def main():
    base = route.Base()
    base.key = "YOUR_API_KEY"
    base.language = "pt-BR"
    base.region = "BR"

    providers = await route.Movie().providers_list()

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

$ export TMDB_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.

async def main():
    # implicit env vars: TMDB_KEY="YOUR_API_KEY" TMDB_LANGUAGE="pt-BR" TMDB_REGION="BR"
    providers = await route.Movie().providers_list()

You also can set language and region on object instantiation.

async def main():
    # implicit env vars: TMDB_KEY="YOUR_API_KEY" TMDB_LANGUAGE="pt-BR" TMDB_REGION="BR"
    movies = await route.Movie().discover()  # discover with the BR regional release date
    movies = await route.Movie(language="en-US", region="US").discover()  # discover with the US regional release date

Metadata

Release files for tmdb-python 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tmdb-python 0.0.9
File Size Uploaded Provenance Actions
tmdb-python-0.0.9.tar.gz 15.3 kB Without provenance Details for tmdb-python-0.0.9.tar.gz

Release files / tmdb-python-0.0.9.tar.gz

Download URL tmdb-python-0.0.9.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dffa5999a560535873a7a35944a55138e2196871cded707314030c9b6230b5e9
BLAKE2b-256 checksum
How to use checksums
3fc98310647d03208cd81178657b897534b964a1c8309ec8ec98a6eca4a1c989
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

Security for tmdb-python 0.0.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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