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:
| Field | Type | Description |
|---|---|---|
created_at | string (ISO 8601) | Request start time |
processed_at | string (ISO 8601) | Request completion time |
time_spent_ms | integer | Processing time in milliseconds |
requests_used | integer | Requests deducted for this call |
Get Video Info
Fetch metadata for a YouTube video.
POST /video/youtube/info
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
url | string | yes | YouTube video URL |
Response Fields
| Field | Type | Description |
|---|---|---|
source | string | Always "youtube" |
url | string | The requested URL |
title | string | null | Video title |
duration | number | null | Duration in seconds |
view_count | integer | null | View count |
like_count | integer | null | Like count |
comments_count | integer | null | Total number of comments on the video, as reported by YouTube |
is_channel_verified | boolean | null | Whether the uploader's channel is verified |
subtitles | array | Always [] on this endpoint; use /video/youtube/subtitles |
comments | null | Always 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
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | yes | — | YouTube video URL |
language | string | no | "en" | BCP-47 language code (e.g. "en", "de", "pt-BR"). Letters, digits and - only, at most 35 characters |
format | string | no | "srt" | Subtitle format: "srt", "vtt", "ass", "lrc", "json3" |
Response Fields
| Field | Type | Description |
|---|---|---|
source | string | Always "youtube" |
url | string | The requested URL |
title | string | null | Video title |
subtitles | array | One entry: the track in the requested language and format |
subtitles[].language | string | Language code of the returned track |
subtitles[].language_name | string | null | Human-readable language name |
subtitles[].format | string | Format of content |
subtitles[].content | string | The subtitle file contents |
subtitles[].is_auto | boolean | true 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
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | yes | — | YouTube video URL |
limit | integer | no | 1000 | Maximum 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
| Field | Type | Description |
|---|---|---|
source | string | Always "youtube" |
url | string | The requested URL |
title | string | null | Video title |
comments_count | integer | Number of comments in this response (not the total on the video) |
comments | array | The comments |
comments[].author | string | null | Author's display name |
comments[].text | string | null | Comment text |
comments[].likes | integer | null | Like count |
comments[].published | string | Unix 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.
| Status | error_code | Meaning | detail |
|---|---|---|---|
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", ...}] |
404 | video_not_found | The video does not exist or has been removed (all endpoints) | "Video not found" |
423 | video_not_accessible | The video exists but is private, members-only, age- or region-restricted (all endpoints) | "Video is private or restricted" |
422 | video_has_no_subtitles | /subtitles: the video has no subtitles at all | "No subtitles available for this video" |
422 | language_not_available | /subtitles: no track in the requested language | "No subtitles available for the requested language" |
422 | format_not_available | /subtitles: the track cannot be served in the requested format | "No subtitles available in the requested format" |
422 | video_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" |
429 | queue_full | The video service is busy. Retry after a few seconds | "Video service is busy, too many requests. Retry later" |
4xx | video_service_error | Any 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" |
504 | timeout | The video service gave up on the request. Retry later | "Video service timed out. Retry later" |
5xx | upstream_error | The 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:00UTC offset and microsecond precision — e.g.2026-07-03T12:00:00.000000+00:00(not aZsuffix).
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
}