Fetching YouTube transcripts in Node.js usually means one of two things: fighting with heavy headless browsers or dealing with flaky, outdated scrapers.
I wanted something faster, type-safe, and proxy-ready. So I built YT Caption Kit.
The Problem
If you are building an AI summarizer, a search engine for videos, or a language learning app, you need captions. But:
Puppeteer/Playwright are overkill and resource-heavy for just fetching text.
Official YouTube APIs can be restrictive or require complex OAuth flows for simple data.
Formatting (like or tags) is often lost in basic scrapers.
The Solution: YT Caption Kit
yt-caption-kit is a lightweight, zero-browser dependency for Node.js and TypeScript that fetches transcripts directly from YouTube's internal endpoints.
Why you should use it:
π No Headless Browser: Extremely fast and low memory footprint.
π‘οΈ TypeScript First: Full autocomplete and built-in error classes (like AgeRestricted or IpBlocked).
π Smart Fallbacks: Automatically prefers manual transcripts but falls back to auto-generated ones.
π¨ Format Ready: Export to JSON, SRT, WebVTT, or plain text out of the box.
π Proxy Support: Built-in support for generic HTTP/SOCKS and Webshare rotation to avoid rate limits.
π» CLI Included: Need a transcript fast? Just run npx yt-caption-kit .
Quick Start
Bash
npm install yt-caption-kit
Using the API:
TypeScript
import { YtCaptionKit } from "yt-caption-kit";
const api = new YtCaptionKit();
// Fetch English or German transcripts with formatting preserved
const transcript = await api.fetch("GJLlxj_dtq8", {
languages: ["en", "de"],
preserveFormatting: true,
});
console.log(transcript.snippets);
Using the CLI:
Bash
# Get subtitles in SRT format for your video editor
yt-caption-kit GJLlxj_dtq8 --format srt --translate es
Handling the "YouTube Wall"
Weβve all been thereβyour IP gets flagged. yt-caption-kit makes it easy to plug in proxies so your app stays up:
TypeScript
const api = new YtCaptionKit({
proxyConfig: new WebshareProxyConfig({
proxyUsername: process.env.USER,
proxyPassword: process.env.PASS,
}),
});
π Support the project
This project relies on undocumented endpoints, which means maintenance is key! If you find this useful for your next AI project or tool, please consider dropping a star on GitHub. It helps me know people are using it and keeps the updates coming!
GitHub: https://github.com/Dhaxor/yt-caption-kit
NPM: https://www.npmjs.com/package/yt-caption-kit
I'd love to hear what you're building with this! Drop a comment below if you have questions or feature requests.
Top comments (0)