Skip to content

YouTube Transcript API Reference

The YouTube Transcript API provides a simple and reliable way to extract transcripts from YouTube videos programmatically. This complete reference covers authentication, request parameters, response formats, and practical examples.

Want to test the API interactively? Try our Swagger UI where you can make live requests right in your browser.

All API requests are made to:

https://transcriptapi.com/api/v2

The API provides a single endpoint:

GET /youtube/transcript

Here’s how to make your first API request:

Terminal window
curl -X GET "https://transcriptapi.com/api/v2/youtube/transcript?video_url=dQw4w9WgXcQ" \
-H "Authorization: Bearer YOUR_API_KEY"

Don’t have an API key yet? Get one from your dashboard.

Expected Response:

{
"video_id": "dQw4w9WgXcQ",
"language": "en",
"transcript": [
{
"text": "Never gonna give you up",
"start": 0.0,
"duration": 4.12
},
{
"text": "Never gonna let you down",
"start": 4.12,
"duration": 3.85
}
]
}

The API uses Bearer token authentication. Include your API key in the Authorization header of every request:

Authorization: Bearer YOUR_API_KEY

Example:

Terminal window
curl -X GET "https://transcriptapi.com/api/v2/youtube/transcript?video_url=..." \
-H "Authorization: Bearer YOUR_API_KEY"

Get your API key from your API Keys dashboard.

The YouTube video URL or video ID to fetch transcripts for.

PropertyValue
Typestring
Pattern^([a-zA-Z0-9_-]{11}|https?://.\*)$
RequiredYes

Accepted Formats:

  • Full YouTube URL: https://www.youtube.com/watch?v=dQw4w9WgXcQ
  • Short YouTube URL: https://youtu.be/dQw4w9WgXcQ
  • Video ID only: dQw4w9WgXcQ

Examples:

Terminal window
# Full URL
?video_url=https://www.youtube.com/watch?v=dQw4w9WgXcQ
# Short URL
?video_url=https://youtu.be/dQw4w9WgXcQ
# Video ID only
?video_url=dQw4w9WgXcQ

The output format for the transcript response.

PropertyValue
Typestring
Valuesjson, text
Defaultjson
  • json: Returns structured data with transcript segments
  • text: Returns plain text transcript

Whether to include timestamps in the transcript output.

PropertyValue
Typeboolean
Defaulttrue

Behavior Matrix:

Formatinclude_timestampOutput
jsontrueSegments with text, start, duration
jsonfalseSegments with only text
texttrueLines formatted as [123.45s] text
textfalsePlain concatenated text

Whether to include video metadata in the response.

PropertyValue
Typeboolean
Defaultfalse

When enabled, includes:

  • title: Video title
  • author_name: Channel name
  • author_url: Channel URL
  • thumbnail_url: Video thumbnail

The API supports multiple response formats based on your parameters:

{
"video_id": "dQw4w9WgXcQ",
"language": "en",
"transcript": [
{
"text": "Never gonna give you up",
"start": 0.0,
"duration": 4.12
},
{
"text": "Never gonna let you down",
"start": 4.12,
"duration": 3.85
}
],
"metadata": {
"title": "Rick Astley - Never Gonna Give You Up",
"author_name": "RickAstleyVEVO",
"author_url": "https://www.youtube.com/@RickAstley",
"thumbnail_url": "https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg"
}
}
HeaderDescription
X-Cache-StatusCache status: HIT, PARTIAL-HIT, or MISS
EndpointCredits per RequestNotes
GET /api/v2/youtube/transcript1 creditOnly charged on successful response (200)
  • Successful requests (HTTP 200) - 1 credit
  • Cached responses (HTTP 200) - 1 credit
  • Failed requests (4xx, 5xx errors) - 0 credits
  • Rate limited requests (HTTP 429) - 0 credits

Credits are deducted in real-time only when a transcript is successfully returned.

When credits are exhausted, the API returns HTTP 402 Payment Required.

All API keys are subject to the following rate limits:

  • 200 requests per minute per API key
  • 2 concurrent requests maximum

Each response includes rate limit information in the headers:

HeaderDescription
X-RateLimit-LimitTotal allowed requests in the window
X-RateLimit-RemainingRemaining requests in the window
X-RateLimit-ResetUTC epoch seconds when the window resets
Retry-AfterSeconds until you can retry (only on 429)

Example Headers:

X-RateLimit-Limit: 200
X-RateLimit-Remaining: 195
X-RateLimit-Reset: 1678901234
  1. Implement exponential backoff on 429 errors
  2. Respect the Retry-After header value
  3. Cache responses when appropriate to reduce API calls
  4. Don’t retry failed requests more than 2 times within 3 seconds
  5. Monitor rate limit headers to avoid hitting limits

The API uses standard HTTP status codes:

Status CodeMeaningAction
200SuccessTranscript returned, 1 credit charged
400Bad RequestCheck your request parameters
401UnauthorizedInvalid or missing API key
402Payment RequiredNo credits remaining, add more credits
404Not FoundVideo not found or transcript unavailable
422Validation ErrorInvalid YouTube URL or ID
429Too Many RequestsRate limit exceeded, retry after delay
500Server ErrorContact support if persistent

All error responses follow this format:

{
"detail": "Human-readable error message",
"code": "ERROR_CODE"
}

Includes a WWW-Authenticate header:

WWW-Authenticate: Bearer

Special format with action details:

Insufficient Credits:

{
"detail": {
"message": "You have an active plan, but you've run out of credits.",
"reason": "insufficient_credits",
"action_label": "Top up credits",
"action_url": "https://transcriptapi.com/top-up"
}
}

No Active Plan:

{
"detail": {
"message": "You don't have an active paid plan yet.",
"reason": "no_active_paid_plan",
"action_label": "Go to billing to choose a plan",
"action_url": "https://transcriptapi.com/billing"
}
}

Here are complete examples in multiple languages:

Terminal window
# Basic request
curl -X GET "https://transcriptapi.com/api/v2/youtube/transcript?video_url=dQw4w9WgXcQ" \
-H "Authorization: Bearer YOUR_API_KEY"
# With all parameters
curl -X GET "https://transcriptapi.com/api/v2/youtube/transcript?video_url=dQw4w9WgXcQ&format=json&include_timestamp=true&send_metadata=true" \
-H "Authorization: Bearer YOUR_API_KEY"
# Text format without timestamps
curl -X GET "https://transcriptapi.com/api/v2/youtube/transcript?video_url=dQw4w9WgXcQ&format=text&include_timestamp=false" \
-H "Authorization: Bearer YOUR_API_KEY"
  1. Implement retry logic with exponential backoff

    async function fetchWithRetry(url, options, maxRetries = 3) {
    for (let i = 0; i < maxRetries; i++) {
    try {
    const response = await fetch(url, options);
    if (response.status !== 429) return response;
    const retryAfter =
    response.headers.get("Retry-After") || Math.pow(2, i);
    await new Promise((resolve) => setTimeout(resolve, retryAfter * 1000));
    } catch (error) {
    if (i === maxRetries - 1) throw error;
    }
    }
    }
  2. Handle payment required errors gracefully

    • Redirect users to billing page
    • Show clear messaging about credit status
    • Provide action buttons for top-up
  • Cache successful responses to reduce API calls
  • Respect cache headers if provided
  • Consider transcript immutability (transcripts rarely change)
  • Implement cache invalidation for metadata
  • Monitor X-RateLimit-Remaining header
  • Implement request queuing when approaching limits
  • Use exponential backoff on 429 errors
  • Consider implementing client-side rate limiting
  • Never expose API keys in client-side code
  • Store API keys in environment variables
  • Use backend proxy for browser applications
  • Rotate API keys regularly
  • Use separate keys for different environments
  • Log all API responses including headers
  • Monitor credit usage patterns
  • Track rate limit approaches
  • Set up alerts for 402 and 429 responses
  • Monitor response times and cache hit rates

If you have questions or need assistance: