Skip to main content

Asynchronous Python library for The Movie Database (TMDb) API v3

Project description

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

Project details


Download files

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

Source Distribution

themoviedb-0.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

themoviedb-0.1.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: themoviedb-0.1.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for themoviedb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b46afb5c23007e554addcce6758abe753ccf9b45256dd2ceca4d12ed76db586d
MD5 da350f654fd31fe89cbac150b61a7562
BLAKE2b-256 9a2f96698511fbb4a4bad4ed9ea93616fbcaa7ff5a7ea304f6361d7d9504bd81

See more details on using hashes here.

File details

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

File metadata

  • Download URL: themoviedb-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for themoviedb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a82ce34754ac6d78c1a8c3feed5d26dd27ddbe7ce78cf469b54c9d2a6bd3882
MD5 d680d4c78892bcea62e1e2ef6c396de0
BLAKE2b-256 045ac9d5f71666889e621c06311530e82b772b2917676622c4edfd88aad2f653

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page