Blog · · 4 min read
Get the Transcript of an X Video With an API
Read the captions of any X video post as timed text: segments, full text, language and duration. Working code, the gaps to expect, and the limits.
Videos on X carry a lot of spoken information that never appears in the post text: announcements, interviews, product demos. A transcript lets you search it, quote it and feed it to other tools. This guide shows how to get the captions of an X video with a single GET request, what the answer contains, and the small surprises to plan for.
Request a transcript
Send the link of a post that has a video. Every call needs an API key. New accounts get 100 free credits and a first key is created automatically on sign-up (it is shown once on the dashboard). Sign in at scrapingrabbit.com/login, then send the key in the x-api-key header (a Bearer token also works). The code below reads it from the SCRAPINGRABBIT_API_KEY environment variable, so no key is ever written into your code.
curl -H "x-api-key: $SCRAPINGRABBIT_API_KEY" "https://api.scrapingrabbit.com/v1/twitter/transcript?url=https://x.com/NASA/status/2119833829389041896"
A successful call costs 5 credits, as the OpenAPI file lists it. Failed calls are not charged.
A shortened real answer, read on 3 December 2026 for a NASA video. We kept the first three caption lines and cut the rest:
{
"success": true,
"data": {
"tweetId": "2119833829389041896",
"author": "NASA",
"duration": 86.708,
"language": "en",
"label": "English",
"isAutoGenerated": false,
"transcript": [
{ "text": "Welcome to Max Power.", "start": 1.583, "duration": 1.5 },
{ "text": "NASA lit the fires and hosted a four-day", "start": 13.833, "duration": 2.167 },
{ "text": "showcase of American", "start": 16, "duration": 1.25 }
],
"text": "Welcome to Max Power. NASA lit the fires and hosted a four-day showcase of American excellence in air and space ...",
"availableLanguages": [{ "language": "en", "label": "English" }]
}
}
The real answer also has the post's description, its url, a mediaId, and the full list of caption lines. The text field is the whole transcript as one string.
What the fields mean
| Field | Meaning |
|---|---|
author | The account that posted the video |
duration | Length of the video in seconds |
language and label | The caption language, en and English here |
isAutoGenerated | true when X made the captions by machine, false when they were uploaded |
transcript[] | The timed lines: text, start in seconds and duration in seconds |
text | The whole transcript joined into one string |
availableLanguages | The caption languages the video has |
Things the numbers show
Two details in this answer are worth knowing before you build on it. The first caption line starts at 1.58 seconds and lasts 1.5 seconds, and the second one starts at 13.83 seconds. That is a gap of about 10.75 seconds with no caption, because the video has no speech there. And the last caption ends at about 79.2 seconds, while the video runs 86.7 seconds. So captions do not cover the whole timeline. If you build clips or subtitles, use the start values, not an even split of the duration.
The full text has 188 words over 86.7 seconds, about 130 words a minute. That is a normal speaking pace, a quick sanity check that the captions match the video.
Read it in code
async function xTranscript(postUrl) {
const url = `https://api.scrapingrabbit.com/v1/twitter/transcript?url=${encodeURIComponent(postUrl)}`;
const res = await fetch(url, { headers: { "x-api-key": process.env.SCRAPINGRABBIT_API_KEY } });
const body = await res.json();
if (!body.success) return null;
const { transcript, duration, isAutoGenerated, author } = body.data;
const stamp = (s) => `${Math.floor(s / 60)}:${String(Math.floor(s % 60)).padStart(2, "0")}`;
return {
author,
review: isAutoGenerated ? "machine captions, check before quoting" : "uploaded captions",
lines: transcript.map((l) => `${stamp(l.start)} ${l.text}`),
coverage: Math.round((transcript.at(-1).start + transcript.at(-1).duration) / duration * 100),
};
}
const result = await xTranscript("https://x.com/NASA/status/2119833829389041896");
console.log(result.review, `captions cover ${result.coverage}% of the video`);
console.log(result.lines.slice(0, 3).join("\n"));
The code formats each line with a time stamp, flags machine-made captions so nobody quotes them unchecked, and works out how much of the video the captions cover. For the video above that is 91 percent. It returns null when the call fails, which includes videos that have no captions.
The same in Python:
import os
import requests
res = requests.get(
"https://api.scrapingrabbit.com/v1/twitter/transcript",
params={"url": "https://x.com/NASA/status/2119833829389041896"},
headers={"x-api-key": os.environ["SCRAPINGRABBIT_API_KEY"]},
timeout=60,
)
body = res.json()
if body["success"]:
data = body["data"]
print(data["author"], data["language"], data["isAutoGenerated"])
print(data["text"][:200])
Things to plan for
- Many videos have no captions. The call then fails and is not charged. Handle that case, because it is common.
- Machine captions can be wrong. Check
isAutoGeneratedbefore you quote someone. - Captions do not cover the whole video. Silence and music leave gaps, so rely on each line's
start. - Posts without a video have no transcript. Private accounts have none either.
- Rate limits and credits. Each key is limited per minute: 10 requests on the free plan, 60 on Starter, 120 on Pro and 300 on Scale. A successful call costs 5 credits, so cache each transcript you have already read.
- Always check
success. A failed request returnssuccess: false, acodesuch asRATE_LIMITEDorINVALID_API_KEY, and amessage.
Try it without code
The free X video transcript tool works in the browser with no key and shows these captions for a post link you paste.
Try it yourself
Frequently asked questions
Does every X video have a transcript?
No. A transcript exists only when X has captions for the video, and many videos have none. Posts without a video, and posts from private accounts, have no transcript either.
Are the captions always correct?
Not always. Captions that X generates automatically can contain mistakes. The answer has an isAutoGenerated field that tells you which kind you got.
Do x.com and twitter.com links both work?
Yes. Paste the link of a post that has a video, from either domain.