Skip to content

Latest commit

 

History

History
55 lines (37 loc) · 1.24 KB

File metadata and controls

55 lines (37 loc) · 1.24 KB

Authentication

TMDB supports two authentication methods. Pass either directly to the TMDB constructor.

Read Access Token (recommended)

Obtain a read access token from TMDB API Settings under "API Read Access Token".

import { TMDB } from '@api-wrappers/tmdb-wrapper';

const tmdb = new TMDB('YOUR_READ_ACCESS_TOKEN');

The token is sent as a Bearer token in the Authorization header on every request.

API Key

const tmdb = new TMDB({ apiKey: 'YOUR_API_KEY' });

The API key is appended as the api_key query parameter.

Combined Config

You can provide both. The access token takes precedence for the Authorization header; the API key is added as a query parameter only when present.

const tmdb = new TMDB({
  accessToken: 'YOUR_READ_ACCESS_TOKEN',
  apiKey: 'YOUR_API_KEY',
});

Using Environment Variables

Never commit credentials to source control. Use environment variables:

const tmdb = new TMDB(process.env.TMDB_ACCESS_TOKEN!);

Type Reference

type TMDBConfig =
  {
    accessToken?: string;
    apiKey?: string;
    client?: TMDBClientConfig;
  };

type TokenType = string | TMDBConfig;