Ssocialgraph.dev
Guides / Youtube

How to get a YouTube video transcript with an API

Pull the full transcript of any YouTube video by video ID, with timestamps, language, keywords and a summary, in one request. Includes code and tips for feeding transcripts to AI models.

Updated October 20, 2026 · 2 min read

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 with text, start (seconds) and duration
  • language, language_code and is_generated (auto-generated captions or uploaded by the creator)
  • word_count, duration_seconds, segment_count
  • keywords, key_points and a short conclusion
  • sentiment with 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:

  1. List a channel's videos with the Playlist items endpoint (the uploads playlist is the channel ID with UC replaced by UU).
  2. Fetch each transcript.
  3. 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.

Start with 100 free credits

Create an account in seconds. No card, no subscription. Credits never expire.

Create free account →