Skip to main content

A resilient and comprehensive asynchronous TMDb API library with key rotation.

Project description

TMDbOne

PyPI version License: MIT

TMDbOne is a powerful, asynchronous Python library for interacting with The Movie Database (TMDb) API.

Features

  • Comprehensive: Provides access to all data retrieval endpoints from the TMDb API v3.
  • Resilient: Transparently handles API key rotation, automatic request retries, and rate-limit cooldowns.
  • Asynchronous: Built from the ground up with asyncio and aiohttp for high-performance applications.
  • Modern: A clean, chainable, object-oriented interface that mirrors the TMDb API's structure.

Installation

pip install tmdbone

Quick Start

import asyncio
import os
from tmdbone import TMDbOneClient, TMDbAPIError

async def main():
    # Securely load keys from an environment variable (e.g., "key1,key2")
    api_keys_str = os.getenv("TMDB_API_KEYS")
    if not api_keys_str:
        raise ValueError("TMDB_API_KEYS environment variable is not set.")
    api_keys = [key.strip() for key in api_keys_str.split(',')]

    # Initialize the client with a global language
    client = TMDbOneClient(api_keys=api_keys, language="en-US")

    try:
        # Get details for the movie "Inception" (ID: 27205)
        inception = client.movie(27205)
        
        details = await inception.details()
        print(f"Title: {details['title']}")

        # Get external IDs (like IMDb ID)
        external_ids = await inception.external_ids()
        print(f"IMDb ID: {external_ids['imdb_id']}")

    except TMDbAPIError as e:
        print(f"An API error occurred: {e}")
    finally:
        await client.close()

if __name__ == "__main__":
    asyncio.run(main())

Advanced Usage

Chaining for TV Shows

The interface allows for intuitive chaining to access nested resources.

# Get details for Season 2, Episode 3 of "The Mandalorian"
episode_details = await client.tv(82856).season(2).episode(3).details()
print(episode_details['name'])

Top-Level Endpoints

Access general API endpoints directly from the client.

# Get a list of popular movies
popular_movies = await client.movies_popular(region="US")

# Get API configuration details
api_config = await client.configuration().api_details()

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

tmdbone-1.0.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

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

tmdbone-1.0.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file tmdbone-1.0.0.tar.gz.

File metadata

  • Download URL: tmdbone-1.0.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for tmdbone-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e9c1da7feee26b0a44bc504a25a5cb456cf07cf31a069c6cf506a3d2fd500b4d
MD5 60526d94427050511439d9d40279ffb2
BLAKE2b-256 6636b77c7227d8fada727057f05d42d3dde9d08c71e3f1a03dac02c86d8cb058

See more details on using hashes here.

File details

Details for the file tmdbone-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: tmdbone-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for tmdbone-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df53936cd72119e6a1e7a0b5b1a9f65c1d4f7fd209354034724576aac03c2f3d
MD5 c462238b9e4ae01c39972815f2adb882
BLAKE2b-256 0e904cd4267257d30901a86d1cff8691288f2e4373ea3d5fa1fe379dfc4bebc9

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