Skip to main content

A lightweight Python library for The V3 and V4 TMDb APIs.

Project description

Welcome to TMDbAPIs Documentation!

GitHub release (latest by date) Build Testing Build Coverage GitHub commits since latest release (by date) for a branch PyPI Downloads

Wiki Discord Reddit GitHub Sponsors Sponsor or Donate

Overview

Unofficial Python bindings for the TMDb API. The goal is to make interaction with the API as easy as possible while emulating the endpoints as much as possible

Installation & Documentation

pip install tmdbapis

Documentation can be found at Read the Docs.

Using the Object API

Getting a TMDbAPIs Instance

To create a TMDbAPIs Object you need your V3 API Key, which can be found following this guide.

from tmdbapis import TMDbAPIs

apikey = "0010843563404748808d3fc9c562c05e"

tmdb = TMDbAPIs(apikey)

Authenticating V3 API Token

To authenticate your TMDb V3 API Token you can either authenticate your TMDb V4 Token or use the authenticate() method.

from tmdbapis import TMDbAPIs

apikey = "0010843563404748808d3fc9c562c05e"

tmdb = TMDbAPIs(apikey)
tmdb.authenticate(username, password)

Saving a V3 API Authenticated Session

To save your authenticated session use the session_id Attribute.

from tmdbapis import TMDbAPIs

apikey = "0010843563404748808d3fc9c562c05e"

tmdb = TMDbAPIs(apikey)
tmdb.authenticate(username, password)
with open("session_id.txt", "w") as text_file:
    print(tmdb.session_id, file=text_file)

To load the authenticated session use the session_id Parameter of the TMDbAPIs constructor.

from tmdbapis import TMDbAPIs

apikey = "0010843563404748808d3fc9c562c05e"

session_id = None
with open("session_id.txt") as text_file:
    session_id = text_file.readline()

tmdb = TMDbAPIs(apikey, session_id=session_id)

Adding TMDb V4 API Read Access Token

To gain read access to TMDb V4’s API just provide you’re TMDb V4 Access Token either using the v4_access_token Parameter of the TMDbAPIs constructor or by using the v4_access_token() method.

To gain read access to TMDb V4’s API need your TMDb V4 Access Token, which can be found following this guide.

from tmdbapis import TMDbAPIs

apikey = "0010843563404748808d3fc9c562c05e"
v4_access_token = "sohsnrfiemrsdvsavvt4h426GWEGW434gSgSdnjhcyuwbBYHBOSIYCBWgyNTYxNTY4OGQ5NTJjZCIsInN1YiI6IjVkMzM5ZmI0MmY4ZDAfdfdgegeGGregerfge34345BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIvfdvsdfveregrgqgfsfghjhOR0shmZZ_ZekFiuyl7o56921C0"

tmdb = TMDbAPIs(apikey, v4_access_token=v4_access_token)

Authenticating TMDb V4 API Token

To authenticate your TMDB V4 Read Access Token it is a multi step process.

  1. Add your TMDb V4 API Read Access Token.

  2. Authenticate the URL returned from v4_authenticate().

  3. Once the URL has been authenticated you must approve it by running v4_approved().

from tmdbapis import TMDbAPIs

apikey = "0010843563404748808d3fc9c562c05e"
v4_access_token = "sohsnrfiemrsdvsavvt4h426GWEGW434gSgSdnjhcyuwbBYHBOSIYCBWgyNTYxNTY4OGQ5NTJjZCIsInN1YiI6IjVkMzM5ZmI0MmY4ZDAfdfdgegeGGregerfge34345BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIvfdvsdfveregrgqgfsfghjhOR0shmZZ_ZekFiuyl7o56921C0"

tmdb = TMDbAPIs(apikey, v4_access_token=v4_access_token)

print(tmdb.v4_authenticate())
input("Navigate to the URL and then hit enter when Authenticated")
tmdb.v4_approved()

Saving a V4 API Authenticated Token

To save your authenticated token use the v4_access_token Attribute.

from tmdbapis import TMDbAPIs

apikey = "0010843563404748808d3fc9c562c05e"
v4_access_token = "sohsnrfiemrsdvsavvt4h426GWEGW434gSgSdnjhcyuwbBYHBOSIYCBWgyNTYxNTY4OGQ5NTJjZCIsInN1YiI6IjVkMzM5ZmI0MmY4ZDAfdfdgegeGGregerfge34345BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIvfdvsdfveregrgqgfsfghjhOR0shmZZ_ZekFiuyl7o56921C0"

tmdb = TMDbAPIs(apikey, v4_access_token=v4_access_token)

print(tmdb.v4_authenticate())
input("Navigate to the URL and then hit enter when Authenticated")
tmdb.v4_approved()
with open("access_token.txt", "w") as text_file:
    print(tmdb.v4_access_token, file=text_file)

To load the authenticated token use the v4_access_token Parameter of the TMDbAPIs constructor or the v4_access_token() method.

from tmdbapis import TMDbAPIs

apikey = "0010843563404748808d3fc9c562c05e"

v4_access_token = None
with open("access_token.txt") as text_file:
    v4_access_token = text_file.readline()

tmdb = TMDbAPIs(apikey, v4_access_token=v4_access_token)

Usage & Contributions

  • Source is available on the Github Project Page.

  • Contributors to TMDbAPIs own their own contributions and may distribute that code under the MIT license.

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

tmdbapis-1.2.18.tar.gz (60.2 kB view details)

Uploaded Source

Built Distribution

tmdbapis-1.2.18-py3-none-any.whl (58.0 kB view details)

Uploaded Python 3

File details

Details for the file tmdbapis-1.2.18.tar.gz.

File metadata

  • Download URL: tmdbapis-1.2.18.tar.gz
  • Upload date:
  • Size: 60.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for tmdbapis-1.2.18.tar.gz
Algorithm Hash digest
SHA256 e1a2b2bf0124d6d7736fbf02d937aa520d8ef9819f69c46b2243ecebf3693364
MD5 6da77e694289b331dd56ceb60ff73b7e
BLAKE2b-256 d6a9d0b7d45adbce96e0062c240d21fc3d509ca88557e8efe446b3585747fe1b

See more details on using hashes here.

File details

Details for the file tmdbapis-1.2.18-py3-none-any.whl.

File metadata

  • Download URL: tmdbapis-1.2.18-py3-none-any.whl
  • Upload date:
  • Size: 58.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for tmdbapis-1.2.18-py3-none-any.whl
Algorithm Hash digest
SHA256 2339744e6db7b9e2cd5a26b2cf1a86c215347374a2b12e9f016d55a5f3d6dfe0
MD5 bca83bd3bed3fe49746ca6df999449c0
BLAKE2b-256 213ed3f99fdbc3b239d1c841a4b13d28010f07fbfd0af8da07d91696c7ec7da9

See more details on using hashes here.

Supported by

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