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
pip install tmdbapis
Documentation can be found at Read the Docs.
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)
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)
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)
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)
To authenticate your TMDB V4 Read Access Token it is a multi step process.
- Add your TMDb V4 API Read Access Token.
- Authenticate the URL returned from v4_authenticate().
- 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()
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)
- Source is available on the Github Project Page.
- Contributors to TMDbAPIs own their own contributions and may distribute that code under the MIT license.