YouTube video transcript
Beta GET /v1/youtube/video/transcript
GET /v1/youtube/video/transcript
The video's own captions: the language you ask for (or the original audio's), typed by the uploader or recognised by YouTube (source), with the languages on offer. A video without captions answers transcript_unavailable and costs nothing; AI transcription of YouTube audio is not available yet.
- Cost: 1 credit for captions; AI transcription 1 up to 2 minutes, then 1 per started minute
- Status: Beta. Built and tested against recorded responses; the shape may still gain fields.
- Cache: Results are kept up to 30 days; send
max_age_daysto reuse them for free. - Timeout: A request still running after about 25 seconds answers
202with a job to poll (Batch and jobs).
Parameters#
| Name | Type | Required | Description |
|---|---|---|---|
url | URL | one of | Video or Short URL (watch, youtu.be, shorts, live, embed). Accepted hosts: youtube.com, youtu.be. |
id | string | one of | 11-character video id. Also accepted as videoId, video_id. |
language | string | no | Language code ("en", "es", "en-US"). Overrides the default track unless original_audio is set. Also accepted as lang. |
original_audio | boolean | no | Only return captions in the video's original spoken language. Takes precedence over language. Default false. |
Send at least one of url, id. If you send several, the first listed is used and the rest are ignored.
Every request also accepts:
trim:truefor a smaller response withoutnullfields andextra.raw:trueto also get the platform's original object asraw.max_age_days: accept a cached result up to this many days old, for 0 credits (Caching).
Example request#
Set your key in the environment first (see Authentication).
curl -G "https://api.socialscrape.io/v1/youtube/video/transcript" \
-H "x-api-key: $SOCIALSCRAPE_API_KEY" \
--data-urlencode "id=dQw4w9WgXcQ" \
--data-urlencode "language=de"import os
import requests
params = {
"id": "dQw4w9WgXcQ",
"language": "de",
}
res = requests.get(
"https://api.socialscrape.io/v1/youtube/video/transcript",
headers={"x-api-key": os.environ["SOCIALSCRAPE_API_KEY"]},
params=params,
)
body = res.json()
if body["ok"]:
print(body["data"])
else:
print(body["error"]["code"], body["error"]["message"])const url = new URL("https://api.socialscrape.io/v1/youtube/video/transcript");
url.search = new URLSearchParams({
"id": "dQw4w9WgXcQ",
"language": "de"
}).toString();
const res = await fetch(url, {
headers: { "x-api-key": process.env.SOCIALSCRAPE_API_KEY! },
});
const body = await res.json();
if (body.ok) {
console.log(body.data);
} else {
console.error(body.error.code, body.error.message);
}{
"nodes": [
{
"name": "SocialScrape YouTube video transcript",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
0,
0
],
"parameters": {
"method": "GET",
"url": "https://api.socialscrape.io/v1/youtube/video/transcript",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "id",
"value": "dQw4w9WgXcQ"
},
{
"name": "language",
"value": "de"
}
]
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "x-api-key",
"value": "={{ $env.SOCIALSCRAPE_API_KEY }}"
}
]
}
}
}
],
"connections": {}
}Example response#
This is a sample from a recorded response, lists and long text are shortened. Status 200.
{
"ok": true,
"credits_charged": 1,
"credits_remaining": 4999,
"cached": false,
"cached_at": null,
"request_id": "req_e45a821caf0eddcb356f1b98",
"data": {
"object": "transcript",
"platform": "youtube",
"video_id": "dQw4w9WgXcQ",
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"language": "de-DE",
"source": "captions",
"duration_seconds": 213.0,
"text": "Uns beiden ist die Liebe nicht fremd Du kennst die Regeln genau wie ich Für mich zählst nur du Das kriegst du sonst von keinem hier Ich will dir sagen, wie ich fühle Damit du es auch verstehst Ich geb dich niemals auf Lass dich niemals im S...",
"segments": [
{
"start": 18.64,
"end": 21.880000000000003,
"text": "Uns beiden ist die Liebe nicht fremd"
},
{
"start": 22.64,
"end": 26.96,
"text": "Du kennst die Regeln genau wie ich"
},
{
"start": 27.04,
"end": 31.04,
"text": "Für mich zählst nur du"
}
],
"available_languages": [
"de-DE",
"en",
"es-419"
],
"extra": {
"language_name": "German (Germany)",
"tracks": [
{
"auto": false,
"code": "en",
"name": "English"
},
{
"auto": true,
"code": "en",
"name": "English (auto-generated)"
},
{
"auto": false,
"code": "de-DE",
"name": "German (Germany)"
}
]
}
},
"cursor": null,
"has_more": null
}Response#
A Transcript object in data.
See Data models for every field. The envelope around data is described in Responses.
Errors#
Failures are free: credits_charged is 0. Branch on error.code, never on the message.
| Code | HTTP | Retry | Meaning |
|---|---|---|---|
invalid_params | 400 | no | A parameter is missing, unknown or has the wrong type. |
unsupported_url | 400 | no | The URL is not one this endpoint accepts (wrong platform or form). |
not_found | 404 | no | The platform says this profile, post or item does not exist. |
transcript_unavailable | 404 | no | No captions exist and AI transcription is not possible for this media. |
Every request can also fail with the account and platform errors listed on the Errors page.
Example error:
{
"ok": false,
"error": {
"code": "transcript_unavailable",
"message": "No captions exist and AI transcription is not possible for this media.",
"retryable": false
},
"credits_charged": 0,
"request_id": "req_7ca19846caca02fcdc1f4606"
}Related endpoints#
- YouTube channel details (
GET /v1/youtube/channel) - YouTube channel videos (
GET /v1/youtube/channel/videos) - Search inside a YouTube channel (
GET /v1/youtube/channel/search) - YouTube channel playlists (
GET /v1/youtube/channel/playlists) - YouTube channel Shorts (
GET /v1/youtube/channel/shorts) - YouTube channel live streams (
GET /v1/youtube/channel/lives) - YouTube channel community posts (
GET /v1/youtube/channel/community-posts) - YouTube video or Short details (
GET /v1/youtube/video)