@dvcol/tmdb-http-client
v1.3.10
Published
Simple fetch based http client for TMDB API with full typescript support (request and response).
Downloads
244
Maintainers
Readme
Simple fetch based http client for TMDB API with full typescript support (request and response).
Prerequisites
- pnpm >=9.0.0
- node >=20.0.0
Install
pnpm install
Usage
pnpm add @dvcol/tmdb-http-client
Modular endpoint bundling
Tmdb-http-client is designed to be modular and flexible. Although it uses static classes, endpoints are instantiated at runtime and can be easily omitted, extended or overridden. If your bundler does not support tree-shaking, you can omit unused endpoints by only importing the ones you need.
By default we provide a full api object with all supported endpoints, as well as a minimal api object with only the essential authentication endpoints. You can also import any endpoint by common scope.
import { TmdbClient } from '@dvcol/tmdb-http-client';
import { minimalTmdbApi } from '@dvcol/tmdb-http-client/api/minimal';
import { movies } from '@dvcol/tmdb-http-client/api/v3/movies';
import { shows } from '@dvcol/tmdb-http-client/api/v3/shows';
import { Config } from '@dvcol/tmdb-http-client/config';
import type { TmdbClientSettings } from '@dvcol/tmdb-http-client/models';
export const api = {
...minimalTmdbApi,
v3: {
movies,
shows,
},
};
export const settings: TmdbClientSettings = {
endpoint: Config.endpoint,
apiKey: '<Your api ID>',
readToken:'<Your read token>',
requestTokenTTL: Config.requestTokenTTL,
useragent: '<Your user Agent>',
corsProxy: '<Optional cors Proxy>',
corsPrefix: '<Optional cors Proxy prefix>',
};
const authenticaiton = {}
const client = new TmdbClient(settings, authenticaiton, api);
Features
- Built-in cache support (per client, endpoint, or query)
- Extensible cache store (in-memory, local storage, etc.)
- Event observer (request, query, auth)
- Built-in cancellation support
- Built-in cors proxy support
Documentation
See Tmdb API documentation for more information.
Author
- Github: @dvcol
📝 License
This project is MIT licensed.