YouTube Subtitles Downloader API
Overview
Section titled “Overview”The YouTube Subtitles Downloader API enables you to extract and download subtitles/captions from any YouTube video. The API supports multiple output formats and automatic language detection, making it perfect for content creators, developers, and researchers.
Base URL: https://youtube-subtitles-downloader-api.p.rapidapi.com
Features
Section titled “Features”- Extract subtitles from any public YouTube video
- Works with regular videos AND YouTube Shorts
- Multiple output formats: SRT, VTT, TXT, JSON
- Multi-language support
- Fast processing times
- Detailed metadata including video title, duration, and segment count
- Automatic fallback to available languages
Authentication
Section titled “Authentication”All requests must include your RapidAPI key in the headers:
x-rapidapi-key: YOUR_RAPIDAPI_KEYx-rapidapi-host: youtube-subtitles-downloader-api.p.rapidapi.comQuick Start Examples
Section titled “Quick Start Examples”Example 1: Long Video (15 min) - SRT Format
Section titled “Example 1: Long Video (15 min) - SRT Format”curl -X POST "https://youtube-subtitles-downloader-api.p.rapidapi.com/download?url=https://www.youtube.com/watch?v=z_bX3runikk&format=srt&language=en" \ -H "x-rapidapi-host: youtube-subtitles-downloader-api.p.rapidapi.com" \ -H "x-rapidapi-key: YOUR_RAPIDAPI_KEY"Response:
{ "success": true, "video_id": "z_bX3runikk", "video_title": "Matthew McConaughey's Concerns Over AI", "video_duration": 914, "language": "en", "format": "srt", "total_segments": 469, "total_characters": 15409, "processing_time_ms": 699, "subtitles": "1\n00:00,880 --> 00:02,879\nthe Joe Rogan Experience.\n\n2\n00:02,879 --> 00:05,439\nAnd then we got AI on the way. And when\n\n3\n00:05,440 --> 00:08,800\nreal AI hits, it'll probably be our\n\n4\n00:08,800 --> 00:11,360\ngovernor. It'll be our president. It'll\n..."}Save to file:
curl -X POST "https://youtube-subtitles-downloader-api.p.rapidapi.com/download?url=https://www.youtube.com/watch?v=z_bX3runikk&format=srt&language=en" \ -H "x-rapidapi-host: youtube-subtitles-downloader-api.p.rapidapi.com" \ -H "x-rapidapi-key: YOUR_RAPIDAPI_KEY" \ | grep -o '"subtitles":"[^"]*"' | sed 's/"subtitles":"//;s/"$//' | sed 's/\\n/\n/g' > subtitles.srtExample 2: YouTube Short (34 sec) - VTT Format
Section titled “Example 2: YouTube Short (34 sec) - VTT Format”curl -X POST "https://youtube-subtitles-downloader-api.p.rapidapi.com/download?url=https://www.youtube.com/shorts/ivTdEQ6wseU&format=vtt&language=en" \ -H "x-rapidapi-host: youtube-subtitles-downloader-api.p.rapidapi.com" \ -H "x-rapidapi-key: YOUR_RAPIDAPI_KEY"Response:
{ "success": true, "video_id": "ivTdEQ6wseU", "video_title": "Are We Living in a Simulation Within a Simulation?", "video_duration": 34, "language": "en", "format": "vtt", "total_segments": 22, "total_characters": 786, "processing_time_ms": 898, "subtitles": "WEBVTT\n\n1\n00:00:00.000 --> 00:00:01.360\nthe simulation theory. I'm glad you\n\n2\n00:00:01.360 --> 00:00:03.040\nbrought that up. You're also one of the\n..."}Save to file:
curl -X POST "https://youtube-subtitles-downloader-api.p.rapidapi.com/download?url=https://www.youtube.com/shorts/ivTdEQ6wseU&format=vtt&language=en" \ -H "x-rapidapi-host: youtube-subtitles-downloader-api.p.rapidapi.com" \ -H "x-rapidapi-key: YOUR_RAPIDAPI_KEY" \ | grep -o '"subtitles":"[^"]*"' | sed 's/"subtitles":"//;s/"$//' | sed 's/\\n/\n/g' > subtitles.vttExample 3: JSON Format with Full Metadata
Section titled “Example 3: JSON Format with Full Metadata”curl -X POST "https://youtube-subtitles-downloader-api.p.rapidapi.com/download?url=https://www.youtube.com/watch?v=z_bX3runikk&format=json&language=en" \ -H "x-rapidapi-host: youtube-subtitles-downloader-api.p.rapidapi.com" \ -H "x-rapidapi-key: YOUR_RAPIDAPI_KEY"Response:
{ "success": true, "video_id": "z_bX3runikk", "video_title": "Matthew McConaughey's Concerns Over AI", "video_duration": 914, "language": "en", "format": "json", "total_segments": 469, "total_characters": 15409, "processing_time_ms": 756, "subtitles": "{\"video_id\":\"z_bX3runikk\",\"video_title\":\"Matthew McConaughey's Concerns Over AI\",\"video_duration\":914,\"language\":\"en\",\"total_segments\":469,\"segments\":[{\"start\":0.88,\"duration\":1.999,\"text\":\"the Joe Rogan Experience.\"},{\"start\":2.879,\"duration\":2.561,\"text\":\"And then we got AI on the way. And when\"}...],\"full_text\":\"...\"}"}Save to file:
curl -X POST "https://youtube-subtitles-downloader-api.p.rapidapi.com/download?url=https://www.youtube.com/watch?v=z_bX3runikk&format=json&language=en" \ -H "x-rapidapi-host: youtube-subtitles-downloader-api.p.rapidapi.com" \ -H "x-rapidapi-key: YOUR_RAPIDAPI_KEY" > subtitles.jsonExample 4: Plain Text Format
Section titled “Example 4: Plain Text Format”curl -X POST "https://youtube-subtitles-downloader-api.p.rapidapi.com/download?url=https://www.youtube.com/shorts/ivTdEQ6wseU&format=txt&language=en" \ -H "x-rapidapi-host: youtube-subtitles-downloader-api.p.rapidapi.com" \ -H "x-rapidapi-key: YOUR_RAPIDAPI_KEY"Save to file:
curl -X POST "https://youtube-subtitles-downloader-api.p.rapidapi.com/download?url=https://www.youtube.com/shorts/ivTdEQ6wseU&format=txt&language=en" \ -H "x-rapidapi-host: youtube-subtitles-downloader-api.p.rapidapi.com" \ -H "x-rapidapi-key: YOUR_RAPIDAPI_KEY" \ | grep -o '"subtitles":"[^"]*"' | sed 's/"subtitles":"//;s/"$//' | sed 's/\\n/\n/g' > subtitles.txtEndpoints
Section titled “Endpoints”API Information
Section titled “API Information”GET /Get API information and usage instructions.
Response:
{ "name": "YouTube Subtitles Downloader API", "version": "1.0.0", "description": "Download subtitles from any YouTube video in multiple formats.", "endpoints": { "POST /download": "Download subtitles from YouTube URL (use query parameters: ?url=VIDEO_URL&format=srt&language=en)", "GET /health": "Health check" }, "formats": ["srt", "vtt", "txt", "json"], "example": { "method": "POST", "endpoint": "/download?url=https://www.youtube.com/watch?v=ly6YKz9UfQ4&format=srt&language=en" }}Health Check
Section titled “Health Check”GET /healthCheck if the API is operational.
Response:
{ "status": "ok", "timestamp": 1704067200000}Download Subtitles
Section titled “Download Subtitles”POST /downloadExtract and download subtitles from a YouTube video.
Query Parameters Required
All parameters must be sent as query parameters in the URL, not in the request body.
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Full YouTube video URL |
format | string | No | Output format: srt, vtt, txt, json (default: srt) |
language | string | No | Language code (default: en) |
Successful Response (200 OK):
{ "success": true, "video_id": "dQw4w9WgXcQ", "video_title": "Rick Astley - Never Gonna Give You Up", "video_duration": 213, "language": "en", "format": "srt", "total_segments": 156, "total_characters": 2847, "processing_time_ms": 1234, "subtitles": "1\n00:00:00,000 --> 00:00:02,500\nWe're no strangers to love\n\n2\n00:00:02,500 --> 00:00:05,000\nYou know the rules and so do I\n..."}Response Fields:
| Field | Type | Description |
|---|---|---|
success | boolean | Whether the request was successful |
video_id | string | YouTube video ID |
video_title | string | Title of the video |
video_duration | integer | Video duration in seconds |
language | string | Language code of the subtitles |
format | string | Output format used |
total_segments | integer | Number of subtitle segments |
total_characters | integer | Total characters in subtitles |
processing_time_ms | integer | Processing time in milliseconds |
subtitles | string | The formatted subtitle content |
Output Formats
Section titled “Output Formats”SRT (SubRip)
Section titled “SRT (SubRip)”Standard subtitle format, widely supported by video players.
100:00:00,000 --> 00:00:02,500First subtitle line
200:00:02,500 --> 00:00:05,000Second subtitle lineVTT (WebVTT)
Section titled “VTT (WebVTT)”Web Video Text Tracks format, ideal for HTML5 video players.
WEBVTT
100:00:00.000 --> 00:00:02.500First subtitle line
200:00:02.500 --> 00:00:05.000Second subtitle lineTXT (Plain Text)
Section titled “TXT (Plain Text)”Simple text format with all subtitles concatenated.
First subtitle lineSecond subtitle lineThird subtitle lineStructured format with complete metadata and timing information.
{ "video_id": "dQw4w9WgXcQ", "video_title": "Rick Astley - Never Gonna Give You Up", "video_duration": 213, "language": "en", "total_segments": 156, "segments": [ { "start": 0, "duration": 2.5, "text": "We're no strangers to love" } ], "full_text": "Complete transcript..."}Supported YouTube URL Formats
Section titled “Supported YouTube URL Formats”The API accepts various YouTube URL formats:
https://www.youtube.com/watch?v=VIDEO_IDhttps://youtu.be/VIDEO_IDhttps://www.youtube.com/shorts/VIDEO_IDhttps://www.youtube.com/embed/VIDEO_IDhttps://www.youtube.com/v/VIDEO_ID
Language Support
Section titled “Language Support”The API supports all languages available on YouTube. Common language codes:
en- Englishes- Spanishfr- Frenchde- Germanit- Italianpt- Portugueseja- Japaneseko- Koreanzh- Chineseru- Russianar- Arabic
Error Responses
Section titled “Error Responses”400 Bad Request
Section titled “400 Bad Request”Missing URL:
{ "error": "URL is required as query parameter: ?url=VIDEO_URL&format=srt&language=en"}Invalid YouTube URL:
{ "error": "Invalid YouTube URL"}Invalid Format:
{ "error": "Invalid format. Valid formats: srt, vtt, txt, json"}401 Unauthorized
Section titled “401 Unauthorized”Missing or Invalid API Key:
{ "error": "Unauthorized"}500 Internal Server Error
Section titled “500 Internal Server Error”No Captions Available:
{ "success": false, "error": "Could not fetch subtitles: No captions available for this video", "video_id": "dQw4w9WgXcQ", "suggestion": "Make sure the video has captions/subtitles enabled in the requested language."}Pricing Plans
Section titled “Pricing Plans”Free (Basic)
Section titled “Free (Basic)”Perfect for testing and small projects
- Price: $0/month
- Monthly Requests: 300 (Hard Limit)
- Max Video Duration: Unlimited
- Support: Community
Ideal for individual developers
- Price: $4.99/month
- Monthly Requests: 5,000 (Hard Limit)
- Rate Limit: 100 requests/hour
- Max Video Duration: Unlimited
- Support: Email
Best for growing businesses
- Price: $14.99/month
- Monthly Requests: 25,000 (Hard Limit)
- Rate Limit: 200 requests/hour
- Max Video Duration: Unlimited
- Support: Priority Email
Enterprise-grade solution
- Price: $39.99/month
- Monthly Requests: 100,000 (Hard Limit)
- Rate Limit: 500 requests/hour
- Max Video Duration: Unlimited
Rate Limiting
Section titled “Rate Limiting”The API enforces rate limits based on your subscription plan. When you exceed the rate limit, you’ll receive a 429 Too Many Requests response.
Rate Limit Headers:
X-RateLimit-Limit: 100X-RateLimit-Remaining: 95X-RateLimit-Reset: 1704070800Best Practices
Section titled “Best Practices”1. Use Query Parameters
Section titled “1. Use Query Parameters”Always pass parameters in the URL as query parameters:
const videoUrl = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';const format = 'srt';const language = 'en';const apiUrl = `https://youtube-subtitles-downloader-api.p.rapidapi.com/download?url=${encodeURIComponent(videoUrl)}&format=${format}&language=${language}`;2. Cache Results
Section titled “2. Cache Results”Cache subtitle downloads to avoid redundant API calls for the same video.
3. Handle Errors Gracefully
Section titled “3. Handle Errors Gracefully”Always implement error handling for cases where subtitles are unavailable.
try { const response = await fetch(apiUrl, { method: 'POST', headers: { 'x-rapidapi-key': 'YOUR_KEY', 'x-rapidapi-host': 'youtube-subtitles-downloader-api.p.rapidapi.com' } });
const data = await response.json();
if (!data.success) { console.error('Subtitles not available:', data.error); }} catch (error) { console.error('Network error:', error);}4. Validate URLs Before Sending
Section titled “4. Validate URLs Before Sending”Verify YouTube URLs client-side before making API requests.
5. Use Appropriate Formats
Section titled “5. Use Appropriate Formats”- Use SRT for video players and editing software
- Use VTT for web video players
- Use TXT for quick text analysis
- Use JSON for programmatic processing and detailed metadata
6. Save Subtitles to File
Section titled “6. Save Subtitles to File”Extract the subtitles field from the response using grep and sed:
curl -X POST "https://youtube-subtitles-downloader-api.p.rapidapi.com/download?url=VIDEO_URL&format=srt&language=en" \ -H "x-rapidapi-key: YOUR_KEY" \ -H "x-rapidapi-host: youtube-subtitles-downloader-api.p.rapidapi.com" \ | grep -o '"subtitles":"[^"]*"' | sed 's/"subtitles":"//;s/"$//' | sed 's/\\n/\n/g' > subtitles.srtCode Examples
Section titled “Code Examples”JavaScript (Fetch)
Section titled “JavaScript (Fetch)”async function downloadSubtitles(videoUrl, format = 'srt', language = 'en') { const apiUrl = `https://youtube-subtitles-downloader-api.p.rapidapi.com/download?url=${encodeURIComponent(videoUrl)}&format=${format}&language=${language}`;
const response = await fetch(apiUrl, { method: 'POST', headers: { 'x-rapidapi-key': 'YOUR_RAPIDAPI_KEY', 'x-rapidapi-host': 'youtube-subtitles-downloader-api.p.rapidapi.com' } });
const data = await response.json();
if (data.success) { console.log(`Downloaded ${data.total_segments} segments`); return data.subtitles; } else { throw new Error(data.error); }}
downloadSubtitles('https://www.youtube.com/watch?v=z_bX3runikk') .then(subtitles => { console.log(subtitles); }) .catch(error => console.error(error));Python (Requests)
Section titled “Python (Requests)”import requests
def download_subtitles(video_url, format='srt', language='en'): url = f'https://youtube-subtitles-downloader-api.p.rapidapi.com/download?url={video_url}&format={format}&language={language}'
headers = { 'x-rapidapi-key': 'YOUR_RAPIDAPI_KEY', 'x-rapidapi-host': 'youtube-subtitles-downloader-api.p.rapidapi.com' }
response = requests.post(url, headers=headers) data = response.json()
if data.get('success'): print(f"Downloaded {data['total_segments']} segments") return data['subtitles'] else: raise Exception(data.get('error', 'Unknown error'))
subtitles = download_subtitles('https://www.youtube.com/watch?v=z_bX3runikk')print(subtitles)
with open('subtitles.srt', 'w', encoding='utf-8') as f: f.write(subtitles)Node.js (Axios)
Section titled “Node.js (Axios)”const axios = require('axios');
async function downloadSubtitles(videoUrl, format = 'srt', language = 'en') { try { const url = `https://youtube-subtitles-downloader-api.p.rapidapi.com/download?url=${encodeURIComponent(videoUrl)}&format=${format}&language=${language}`;
const response = await axios.post(url, null, { headers: { 'x-rapidapi-key': 'YOUR_RAPIDAPI_KEY', 'x-rapidapi-host': 'youtube-subtitles-downloader-api.p.rapidapi.com' } });
if (response.data.success) { console.log(`Downloaded ${response.data.total_segments} segments`); return response.data.subtitles; } } catch (error) { console.error('Error:', error.response?.data || error.message); throw error; }}
downloadSubtitles('https://www.youtube.com/shorts/ivTdEQ6wseU', 'srt') .then(subtitles => { const fs = require('fs'); fs.writeFileSync('subtitles.srt', subtitles, 'utf-8'); console.log('Subtitles saved to subtitles.srt'); }) .catch(console.error);<?php
function downloadSubtitles($videoUrl, $format = 'srt', $language = 'en') { $url = "https://youtube-subtitles-downloader-api.p.rapidapi.com/download?url=" . urlencode($videoUrl) . "&format={$format}&language={$language}";
$headers = [ 'x-rapidapi-key: YOUR_RAPIDAPI_KEY', 'x-rapidapi-host: youtube-subtitles-downloader-api.p.rapidapi.com' ];
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch); curl_close($ch);
$data = json_decode($response, true);
if ($data['success']) { echo "Downloaded {$data['total_segments']} segments\n"; return $data['subtitles']; } else { throw new Exception($data['error']); }}
$subtitles = downloadSubtitles('https://www.youtube.com/watch?v=z_bX3runikk');file_put_contents('subtitles.srt', $subtitles);echo "Subtitles saved to subtitles.srt\n";?>require 'net/http'require 'json'require 'uri'
def download_subtitles(video_url, format = 'srt', language = 'en') encoded_url = URI.encode_www_form_component(video_url) url = URI("https://youtube-subtitles-downloader-api.p.rapidapi.com/download?url=#{encoded_url}&format=#{format}&language=#{language}")
http = Net::HTTP.new(url.host, url.port) http.use_ssl = true
request = Net::HTTP::Post.new(url) request['x-rapidapi-key'] = 'YOUR_RAPIDAPI_KEY' request['x-rapidapi-host'] = 'youtube-subtitles-downloader-api.p.rapidapi.com'
response = http.request(request) data = JSON.parse(response.body)
if data['success'] puts "Downloaded #{data['total_segments']} segments" return data['subtitles'] else raise StandardError, data['error'] endend
subtitles = download_subtitles('https://www.youtube.com/watch?v=z_bX3runikk')File.write('subtitles.srt', subtitles)puts 'Subtitles saved to subtitles.srt'Use Cases
Section titled “Use Cases”Content Creation
Section titled “Content Creation”- Generate subtitles for accessibility
- Translate video content
- Create closed captions for social media
Education
Section titled “Education”- Extract lecture transcripts
- Create study materials
- Build searchable video databases
Research & Analysis
Section titled “Research & Analysis”- Analyze video content at scale
- Extract data from educational videos
- Content categorization and indexing
Development
Section titled “Development”- Build video search engines
- Create subtitle editing tools
- Develop language learning applications
Q: Why do I need to use query parameters instead of request body?
A: All parameters must be passed in the URL as query parameters for the API to work correctly.
Q: Do I need to URL-encode the YouTube URL?
A: Yes, it’s recommended to use encodeURIComponent() in JavaScript or equivalent in other languages to properly encode the URL.
Q: What happens if a video doesn’t have subtitles?
A: The API will return an error indicating that no captions are available for the video.
Q: Can I download auto-generated subtitles?
A: Yes, the API supports both manual and auto-generated YouTube captions.
Q: Are there any restrictions on video length?
A: No, all plans support unlimited video duration.
Q: Does it work with YouTube Shorts?
A: Yes! The API works with both regular YouTube videos and YouTube Shorts.
Q: How accurate are the subtitles?
A: The accuracy depends on YouTube’s caption quality. Manual captions are more accurate than auto-generated ones.
Q: Can I use this for commercial projects?
A: Yes, all plans can be used for commercial purposes according to our terms of service.
Q: What’s the maximum number of requests I can make?
A: Each plan has specific monthly and hourly limits. Check the pricing section for details.
Q: How do I save the subtitles to a file?
A: Extract the subtitles field from the JSON response using grep and sed (shown in examples above), or use the code examples provided for your preferred programming language.
Support
Section titled “Support”Need help? We’re here for you:
- Email: support@cliperly.com
Terms of Use
Section titled “Terms of Use”By using this API, you agree to:
- Use the service only through RapidAPI
- Not exceed your plan’s rate limits
- Not abuse or attempt to bypass restrictions
- Comply with YouTube’s Terms of Service
- Use downloaded subtitles in accordance with copyright laws
Last updated: October 2025