TheIntroDB Package Docs

Documentation for the theintrodb NPM package

View on GitHub

TheIntroDB Package Docs

Welcome to the GitHub Pages documentation for the theintrodb NPM package.

This package is a typed TypeScript client for the TheIntroDB API (v4). It provides runtime validation, normalized timestamp handling, optional logging, and a reusable client for reading and submitting segment timestamps.

What This Package Covers

Quick Example

import { createIntroDbClient } from 'theintrodb';

const client = createIntroDbClient({
  logger: console,
});

const movie = await client.getMedia({
  tvdbId: 169,
  durationMs: 7_200_000,
});

const episode = await client.getMedia({
  tvdbId: 71663,
  season: 1,
  episode: 1,
});

if (movie.kind === 'media') {
  console.log(movie.intro);
}

const myPendingAwareResult = await client.getMedia(
  { tvdbId: 169 },
  { apiKey: currentUserApiKey }
);

await client.submitMediaTimestamp(
  {
    tvdbId: 169,
    type: 'movie',
    segment: 'intro',
    videoDurationMs: 7_200_000,
    startSec: 0,
    endSec: 90,
  },
  {
    apiKey: currentUserApiKey,
  }
);

// Dry run: where would this submission land?
const resolved = await client.mapSubmission(
  { tvdbId: 71663, type: 'tv', mapping: 'dvd', season: '1', episode: '1' },
  { apiKey: currentUserApiKey }
);

Important Auth Rule

Do not use a shared application key for submissions. The API key should belong to the current user so submissions and pending visibility stay tied to that user account.