Skip to main content

YouTube API Reference

All endpoints require an Advanced package API key passed via the X-API-Key header.

url must be a YouTube video URL on one of these hosts: youtube.com, www.youtube.com, m.youtube.com, music.youtube.com, youtu.be. Any other host is rejected with a validation 422.

Every response includes the following envelope fields:

FieldTypeDescription
created_atstring (ISO 8601)Request start time
processed_atstring (ISO 8601)Request completion time
time_spent_msintegerProcessing time in milliseconds
requests_usedintegerRequests deducted for this call

Get Video Info​

Fetch metadata for a YouTube video.

POST /video/youtube/info

Request Body​

FieldTypeRequiredDescription
urlstringyesYouTube video URL

Response Fields​

FieldTypeDescription
sourcestringAlways "youtube"
urlstringThe requested URL
titlestring | nullVideo title
durationnumber | nullDuration in seconds
view_countinteger | nullView count
like_countinteger | nullLike count
comments_countinteger | nullTotal number of comments on the video, as reported by YouTube
is_channel_verifiedboolean | nullWhether the uploader's channel is verified
subtitlesarrayAlways [] on this endpoint; use /video/youtube/subtitles
commentsnullAlways null on this endpoint; use /video/youtube/comments

Billing​

1 request per call.

Example Request​

{
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}

Example Response​

{
"source": "youtube",
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"title": "Rick Astley - Never Gonna Give You Up (Official Music Video)",
"duration": 213.0,
"view_count": 1500000000,
"like_count": 16000000,
"subtitles": [],
"comments_count": 2300000,
"comments": null,
"is_channel_verified": true,
"created_at": "2026-07-03T12:00:00.000000+00:00",
"processed_at": "2026-07-03T12:00:05.000000+00:00",
"time_spent_ms": 5000,
"requests_used": 1
}

Timeout​

65 s. Requests that run past it fail with 504 (error_code: "timeout"), or 502 if the video service could not be reached (see Error Responses). Nothing is billed.


Get Subtitles​

Fetch subtitle content for a YouTube video in the specified language and format.

POST /video/youtube/subtitles

Request Body​

FieldTypeRequiredDefaultDescription
urlstringyes—YouTube video URL
languagestringno"en"BCP-47 language code (e.g. "en", "de", "pt-BR"). Letters, digits and - only, at most 35 characters
formatstringno"srt"Subtitle format: "srt", "vtt", "ass", "lrc", "json3"

Response Fields​

FieldTypeDescription
sourcestringAlways "youtube"
urlstringThe requested URL
titlestring | nullVideo title
subtitlesarrayOne entry: the track in the requested language and format
subtitles[].languagestringLanguage code of the returned track
subtitles[].language_namestring | nullHuman-readable language name
subtitles[].formatstringFormat of content
subtitles[].contentstringThe subtitle file contents
subtitles[].is_autobooleantrue for YouTube's automatic captions, false for uploaded subtitles

If the video has no subtitles, or none in the requested language or format, the call fails with 422 and an error_code saying which (see Error Responses).

Billing​

1 request per call.

Example Request​

{
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"language": "en",
"format": "srt"
}

Example Response​

{
"source": "youtube",
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"title": "Rick Astley - Never Gonna Give You Up (Official Music Video)",
"subtitles": [
{
"language": "en",
"language_name": "English",
"format": "srt",
"content": "1\n00:00:01,000 --> 00:00:04,000\nNever gonna give you up\n\n2\n...",
"is_auto": false
}
],
"created_at": "2026-07-03T12:00:00.000000+00:00",
"processed_at": "2026-07-03T12:00:03.200000+00:00",
"time_spent_ms": 3200,
"requests_used": 1
}

Timeout​

65 s. Requests that run past it fail with 504 (error_code: "timeout") or 502, and nothing is billed.


Get Comments​

Fetch comments for a YouTube video.

POST /video/youtube/comments

Request Body​

FieldTypeRequiredDefaultDescription
urlstringyes—YouTube video URL
limitintegerno1000Maximum number of comments, from 1 to 1000 (values outside the range are a validation 422). For prepaid keys it is additionally capped to what the current balance can afford (balance × 10 comments), so a request never reserves more than the balance covers.

Response Fields​

FieldTypeDescription
sourcestringAlways "youtube"
urlstringThe requested URL
titlestring | nullVideo title
comments_countintegerNumber of comments in this response (not the total on the video)
commentsarrayThe comments
comments[].authorstring | nullAuthor's display name
comments[].textstring | nullComment text
comments[].likesinteger | nullLike count
comments[].publishedstringUnix timestamp in seconds as a string (e.g. "1712345678"); when YouTube gives no timestamp, its relative text (e.g. "2 weeks ago"), or ""

If the video has no comments, or comments are turned off, the call fails with 422 (error_code: "video_has_no_comments").

Billing​

1 request per 10 comments (minimum 1), billed on the number of comments actually returned.

Examples: 5 comments → 1 request, 100 comments → 10 requests, 1 000 comments → 100 requests.

Example Request​

{
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"limit": 100
}

Example Response​

{
"source": "youtube",
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"title": "Rick Astley - Never Gonna Give You Up (Official Music Video)",
"comments_count": 100,
"comments": [
{
"author": "John Doe",
"text": "This is a classic!",
"likes": 42,
"published": "1712345678"
}
],
"created_at": "2026-07-03T12:00:00.000000+00:00",
"processed_at": "2026-07-03T12:01:00.000000+00:00",
"time_spent_ms": 60000,
"requests_used": 10
}

Timeout​

155 s. Requests that run past it fail with 504 (error_code: "timeout") or 502, and nothing is billed.


Error Responses​

All error responses include the standard envelope fields (created_at, processed_at, time_spent_ms, requests_used) alongside the detail field. Errors are never billed: requests_used is 0.

Errors that come from the video service also carry an error_code string. Branch on error_code rather than on detail text. Errors raised before the request reaches the video service (authentication, plan, thread limit, validation) and connection failures (502) have no error_code.

Statuserror_codeMeaningdetail
401—Missing or invalid API key, package not activated, or insufficient balance"Missing API key. Provide the X-API-Key header" / "Invalid API key" / "Please activate your package" / "Not enough requests. Renew your package."
403—Account suspended, or the key is not on the Advanced plan"PAYG account is suspended" / "Render JS is available only in the Advanced plan. Upgrade your plan to use this feature. Your package: …"
422—Request body validation error (FastAPI). detail is a list of error objects, not a string (see below)[{"type": "value_error", "loc": ["body", "url"], "msg": "Value error, url must be a YouTube video URL", ...}]
404video_not_foundThe video does not exist or has been removed (all endpoints)"Video not found"
423video_not_accessibleThe video exists but is private, members-only, age- or region-restricted (all endpoints)"Video is private or restricted"
422video_has_no_subtitles/subtitles: the video has no subtitles at all"No subtitles available for this video"
422language_not_available/subtitles: no track in the requested language"No subtitles available for the requested language"
422format_not_available/subtitles: the track cannot be served in the requested format"No subtitles available in the requested format"
422video_has_no_comments/comments: the video has no comments, or comments are turned off"No comments available for this video"
429—Your concurrent thread limit is reached"Maximum number of threads reached"
429queue_fullThe video service is busy. Retry after a few seconds"Video service is busy, too many requests. Retry later"
4xxvideo_service_errorAny other error the video service returned for this request"Video service error"
502—The video service is unreachable, did not answer within the endpoint's timeout, or returned an unusable body"Upstream video service connection error"
504timeoutThe video service gave up on the request. Retry later"Video service timed out. Retry later"
5xxupstream_errorThe video service failed (including temporary unavailability). Retry later"Upstream video service error"
500—Internal error"Unexpected server error"

The video service's own wording is never forwarded: known errors are reduced to the messages above, everything else to the generic video_service_error / upstream_error.

Timestamps (created_at / processed_at) are ISO 8601 with an explicit +00:00 UTC offset and microsecond precision — e.g. 2026-07-03T12:00:00.000000+00:00 (not a Z suffix).

Error body example (video service error):

{
"detail": "No subtitles available for the requested language",
"error_code": "language_not_available",
"created_at": "2026-07-03T12:00:00.000000+00:00",
"processed_at": "2026-07-03T12:00:04.100000+00:00",
"time_spent_ms": 4100,
"requests_used": 0
}

Error body example (billing):

{
"detail": "Not enough requests. Renew your package.",
"created_at": "2026-07-03T12:00:00.000000+00:00",
"processed_at": "2026-07-03T12:00:00.012000+00:00",
"time_spent_ms": 12,
"requests_used": 0
}