Skip to content

Instantly share code, notes, and snippets.

@jeszy75
Created October 6, 2019 17:56
Show Gist options
  • Save jeszy75/2659094807014e6565ba2f6089d74146 to your computer and use it in GitHub Desktop.
Save jeszy75/2659094807014e6565ba2f6089d74146 to your computer and use it in GitHub Desktop.
Using the TVDB API with HTTPie

API Documentation

See: https://api.thetvdb.com/swagger

Authentication

Authentication is based on JSON Web Token (JWT). See:

Obtaining a JWT token for authentication:

http https://api.thetvdb.com/login apikey=<api-key> userkey=<unique-id> username=<username> -v

The identifiers to be substituted into the command above can be found here (requires login): https://www.thetvdb.com/member/api.

The message body of the response contains the token, store it in a file named TheTVDB.jwt.

In subsequent requests, the token must be submitted in the Authorization header field as follows:

http https://api.thetvdb.com/search/series "Authorization: Bearer $(<TheTVDB.jwt)" name=="The Big Bang Theory" -v

The token is automatically included in subsequent requests when the --session command line option is specified:

rm -f TheTVDB.json
http --session=./TheTVDB.json https://api.thetvdb.com/search/series "Authorization: Bearer $(<TheTVDB.jwt)" name=="The Big Bang Theory" -v
cat TheTVDB.json
http --session=./TheTVDB.json https://api.thetvdb.com/search/series name=="Game of Thrones" -v

Using the API

http --session=./TheTVDB.json https://api.thetvdb.com/languages
http --session=./TheTVDB.json https://api.thetvdb.com/series/80379
http --session=./TheTVDB.json https://api.thetvdb.com/series/80379/filter keys==id,seriesName,firstAired,overview
http --session=./TheTVDB.json https://api.thetvdb.com/series/80379/filter keys==id,seriesName,firstAired,overview Accept-Language:hu
http --session=./TheTVDB.json https://api.thetvdb.com/series/80379/filter keys==id,seriesName,firstAired,overview Accept-Language:fr
http --session=./TheTVDB.json https://api.thetvdb.com/series/80379/filter keys==id,seriesName,firstAired,overview Accept-Language:zh
http --session=./TheTVDB.json https://api.thetvdb.com/series/80379/actors
http --session=./TheTVDB.json https://api.thetvdb.com/series/80379/episodes/summary
http --session=./TheTVDB.json https://api.thetvdb.com/series/80379/episodes
http --session=./TheTVDB.json https://api.thetvdb.com/series/80379/episodes page==2
http --session=./TheTVDB.json https://api.thetvdb.com/series/80379/episodes page==3
http --session=./TheTVDB.json https://api.thetvdb.com/series/80379/episodes/query/params
http --session=./TheTVDB.json https://api.thetvdb.com/series/80379/episodes/query airedSeason==1
http --session=./TheTVDB.json https://api.thetvdb.com/series/80379/episodes/query airedSeason==1 airedEpisode==1
http --session=./TheTVDB.json https://api.thetvdb.com/series/80379/episodes/query airedEpisode==1
http --session=./TheTVDB.json https://api.thetvdb.com/episodes/332484
http --session=./TheTVDB.json https://api.thetvdb.com/series/80379/images
http --session=./TheTVDB.json https://api.thetvdb.com/series/80379/images/query/params
http --session=./TheTVDB.json https://api.thetvdb.com/series/80379/images/query keyType==poster
date -d 2019-09-28 +%s
http --session=./TheTVDB.json https://api.thetvdb.com/updated/query fromTime==$(date -d 2019-09-28 +%s) -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment