You have a video on YouTube and you need the full transcript right now—so you can summarize it, index it, generate captions, or feed it into your media pipeline. By the end of this article, you’ll make a single GET request to fetch a structured transcript (text, duration, offset, lang) for a YouTube video, and wire it into your code or AI agent without leaving your sprint.
What this Media API does and when to use it
The YouTube Sub Extractor API returns the text transcript for a given YouTube video. The response is a list of caption segments with:
- text: the subtitle/utterance text
- duration: segment length in seconds
- offset: start time in seconds from the beginning of the video
- lang: the language tag for the segment
This is useful for media search, content moderation, topic analysis, automated chaptering, accessibility workflows, and building RAG prompts that summarize or answer questions about a single video. Because the API returns timestamps, you can align the text back to the video timeline for highlights and previews.
Getting started on Zyla API Hub
Zyla API Hub hosts more than 10,000 public APIs with a single account, one API key, and a subscription + quota model (not pay-per-call). The first API typically offers a 7-day trial or 50 requests; there’s no Free Plan. Check the API page for current access options and pricing.
To try this API:
- Open the listing for the YouTube Sub Extractor API and start the trial: Start 7-day trial on YouTube Sub Extractor API.
- Click Subscribe or Start Free Trial if available to get your API key.
- Use Authorization: Bearer YOUR_API_KEY in every call.
If you’re new to the marketplace, you can also browse and subscribe to other Entertainment & Media APIs on Zyla API Hub with the same key and account.
Endpoint overview
The YouTube Sub Extractor API exposes one endpoint you need to implement “get video transcript” fast:
-
Get Video Transcript
Method: GET
URL: https://zylalabs.com/api/5216/youtube-sub-extractor-api/6681/get-video-transcript
Required query parameter:- videoId (string): YouTube video ID
cURL you can paste right now
Use your API key in the Authorization header and call the endpoint with the required videoId. This is the official example:
curl -s -X GET "https://zylalabs.com/api/5216/youtube-sub-extractor-api/6681/get-video-transcript?videoId=eCBABjPcNyo" \
-H "Authorization: Bearer YOUR_API_KEY"
What the response looks like
Official sample response (truncated for brevity in a real-world UI, but preserved here exactly as provided):
{"success":true,"transcript":[{"text":"o que a gente tem no diante","duration":3.24,"offset":0,"lang":"en"},{"text":"dos nossos olhos não dá muita esperança","duration":3.24,"offset":3.24,"lang":"en"},{"text":"no futuro daqui eu vejo a polícia","duration":3.24,"offset":6.48,"lang":"en"},{"text":"atirando a dignidade de pais de família","duration":3.24,"offset":9.72,"lang":"en"},{"text":"daqui eu vejo o estado transformando pessoas","duration":3.24,"offset":12.96,"lang":"en"},{"text":"que poderiam dar bons frutos carregado em","duration":3.24,"offset":16.200000000000003,"lang":"en"},{"text":"pessoas frustradas eu não julgo entendeu monstro","duration":3.24,"offset":19.44,"lang":"en"},{"text":"não precisa ser nenhum expert title superlotado","duration":3.24,"offset":22.68,"lang":"en"},{"text":"estudado formada uma coisa pra saber que","duration":3.24,"offset":25.92,"lang":"en"},{"text":"está tudo errado para saber qual a","duration":3.24,"offset":29.160000000000004,"lang":"en"},{"text":"posição da gente isso tem que acabar","duration":3.24,"offset":32.400000000000006,"lang":"en"},{"text":"com os palestinos abete paz [Música] gino","duration":3.24,"offset":35.64,"lang":"en"},{"text":"problema queria só paz mas não viu","duration":3.24,"offset":38.88,"lang":"en"},{"text":"o veículo agora sem proteção da vida","duration":3.24,"offset":42.120000000000005,"lang":"en"},{"text":"e arrojado mas ainda era o então","duration":3.24,"offset":45.36,"lang":"en"},{"text":"ainda disparava e agora o que eu","duration":3.24,"offset":48.6,"lang":"en"},{"text":"faço me fala na maturidade na sala","duration":3.24,"offset":51.84,"lang":"en"},{"text":"tem pesadelo é época de eleição nosso","duration":3.24,"offset":55.080000000000005,"lang":"en"},{"text":"descabelo progresso sem previsão no chão torço","duration":3.24,"offset":58.32000000000001,"lang":"en"},{"text":"pro meu filho também não vira lata","duration":3.24,"offset":61.56,"lang":"en"},{"text":"é um opção tem vaca tem sempre","duration":3.24,"offset":64.80000000000001,"lang":"en"},{"text":"cid piada pode justificar nada eu entrei","duration":3.24,"offset":68.04,"lang":"en"},{"text":"político claro que foi pra vencer nelson","duration":3.24,"offset":71.28,"lang":"en"},{"text":"é um nojo esgoto exposto é alguém","duration":3.24,"offset":74.52000000000001,"lang":"en"},{"text":"é tanta injustiça em sangue nas suas","duration":3.24,"offset":77.76,"lang":"en"},{"text":"mãos por não fazer nada a troca","duration":3.24,"offset":81…
Fields you’ll typically use:
- success: boolean indicating the call worked
- transcript: array of segments; each has:
- text: subtitle segment content
- duration: length in seconds (float)
- offset: start time in seconds from 0.0 (float)
- lang: language tag for the line
Practical notes:
- Offsets and durations are seconds (floats). Multiply by 1000 if your UI expects milliseconds.
- Transcripts for a given videoId are typically static. Cache by videoId to avoid repeated calls in indexing pipelines.
- If a video does not have captions, handle an empty or missing transcript array gracefully in your app logic.
Python example: fetch, flatten, and print timestamps
This Python snippet calls the same endpoint, checks success, and formats each line with start and end times.
import requests
from datetime import timedelta
API_KEY = "YOUR_API_KEY"
VIDEO_ID = "eCBABjPcNyo"
url = "https://zylalabs.com/api/5216/youtube-sub-extractor-api/6681/get-video-transcript"
params = {"videoId": VIDEO_ID}
headers = {"Authorization": f"Bearer {API_KEY}"}
resp = requests.get(url, params=params, headers=headers, timeout=30)
resp.raise_for_status()
data = resp.json()
if not data.get("success"):
raise RuntimeError("API call did not succeed")
segments = data.get("transcript", [])
def fmt(ts):
return str(timedelta(seconds=float(ts)))
for seg in segments:
start = seg.get("offset", 0)
dur = seg.get("duration", 0)
end = float(start) + float(dur)
text = seg.get("text", "")
lang = seg.get("lang", "")
print(f"[{fmt(start)} - {fmt(end)}] ({lang}) {text}")
Swap the print logic for your use case: write to SRT/VTT, index into search, or feed into your summarizer.
Common media workflows you can ship this week
- Search indexing for a video library: store text, offset, and duration; let users jump to exact timestamps in your player.
- Automated chaptering: group segments by pauses or topic shifts and generate clickable chapters.
- Content moderation: scan transcript segments for flagged terms with time-based review queues.
- Summarization and Q&A: pass transcript chunks to your LLM with offsets so answers can include deep links into the video.
- Caption QA: compare segments against your own subtitle files to find gaps or drift.
Details that save time in production
- Map offsets/durations directly to your player timeline. If you need frame accuracy, convert seconds to frames using your player’s FPS.
- Chunking for LLMs: batch segments to keep prompts under token limits; preserve offsets so you can reconstruct source timestamps in outputs.
- Normalization: transcripts may include punctuation or music tags. Preprocess as needed for your search pipeline.
- Retries and idempotency: because transcript content is stable, wrap calls in a retry with caching to avoid duplicate network hits during backfills.
Call this API from AI agents via MCP
You can also invoke the same Hub endpoint through MCP-compatible IDE agents. Point your MCP client to the Zyla MCP gateway and supply your key. See the docs here: MCP.
Implementation outline:
- Configure your MCP client with the base gateway and your API key.
- Call the Hub URL path for Get Video Transcript with videoId=eCBABjPcNyo.
- Ensure the Authorization: Bearer YOUR_API_KEY header is passed through.
- Parse the same JSON fields (success, transcript[].text/duration/offset/lang) in your tool’s handler.
This lets an AI agent fetch transcripts on demand and chain the result into summarization or tagging steps without leaving your editor.
Troubleshooting and edge-handling
- Empty transcript: not all videos have captions; handle an empty transcript array gracefully.
- Time math: duration and offset are floats. Round carefully for display to prevent off-by-one second errors in UIs.
- Caching: since transcripts are stable, memoize results per videoId. This keeps your quota focused on new content.
- Language: lang tags are returned per segment. If you surface language filters, aggregate langs across segments first.
Quick reference
- API listing: YouTube Sub Extractor API
- Method: GET
- Endpoint: https://zylalabs.com/api/5216/youtube-sub-extractor-api/6681/get-video-transcript
- Required query param: videoId (string)
- Auth header: Authorization: Bearer YOUR_API_KEY
For other Media integrations you might need next, browse the Entertainment & Media category on Zyla API Hub. One key works across every subscribed API.
FAQ
Does this endpoint require any parameters besides videoId?
No. The Get Video Transcript endpoint requires only the videoId parameter.
What time units do duration and offset use?
Seconds as floating-point values. Convert to milliseconds or frames as needed for your player.
What authentication is required?
Pass your key with Authorization: Bearer YOUR_API_KEY on every request.
How is billing handled?
Zyla uses a subscription + quota model (not pay-per-call). The first API typically offers a 7-day trial or 50 requests. Check the API page for current access options and pricing.
Can I call this API from an AI agent?
Yes. Use the MCP gateway and include your Authorization header; see MCP for details.
Ready to ship your integration? Start your trial, get an API key, and fetch transcripts in minutes: Start 7-day trial on YouTube Sub Extractor API.