Get fully typed YouTube transcript data in TypeScript. Our API returns predictable JSON that you can type with interfaces for maximum developer experience. Build type-safe transcript pipelines for Next.js, Remix, or any TypeScript project.
interface TranscriptSegment {
text: string;
start: number;
duration: number;
}
interface TranscriptResponse {
title: string;
channel: string;
duration: number;
transcript: TranscriptSegment[];
}
async function getTranscript(videoUrl: string): Promise<TranscriptResponse> {
const res = await fetch(
`https://api.youtubetranscripts.co/v1/transcript?url=${encodeURIComponent(videoUrl)}`,
{
headers: { "x-api-key": process.env.YT_TRANSCRIPTS_API_KEY! },
}
);
if (!res.ok) {
throw new Error(`API error: ${res.status}`);
}
return res.json() as Promise<TranscriptResponse>;
}
const data = await getTranscript("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
console.log(data.title);
console.log(`${data.transcript.length} segments, ${data.duration}s total`);Full type definitions for all API responses
Works with any TypeScript runtime or framework
Perfect for Next.js API routes and server actions
Predictable response shape for safe data access
Generic error handling with typed error responses
Compatible with zod, io-ts, and other validators
Sign up in 30 seconds. Get 150 free API requests. No credit card required. Your TypeScript integration can be live in minutes.