A Python wrapper for TMDb API, supporting version 3 and 4
From PyPi
pip install ezapi-tmdb
From GitHub
pip install git+https://github.com/zehengl/ezapi-tmdb.git
- All endpoints are mapped to functions in a
TMDb
object - All query string params are used as keyword arguments
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"])
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)
git clone [email protected]:zehengl/ezapi-tmdb.git
cd ezapi-tmdb
export tmdb_api_key="..."
export tmdb_username="..."
export tmdb_password="..."
export tmdb_access_token="..."
python -m venv .venv
source .venv/bin/activate
pip install -e .
pip install -r requirements-test.txt
pytest
Use $Env:tmdb_api_key="..."
, $Env:tmdb_username="..."
, $Env:tmdb_password="..."
, and $Env:tmdb_access_token="..."
to set the api key, username, password, and access token environment variables on Windows.
- Icon from www.themoviedb.org
Thanks goes to these wonderful people (emoji key):
Cologler 💻 |
Rafael Pierre 💻 |
joselimajr 🤔 |
This project follows the all-contributors specification. Contributions of any kind welcome!