A call to the YouTube transcription API at GET /v1/youtube/video_transcript on api.virev.ai costs $0.0005, so 1,000 videos cost $0.50. The call returns the video's caption track as one text string and as segments with start times in milliseconds, in any language the video has captions in. It reads captions YouTube already has, uploaded or auto-generated, and does not transcribe audio, so a video with no captions answers 404 and costs nothing.

This guide gets one transcript in Python, picks a language, turns segments into timestamps, handles videos without captions and fetches transcripts for a list of videos. The YouTube transcript API reference has every response field and parameter.

Three ways to get a YouTube transcript

WayWhat it needsWhat it costs
YouTube Data API captions.downloadOAuth and permission to edit the video200 quota units a call
youtube-transcript-api Python libraryYour own machine, and rotating residential proxies on a cloud serverFree, plus any proxies
GET /v1/youtube/video_transcriptAn API key and one HTTPS request$0.0005 a call

Google's own captions.download method needs the youtube.force-ssl or youtubepartner OAuth scope, and the user must have permission to edit the video. It works for a channel you manage and not for a public video someone else uploaded.

The youtube-transcript-api library is free and MIT-licensed, and it does more with one video than this endpoint: it takes a list of languages in priority order, translates a track through YouTube, formats SRT or WebVTT and gives start times in fractions of a second, where this endpoint gives whole seconds. Its README says YouTube blocks most IPs of cloud providers such as AWS, Google Cloud and Azure, so code on a server needs rotating residential proxies. If your script runs on a laptop and reads a few videos, the library is the cheaper choice.

Get one transcript in Python

Send video_id as an 11-character id or as a watch, Shorts or youtu.be URL, with your key in the Authorization header.

python
import os
import requests

response = requests.get(
    "https://api.virev.ai/v1/youtube/video_transcript",
    params={"video_id": "0e3GPea1Tyg"},
    headers={"Authorization": f"Bearer {os.environ['VIREV_API_KEY']}"},
    timeout=60,
)
response.raise_for_status()
data = response.json()["data"]
print(data["language_name"], len(data["segments"]))
print(data["text"][:200])

The answer holds video_id, language, language_name, text, segments and segments_complete under data, and the price you paid under meta.cost. For this video language_name is English, and its first segment starts at 0 ms and runs 9,000 ms.

Choose the caption language

language takes a BCP-47 code, and a call without it asks for en. The endpoint looks for a track with that exact code first, then for any track of the same base language. It never translates, so each language you want is its own call and its own $0.0005.

You sendYou get
No language, or enThe en track, or an en-US or en-GB track when the video has only that
jaThe Japanese track, which YouTube labels Japanese (auto-generated) when speech recognition made it
ptAny Portuguese track, such as pt-BR
de on a video with no German track404 no_captions, not billed

Turn segments into timestamps

Each segment has start_ms, duration_ms and text. Start times come from YouTube's transcript panel in whole seconds, so a [mm:ss] line format loses nothing.

python
for seg in data["segments"]:
    minutes, seconds = divmod(seg["start_ms"] // 1000, 60)
    print(f"[{minutes:02}:{seconds:02}] {seg['text']}")
output
[00:00] - [Mr. Beast] I've recreated every single set from Squid Game in real life, and whichever one of these 456 people survives the longest, wins 456 grand.
[00:09] (contestants cheering) The first game we're gonna play is red light, green light.

For subtitles, the reference page has a script that writes an SRT file from the same segments. To read or download one transcript without code, the free YouTube transcript tool on virev.ai exports TXT, SRT and WebVTT.

Handle videos with no captions

A video with no caption track in the requested language answers 404 with error.code no_captions, and a removed or mistyped video answers 404 not_found. Neither is billed, so you can send a whole list and pay only for the transcripts you get.

python
response = requests.get(
    "https://api.virev.ai/v1/youtube/video_transcript",
    params={"video_id": video_id, "language": "de"},
    headers={"Authorization": f"Bearer {os.environ['VIREV_API_KEY']}"},
    timeout=60,
)
if response.status_code == 404 and response.json()["error"]["code"] == "no_captions":
    transcript = None
else:
    response.raise_for_status()
    transcript = response.json()["data"]

The endpoint reads captions only

Text from a video that has no captions needs a speech-to-text model run on its audio.

Transcripts for a list of videos

Single calls share your organization's limit of 100 requests a minute, so for more than a few hundred videos send one batch job instead of a loop. Each row is the query you would send to the single endpoint.

  1. Send up to 10,000 rows to POST /v1/batch/trigger?operation=youtube.video_transcript of the batch API, which is free to call.
  2. Poll GET /v1/batch/progress/{snapshot_id} until status leaves starting and running.
  3. Download GET /v1/batch/snapshot/{snapshot_id} as NDJSON, JSON or CSV, with each row's input beside its data.
python
import json
import os
import time
import requests

BASE = "https://api.virev.ai"
HEADERS = {"Authorization": f"Bearer {os.environ['VIREV_API_KEY']}"}
rows = [{"video_id": "0e3GPea1Tyg"}, {"video_id": "kJr98PyRl_k", "language": "ja"}]

job = requests.post(
    f"{BASE}/v1/batch/trigger",
    params={"operation": "youtube.video_transcript", "include_errors": "true"},
    json=rows,
    headers=HEADERS,
    timeout=60,
).json()["data"]

progress_url = f"{BASE}/v1/batch/progress/{job['snapshot_id']}"
while requests.get(progress_url, headers=HEADERS, timeout=60).json()["data"]["status"] in ("starting", "running"):
    time.sleep(5)

snapshot_url = f"{BASE}/v1/batch/snapshot/{job['snapshot_id']}"
lines = requests.get(snapshot_url, headers=HEADERS, timeout=300).text.splitlines()
for row in map(json.loads, lines):
    print(row["input"]["video_id"], row["error"]["code"] if "error" in row else row["data"]["language_name"])

With include_errors=true, a video with no captions comes back as a row with input and error instead of being dropped, so you can see which videos had none. The job needs a balance of rows times $0.0005 to start, and it bills each row only when that row returns a transcript.

What transcripts cost

VideosCost at $0.0005 a call
1$0.0005
1,000$0.50
10,000$5.00
100,000$50.00

A call that fails, a 404 included, costs nothing, and a batch row costs the same as a single call.

Get your first transcript for $0.0005

Create a key, then call the transcript endpoint with any video id.

Get your API key →