@chirag127/tmdb
v1.0.0
Published
TMDB v3 API client — trending, popular, search, enrichment
Downloads
57
Readme
@chirag127/tmdb
Zero-dependency TMDB v3 API client. Read access token auth (Bearer).
Install
npm i @chirag127/tmdbUsage
import { createClient } from '@chirag127/tmdb';
const tmdb = createClient(process.env.TMDB_READ_ACCESS_TOKEN);
// Trending movies this week
const trending = await tmdb.trending('movie', 'week');
// Popular TV shows
const popular = await tmdb.popular('tv');
// Now playing in cinemas
const nowPlaying = await tmdb.nowPlaying();
// On the air (TV)
const onAir = await tmdb.onTheAir();
// Top rated
const topRated = await tmdb.topRated('movie');
// Movie details with credits appended
const movie = await tmdb.details('movie', 550, 'credits,videos');
// Search
const results = await tmdb.search('Inception', 'movie');
const multi = await tmdb.search('Breaking Bad', 'multi');
// Poster URL
const url = tmdb.posterUrl('/abc123.jpg', 'w500');API
createClient(readAccessToken)
Returns a client object with:
| Method | Returns |
|---|---|
| trending(mediaType, window, opts?) | results[] |
| popular(mediaType, opts?) | results[] |
| nowPlaying(opts?) | results[] |
| onTheAir(opts?) | results[] |
| topRated(mediaType, opts?) | results[] |
| details(mediaType, id, append?) | object |
| search(query, mediaType, opts?) | results[] |
| posterUrl(path, size?) | string |
mediaType:'movie'or'tv'(search also accepts'multi')window:'day'or'week'opts: extra query params (e.g.{ language: 'en-US', page: 2 })append: comma-separated TMDB append_to_response valuesize: TMDB image size (default'w500')- All requests have a 15s timeout.
