100 free credits. No credit card required. Get a key

X (Twitter) video transcript API

The transcript of the video in an X post, from the captions X serves with the video itself: timed segments, the whole text, and every caption track the video has (uploaded, or X’s own auto-generated ones).

GET /v1/x/tweets/{id}/transcript2 credits per callRefunded on failure
import os, requests

res = requests.get(
    "https://api.groundsocial.dev/v1/x/tweets/1585341984679469056/transcript",
    headers={"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"},
)
res.raise_for_status()
data = res.json()
Response
200 · 2 credits
{
"data": {
"tweet_id": "1585341984679469056",
"media_key": "7_1585341912877146112",
"duration_ms": 9301,
"language": "en-US",
"auto_generated": true,
"text": "Just like getting this and what was singing then you just can't help with it. That's it, yeah.",
"segments": [
{
"start_ms": 280,
"end_ms": 6520,
"text": "Just like getting this and what was singing then you just can't"
},
{
"start_ms": 6520,
"end_ms": 6919,
"text": "help with it."
},
"… 1 more"
]
},
"tracks": [
{
"language": "en-US",
"name": "en-US (auto-generated)",
"auto_generated": true
}
]
}

Parameters

NameTypeDescription
idpath · requiredstringA post id or a post URL (x.com or twitter.com). Example: 1585341984679469056.
langquerystringPreferred caption language (BCP 47), e.g. en. Example: en.
Response fields

200 with a XTranscriptResponse, in the shape of X’s API v2 Tweet and User objects.

FieldTypeDescription
dataobject
tracksXCaptionTrack[]Every caption track the video has; data is one of them.
Status codes
StatusMeaning
200The transcript and the caption tracks available.
400Invalid input. Nothing was charged.
401Missing or invalid API key.
402Not enough credits, a spend cap was reached, or payment is required.
403The target is private, or the account is suspended.
404The post or account does not exist, was deleted, or is suspended.
429Too many requests. Wait for Retry-After seconds.
503X is temporarily unavailable. Retryable; nothing was charged.

Every error has code, message, hint and retryable. All error codes

Questions

What if the video has no captions?

Then the call answers 404 target_not_found and is not charged. Most videos have X’s auto-generated captions.

X is a trademark of X Corp. We are not affiliated with or endorsed by X Corp.