npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fetchtranscript

v0.1.0

Published

Official TypeScript/JavaScript SDK for the FetchTranscript YouTube API

Downloads

136

Readme

FetchTranscript JavaScript/TypeScript SDK

Official TypeScript/JavaScript SDK for the FetchTranscript API — fetch YouTube transcripts, video metadata, channel info, and more.

Installation

npm install fetchtranscript

Quick Start

import { FetchTranscriptClient } from 'fetchtranscript';

const client = new FetchTranscriptClient({ apiKey: 'yt_your_api_key' });

// Get a transcript
const transcript = await client.transcripts.get('dQw4w9WgXcQ');
for (const segment of transcript.segments) {
  console.log(`[${segment.start.toFixed(1)}s] ${segment.text}`);
}

// Get video metadata
const video = await client.videos.getMetadata('dQw4w9WgXcQ');
console.log(video.title);

API Reference

Transcripts

// Get transcript (JSON format with segments)
const transcript = await client.transcripts.get('VIDEO_ID');

// Get transcript in a specific language
const transcript = await client.transcripts.get('VIDEO_ID', { lang: 'es' });

// Get as plain text
const text = await client.transcripts.getText('VIDEO_ID');

// Get as SRT subtitles
const srt = await client.transcripts.getSrt('VIDEO_ID');

// List available languages
const languages = await client.transcripts.listLanguages('VIDEO_ID');

Videos

// Get video metadata
const metadata = await client.videos.getMetadata('VIDEO_ID');

// Get video chapters
const chapters = await client.videos.getChapters('VIDEO_ID');

// Get video comments
const comments = await client.videos.getComments('VIDEO_ID', { limit: 50 });

Channels

// Get channel info
const channel = await client.channels.getInfo('CHANNEL_ID');

// Get channel videos
const videos = await client.channels.getVideos('CHANNEL_ID', { limit: 20 });

// Get all videos with auto-pagination
const allVideos = await client.channels.getAllVideos('CHANNEL_ID');

Search

// Search videos
const results = await client.search.videos('python tutorial', { limit: 10 });

Error Handling

The SDK throws typed exceptions instead of generic errors:

import {
  FetchTranscriptClient,
  VideoNotFoundError,
  InsufficientCreditsError,
  AuthenticationError,
} from 'fetchtranscript';

const client = new FetchTranscriptClient({ apiKey: 'yt_your_api_key' });

try {
  const transcript = await client.transcripts.get('invalid_id');
} catch (error) {
  if (error instanceof VideoNotFoundError) {
    console.log(`Video not found: ${error.message}`);
  } else if (error instanceof InsufficientCreditsError) {
    console.log('Not enough credits');
  } else if (error instanceof AuthenticationError) {
    console.log('Invalid API key');
  }
}

Exception Hierarchy

| Exception | HTTP Status | Description | |-----------|-------------|-------------| | FetchTranscriptError | — | Base exception | | VideoNotFoundError | 404 | Video not found or transcripts disabled | | ChannelNotFoundError | 404 | Channel not found | | InvalidVideoIdError | 400 | Invalid video/channel ID format | | InsufficientCreditsError | 402 | Not enough credits | | AuthenticationError | 401 | Missing or invalid API key | | ServiceUnavailableError | 503 | Upstream service unavailable |

Response Headers

After each request, you can check:

await client.transcripts.get('dQw4w9WgXcQ');
console.log(client.creditsRemaining);    // Remaining API credits
console.log(client.processingTimeMs);    // Processing time in ms

Requirements

  • Node.js 18+ (uses native fetch)
  • Zero runtime dependencies

License

MIT