@skiffyard/tmdb
A typed Jennifer client for The Movie Database™.
This deck is part of Skiffyard, small community decks for Jennifer.
use io;
import "@skiffyard/tmdb/" as tmdb;
def c as tmdb.Client init tmdb.clientFromEnv();
def hits as tmdb.MoviePage init tmdb.searchMovies($c, "blade runner", 1);
for (def m in $hits.results) {
io.printf("%s (%s) %.1f\n", $m.title, tmdb.year($m.releaseDate), $m.voteAverage);
}v3 and v4
TMDB™ serves two API generations from one host, https://api.themoviedb.org. v4 (/4/...) has bearer authentication, the user approval flow, accounts and custom lists, but cannot search or describe a film. v3 (/3/...) has the catalogue: films, series, seasons, episodes, people, credits, images, videos, genres, discovery and watch providers.
The v4 API Read Access Token is a bearer credential both generations accept, so one Client with one token reaches /3/movie/550 and /4/list/8175284 alike.
What the deck does on top of the HTTP API:
- Replies are value-semantic structs. A
nullor missing field reads as"",0,falseor[], so a struct is always safe to read. - Films and series share field names:
titleis filled fromtitleorname,releaseDatefromrelease_dateorfirst_air_date, and the discovery filter writesprimary_release_date.gteorfirst_air_date.gteas the catalogue needs. - Arguments are checked before the request: a zero id, a page outside 1..500, an image size that does not exist for that kind, a path carrying
... - Every failure is a
tmdb.TmdbError(kind"tmdb"), carrying TMDB's ownstatus_messagewhen there is one, and the HTTPstatusand TMDB'sstatusCodeas fields. tmdb.call,tmdb.callPost,tmdb.callPutandtmdb.callDeletereach any endpoint without a typed verb.
Coverage
| topic | endpoints |
|---|---|
| Search | movie, tv, person, multi, collection, company, keyword |
| Discovery | /discover/movie, /discover/tv, behind a filter builder |
| Movies | details, credits, images, videos, keywords, recommendations, similar, reviews, release dates, external ids, translations, alternative titles, watch providers, now playing, popular, top rated, upcoming, latest |
| Series | details, credits, aggregate credits, images, videos, keywords, content ratings, episode groups, recommendations, similar, reviews, external ids, translations, alternative titles, watch providers, airing today, on the air, popular, top rated, latest |
| Seasons and episodes | details, credits, aggregate credits, images, videos, external ids |
| People | details, movie / tv / combined credits, images, external ids, popular, latest |
| Catalogue | collections, companies, networks, keywords, reviews, credits, find |
| Browsing | trending, genres, certifications, watch providers, change feeds |
| Configuration | images, countries, languages, primary translations, jobs, time zones |
| v4 auth | request token, approval URL, access token, logout |
| v4 account | lists, favourites, ratings, watchlists, recommendations |
| v4 lists | create, read, update, delete, clear, add and remove items, item status |
Errors lists what can fail and the messages, Recipes has complete programs, and the cheatsheet lists every export.
Attribution
This product uses the TMDB API but is not endorsed or certified by TMDB. Using the API means agreeing to its terms of use, which require you to attribute TMDB in any application built on it. The watch-provider data is JustWatch™'s and carries its own attribution requirement.
Trademarks
JustWatch™ is a trademark of JustWatch GmbH. YouTube™ is a trademark of Google LLC. Vimeo™ is a trademark of Vimeo.com, Inc. IMDb™ is a trademark of IMDb.com, Inc. TMDB™, The Movie Database™ and other product and company names may be trademarks of their respective owners. They are used only to identify the products this deck works with. This deck is an independent project, not affiliated with, sponsored or endorsed by TMDB, JustWatch GmbH or any other service named here.