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

ytranscript-api

v0.1.3

Published

Reliable YouTube transcript extraction API client — your servers never get IP-banned, no proxy management, Whisper fallback for captionless videos.

Downloads

735

Readme

ytranscript-api

npm version CI license: MIT

Official JavaScript/TypeScript client for the yTranscript API — reliable YouTube transcript extraction without proxy management or player-response scraping.

  • Your servers never touch YouTube — bot detection becomes our problem, not yours. Multi-strategy extraction (edge → direct → residential → Whisper) maximizes success, and failed requests are never charged.
  • Captionless videos work — automatic Whisper speech-to-text fallback, one endpoint for every video.
  • Simple and typed — one method, structured segments, zero runtime dependencies, CJS + ESM + types.

Works in Node.js ≥ 18, Bun, Deno, and edge runtimes (anything with fetch).

Install

npm install ytranscript-api

Quickstart

import { YTranscript } from "ytranscript-api";

const yt = new YTranscript("yk_live_...");   // get a key at ytranscript.com/developers

const t = await yt.transcript("dQw4w9WgXcQ");  // video ID or any YouTube URL
console.log(t.lang);          // "en"
console.log(t.segments[0]);   // { text: "We're no strangers to love", offset: 18800, duration: 3600 }
console.log(t.text);          // full transcript as one string
console.log(t.whisper);       // true if Whisper produced it (captionless video)

console.log(yt.lastQuota);    // { limit: 10000, used: 42, rateLimitRemaining: 59 }

API

new YTranscript(apiKey, options?)

| Option | Type | Default | Description | | --- | --- | --- | --- | | baseUrl | string | https://ytranscript.com/api/v1 | Override the API base URL (rarely needed) | | timeoutMs | number | 120000 | Request timeout — Whisper fallbacks on long videos take time |

yt.transcript(videoIdOrUrl, options?)

Accepts an 11-character video ID or any YouTube URL (youtube.com/watch, youtu.be/…, shorts, embeds).

| Option | Type | Description | | --- | --- | --- | | lang | string | Preferred language code (e.g. "en", "es"). Defaults to the video's source language. |

Returns a Transcript:

interface Transcript {
  videoId: string;
  lang: string;             // language of the returned transcript
  whisper: boolean;         // produced by Whisper speech-to-text
  cached: boolean;          // served from cache (always 1 unit)
  unitsCharged: number;     // captions: 1, Whisper: 15
  segments: { text: string; offset: number; duration: number }[];  // ms offsets
  text: string;             // convenience: all segment text joined
}

yt.lastQuota

Quota headers from the most recent successful request: { limit, used, rateLimitRemaining }.

Error handling

Every failure throws a typed YTranscriptError:

import { YTranscript, YTranscriptError } from "ytranscript-api";

try {
  await yt.transcript(videoId);
} catch (err) {
  if (err instanceof YTranscriptError) {
    switch (err.code) {
      case "no_transcript":   // 404 — video has no obtainable transcript
      case "quota_exceeded":  // 402 — monthly units exhausted
      case "rate_limited":    // 429 — back off and retry
      case "unauthorized":    // 401 — bad or revoked key
      case "fetch_failed":    // 500 — extraction failed (you are NOT charged)
      case "network_error":   // request never reached the API
    }
    console.error(err.status, err.message);
  }
}

Units & pricing

Caption transcripts cost 1 unit; Whisper transcriptions (captionless videos) cost 15 units. Failed requests cost nothing. Plans start at $29/mo for 10,000 units — get an API key at ytranscript.com/developers.

Why not scrape it yourself?

You can — until you deploy. YouTube aggressively bot-detects transcript extraction from datacenter IPs (AWS, GCP, Vercel, Railway…), so DIY libraries tend to work locally and fail in production. This API exists so that arms race is our full-time job instead of your on-call incident. Extraction success rates are high but not absolute, which is exactly why failed requests are never charged.

License

MIT