YouTube Transcript API for JavaScript & Node.js
A REST YouTube Transcript API that drops into any JavaScript runtime — Node 18+, Next.js, Cloudflare Workers, Deno, Bun, or your own backend. Bearer-token auth, predictable JSON, 49ms median cached responses, and 100 free credits to ship your first feature today.
100 free credits — no credit card requiredWhat is a YouTube Transcript API in JavaScript?
A YouTube Transcript API in JavaScript is a plain HTTPS endpoint that takes a video ID or URL and returns the spoken text as structured JSON. You authenticate with a Bearer token in the Authorization header, send a GET request, and parse the JSON body. Because the contract is just HTTP and JSON, the same call works in any JavaScript runtime — Node, Next.js Route Handlers, Cloudflare Workers, Vercel Edge, Deno, Bun, and even the browser when you proxy through a backend you control.
Quickstart in JavaScript
Native fetch — Node 18+, Workers, Deno, Bun
const res = await fetch(
"https://youtubetranscriptapi.com/api/v2/youtube/transcript?video_url=dQw4w9WgXcQ",
{ headers: { Authorization: `Bearer ${process.env.YT_API_KEY}` } }
);
const { video_id, language, transcript } = await res.json();
console.log(transcript[0].text);axios variant
Install with npm i axios, then:
import axios from "axios";
const { data } = await axios.get(
"https://youtubetranscriptapi.com/api/v2/youtube/transcript",
{
params: { video_url: "dQw4w9WgXcQ" },
headers: { Authorization: `Bearer ${process.env.YT_API_KEY}` },
}
);The response shape is { video_id, language, transcript[] } where every segment has text, start (seconds), and duration (seconds). Optional metadata adds title, author, and thumbnail. See the full reference at /docs/api/transcript.
TypeScript types
Paste these interfaces into your project to get autocompletion on transcript data. The shape never changes across API versions, so you can ship them in a shared package without worrying about breaking changes.
interface TranscriptSegment {
text: string;
start: number;
duration: number;
}
interface TranscriptResponse {
video_id: string;
language: string;
transcript: TranscriptSegment[];
metadata?: {
title: string;
author_name: string;
author_url: string;
thumbnail_url: string;
};
}Use cases for JS & Node teams
Five places the YouTube Transcript API earns its keep in real JavaScript codebases.
AI summarizers
Feed clean transcript chunks straight into the Vercel AI SDK, OpenAI, or Anthropic to ship summaries, chapters, and quote pulls.
RAG indexes
Each segment ships with start and duration, so chunking by token count or by minute is one map() away — perfect for vector stores.
Discord and Slack bots
Drop a YouTube link in chat, hit the YouTube Transcript API in your bot worker, and reply with a 200-word recap before the next message lands.
Edge functions
Native fetch + Bearer auth means it runs unchanged on Cloudflare Workers, Vercel Edge, and Netlify Edge — no Node-only libraries.
Content pipelines
Power newsletters, SEO articles, and YouTube-to-blog workflows by piping transcripts into your CMS or static site generator.
Why our REST API beats DIY scraping
No headless browser
Skip Puppeteer, Playwright, and the 200MB Chromium tarball that breaks every Lambda cold start. One fetch call, no infra to babysit.
No IP blocks or 429s
YouTube hates scrapers from Cloud IPs. We rotate, retry, and absorb the blocks so your worker keeps shipping clean responses.
Cached at the edge
Repeat fetches for the same video return in 49ms median. That is faster than your DB round-trip, with predictable JSON every time.
Frequently asked questions
Does this work in Cloudflare Workers and Vercel Edge?
Yes. The YouTube Transcript API uses the standard fetch interface and Bearer auth, with no Node-only modules in the request path. Drop the same snippet into a Cloudflare Worker, a Vercel Edge function, or a Deno Deploy handler — it runs unchanged. Responses arrive as JSON, ready for Response.json().
Can I use it directly in a browser?
Technically yes, but you should not. Calling the API from client-side JavaScript would expose your API key in the page source. Instead, proxy through a Next.js Route Handler, a Cloudflare Worker, or any small backend you control, and forward only the transcript payload to the browser.
Do you provide an official npm SDK?
No SDK is needed — fetch is enough. The endpoints return predictable JSON with a stable shape, and the auth header is a single Bearer token. We may publish a typed npm wrapper later, but most teams ship faster by pasting the 6-line fetch call below into their codebase.
What's the rate limit and how do I handle 429?
300 requests per minute per API key. Every response includes X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset headers — read them in your fetch wrapper. On a 429, sleep for the seconds returned in the Retry-After header, then retry. Stay polite and you will not be throttled.
Are failed requests charged?
Errors and 429s are never charged — only HTTP 200s debit a credit. That includes 4xx validation errors, 404 missing transcripts, 408/503 upstream blips, and 429 throttling. Your 100 free credits will last as long as your successful requests do, so you can iterate against the YouTube Transcript API without watching the meter.
How do I bulk-fetch transcripts efficiently?
Use Promise.all for small batches and a tiny worker pool for large ones — six concurrent fetches is a safe ceiling under 300 req/min. Always honor X-RateLimit-Remaining before firing the next batch, and persist results to your DB so you never re-pay a credit for the same video twice.
Ship a YouTube feature today.
Grab an API key in 30 seconds. 100 free credits, no card. Predictable JSON, Bearer auth, the same YouTube Transcript API your tests already expect.