YouTube's official Data API lets you list caption tracks, but downloading the caption text requires OAuth as the video owner. For anyone building search, summaries or AI features on top of other people's public videos, that is a dead end. The Video transcript endpoint takes a video ID and returns the transcript as structured JSON.
The request
The video ID is the part after v= in the video URL. For https://www.youtube.com/watch?v=OYp5j2RihPE it is OYp5j2RihPE.
curl "https://socialgraph.dev/api/v1/youtube/transcript?video_id=OYp5j2RihPE&languages=en" \
-H "Authorization: Bearer YOUR_API_KEY"
const url = new URL("https://socialgraph.dev/api/v1/youtube/transcript");
url.searchParams.set("video_id", "OYp5j2RihPE");
url.searchParams.set("languages", "en");
const response = await fetch(url, { headers: { Authorization: "Bearer YOUR_API_KEY" } });
const transcript = await response.json();
console.log(transcript.word_count, transcript.language, transcript.key_points);
What the response contains
transcript: the caption segments, each withtext,start(seconds) anddurationlanguage,language_codeandis_generated(auto-generated captions or uploaded by the creator)word_count,duration_seconds,segment_countkeywords,key_pointsand a shortconclusionsentimentwith a label and scores
So you get both the raw timed text for search and subtitles, and a ready-made summary layer.
Choosing the language
Pass languages=hi (or any ISO 639-1 code) to prefer a language. If that track doesn't exist, another available transcript is returned; check language_code in the response rather than assuming you got what you asked for.
Feeding transcripts to an AI model
A typical pipeline:
- List a channel's videos with the Playlist items endpoint (the uploads playlist is the channel ID with
UCreplaced byUU). - Fetch each transcript.
- Join the segment texts, chunk by a few thousand words, and send them to your model for summaries, Q&A or classification.
Keep the start times: they let you link an answer back to the exact second in the video.
Things to know
- Some videos have no captions (captions disabled, or no speech). Those return an error and cost nothing.
- Transcripts are fetched live and take a few seconds; use a 60-second timeout.
- Each successful call is 2 credits. A 100-video channel costs about US$0.40 to transcribe.
Try it on the endpoint page: the live demo runs on a real video without an account.