YouTubeExplainer

YouTube transcript API: get a video's transcript as JSON

Google's captions API downloads text only for videos you can edit, at 250 quota units a transcript. Ours returns a public video's transcript for 1 credit.

3 min read

Short answer

  • Google's captions.download needs OAuth and permission to edit the video, so the official API returns no caption text for videos on other channels.
  • One captions.list plus one captions.download costs 250 of the default 10,000 daily quota units, about 40 transcripts a day.
  • ToolzerHub returns timed transcript segments for a public video with captions, from a video ID or URL, at 1 credit a call, with 100 free credits a month.
On this page

Google's YouTube Data API has a captions resource, but it gives caption text only for videos you can edit. For any other public video it returns track metadata and no text. Our API returns a public video's transcript as JSON with timestamps, from a video ID or URL, for 1 credit.

What Google's captions API allows

The captions resource has two read methods. captions.list returns a video's caption tracks without the text. captions.download takes a track ID and returns the track as SRT, VTT, TTML, SBV or SCC, or a machine translation with tlang.

Both need OAuth with the youtube.force-ssl or youtubepartner scope, and download needs permission to edit the video, or it returns 403 forbidden. Use Google's API for videos you can edit, where it also uploads and edits captions.

The quota:

  • captions.list: 50 units.
  • captions.download: 200 units.
  • One transcript: 250 units, so 40 transcripts a day from the default 10,000 units.
  • More quota needs Google's quota extension form. Searches use a separate bucket of 100 calls a day; see the YouTube search API quota.

Get a transcript with ToolzerHub

We make ToolzerHub. Our YouTube API returns the transcript of a public video as JSON with one API key: no Google Cloud project, no OAuth and no access to the channel. video_reference takes a video ID or a watch, youtu.be, Shorts or embed URL. The YouTube reference lists all 29 endpoints under /v2/youtube/.

bash
curl "https://api.toolzerhub.com/v2/youtube/transcript?video_reference=M7lc1UVf-VE&language_code=en" \
  -H "x-api-key: $TOOLZERHUB_API_KEY"

The response shape, from the API reference:

json
{
  "data": {
    "id": "string",
    "transcript": [
      {
        "startMs": "string",
        "endMs": "string",
        "startTime": "string",
        "text": "string"
      }
    ]
  }
}
  • transcript is a list of timed segments. Each has the line's text, its startMs and endMs, and a display startTime.
  • The millisecond fields are strings. Convert them to numbers before you do arithmetic.
  • language_code picks the transcript language. There is no cursor: one call returns one video, and whether a transcript exists depends on the video's published captions.

For an SRT or VTT file, GET /v2/youtube/subtitles lists a video's caption tracks with each track's language and url. Pass that url as caption_source to GET /v2/youtube/subtitle with caption_style set to srt or vtt; json3, srv1, srv2, srv3 and ttml also work. Add translation_code for a translation. That is 2 calls per video.

What it costs

Every call costs 1 credit and returns one video's transcript, so 1,000 transcripts cost 1,000 credits. The SRT or VTT route is 2 credits per video. You get 100 free credits a month; $19 buys 10,000 credits that never expire, and plans for higher volume cover more videos. Get a free API key and run the request above.

For a few videos from your own computer, the open-source youtube-transcript-api Python library is free and needs no API key, but it uses an undocumented part of YouTube's API. For other YouTube jobs see how to get all comments and all videos from a channel.

We are not affiliated with YouTube or Google.

Sources

Get this data from your own code

The YouTube API returns it as JSON with one x-api-key header. 100 free credits monthly.