API DocsyoutubeContentGet video captions
Get video captions
What this API is for
- Get video caption list or caption content for a specific language
- Supports multiple caption format outputs
GET
/openapi/api/v1/youtube/web_v2/get_video_captionsPrice:Price unavailable · Actual charges depend on free quota and account discounts
Authentication
All API requests require a Bearer project token in the Authorization header
Authorization header
Authorization: Bearer YOUR_API_TOKENRequest parameters
- video_id: Video ID (recommended)
- video_url: Full video URL (optional)
- language_code: Language code (e.g. en, zh-Hans, a.en), returns available caption list if empty
- format: Caption format
- srt: SubRip subtitle format (with timestamps)
- xml: Raw XML format
- json3: JSON format (YouTube raw structure)
- txt: Plain text (no timestamps)
| Name | Location / type | Required | Notes | Example |
|---|---|---|---|---|
| video_id | query / string | No |
| dQw4w9WgXcQ |
| video_url | query / string | No |
| https://www.youtube.com/watch?v=dQw4w9WgXcQ |
| language_code | query / string | No |
| en |
| format | query / string | No |
| srt |
Request examples
curl -X GET "https://api.trmesh.com/openapi/api/v1/youtube/web_v2/get_video_captions" \ -H "Authorization: Bearer sdc_your_project_token" \ -H "Accept: application/json"
Response fields
- Without language_code (caption language list):
- With language_code (caption content):
- format=srt: Standard SRT subtitle content (with sequence numbers, timestamps, text)
- format=txt: Plain text (text only, no timestamps)
- format=xml: YouTube raw XML captions
- format=json3: YouTube JSON format captions
- Large videos (async job):
- When status="processing" is returned, poll /get_video_captions_result
- with the job_id to retrieve the final captions
- Video has no captions:
Common response envelope
Common fields for response status, request identifiers and data
| Field | Type | Notes | Example |
|---|---|---|---|
| code | integer |
| |
| request_id | string | null |
| |
| message | string |
| |
| message_zh | string |
| |
| support | string |
| |
| time | string |
| |
| time_stamp | integer |
| |
| time_zone | string |
| |
| docs | string | null |
| |
| cache_message | string | null |
| |
| cache_message_zh | string | null |
| |
| cache_url | string | null |
| |
| router | string |
| |
| params | unknown |
| |
| data | unknown | null |
|
Errors and limits
The docs cover not only success responses, but also auth failures, rate limits, and data-service errors
| Code | Meaning | Notes |
|---|---|---|
| 200 | Success | The request completed and returned the standard response envelope. |
| 401 | Unauthorized | The token is missing, invalid, or no longer active. |
| 429 | Rate limited | The request exceeded token, user, or plan-level throughput limits. |
| 502 | Service unavailable | The gateway could not obtain a healthy result. Retry in a moment. |
Next steps
New to the API? Read the guide or explore examples