Skip to main content

A Python wrapper for TMDb API

Project description

logo yelp

ezapi-tmdb

pytest Code style: black PyPI - License PyPI - Python Version PyPI Downloads

All Contributors

A Python wrapper for TMDb API, supporting version 3 and 4

Install

From PyPi

pip install ezapi-tmdb

From GitHub

pip install git+https://github.com/zehengl/ezapi-tmdb.git

Usage

  1. All endpoints are mapped to functions in a TMDb object
  2. All query string params are used as keyword arguments

Version 3 Example

See Version 3 documents for detailed API usage.

from tmdb import TMDb3

api_key = "..."

tmdb = TMDb3(api_key)

# query string params are used as keyword arguments
print(tmdb.get_popular_movies(region="US"))
print(tmdb.get_tvs_on_the_air(page=10))

# create session_id with username/password login
username = "..."
password = "..."
request_token = tmdb.create_request_token().get("request_token")
tmdb.create_session_with_login(username, password, request_token)
session_id = tmdb.create_session(request_token).get("session_id")

# some endpoints require session_id
print(tmdb.get_account_details(session_id=session_id))

# store global options, language / region for example
tmdb.set_options(language="de", region="de")
tmdb.get_trending("all", "week")

# reset global options
tmdb.reset_options()

# configure image languages globally
tmdb.set_options(include_image_language=["en", "null"])
tmdb.get_movie_images(597)

# url param per request would overwrite global options
tmdb.get_movie_images(597, include_image_language=["de", "fr"])

Version 4 Example

See Version 4 documents for detailed API usage.

from tmdb import TMDb4

# API Read Access Token from the settings page
access_token = "..."

tmdb = TMDb4(access_token)

# create a user access token
request_token = tmdb.create_request_token().get("request_token")
print(f"https://www.themoviedb.org/auth/access?request_token={request_token}")

# click on the link above, sign in, then approve access
resp = tmdb.create_access_token(request_token)

# extract the user access token and account id for v4 api
user_access_token = resp.get("access_token")
account_id = resp.get("account_id")

tmdb.update_access_token(user_access_token)

tmdb.get_list(14105)
tmdb.get_account_favorite_movies(account_id)

Test

git clone git@github.com:zehengl/ezapi-tmdb.git
export api_key="..."
export username="..."
export password="..."
export access_token="..."
cd ezapi-tmdb
python setup.py test

Use $Env:api_key="..." , $Env:username="...", $Env:password="...", and $Env:access_token="..." to set the api key, username, password, and access token environment variables on Windows.

Credits

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Cologler

💻

Rafael Pierre

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

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

ezapi_tmdb-0.7.1.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

ezapi_tmdb-0.7.1-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file ezapi_tmdb-0.7.1.tar.gz.

File metadata

  • Download URL: ezapi_tmdb-0.7.1.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.4

File hashes

Hashes for ezapi_tmdb-0.7.1.tar.gz
Algorithm Hash digest
SHA256 1eecc05cf57e0703ec919a24cafe855e41584e1d4eb7d95cd600cb49b6d34630
MD5 8292ba4dd06d316a0a655b0e94841df3
BLAKE2b-256 86770c98d3148a53801f84339ce0d889d788b69a7ff3856b968a50dac4f59351

See more details on using hashes here.

File details

Details for the file ezapi_tmdb-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: ezapi_tmdb-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 31.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.4

File hashes

Hashes for ezapi_tmdb-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a534908c68b3291f79f8bbd25f47bfa958231ea7e7ec59790b263f2fb005fe7f
MD5 8f88b1b2b812ab9a235075fc9a75c7b9
BLAKE2b-256 5b538e7013493310f913385ad8f9dbabc9cc95ff3a88204a1dcc954075b6133a

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