API Documentation
Extract YouTube transcripts programmatically. SSE streaming, timestamps, speaker detection, and caching built in.
Programmatic access
The TubeScript API provides programmatic access to YouTube video transcription. Send a YouTube URL and receive timestamped transcript segments via a real-time SSE stream or a single JSON response. Each segment includes the text, start time, duration, and optional speaker identification.
Transcripts are generated using Gemini AI and cached for 7 days. Cached responses are returned instantly. The API handles video processing, audio extraction, and text formatting so your application does not have to.
API keys
API access requires a Team plan subscription ($29/month). After subscribing, you can generate an API key from your account dashboard.
Include your API key in the Authorization header of every request as a Bearer token.
Transcript request
/api/transcriptSubmit a YouTube URL for transcription. Set stream: true for real-time SSE delivery or omit it for a single JSON response.
Request Body
{
"url": "https://youtube.com/watch?v=VIDEO_ID",
"language": "en",
"stream": true
}Parameters
urlstringrequiredlanguagestringstreambooleanSSE response format
When stream: true, the API returns a Server-Sent Events stream with three event types:
event: metadata
data: {
"video_id": "dQw4w9WgXcQ",
"video_title": "Video Title",
"channel_name": "Channel Name",
"video_duration": 212,
"language": "en",
"cached": false
}event: segment
data: {
"start": 0,
"duration": 4.2,
"text": "First segment of the transcript",
"speaker": "Speaker 1"
}event: done
data: {
"word_count": 1847,
"read_time_minutes": 8,
"ai_transcribed": true,
"permalink": "https://tubescript.cc/transcript/dQw4w9WgXcQ"
}JSON response format
When streaming is disabled (default), the API returns a single JSON object after the transcript is fully processed.
{
"success": true,
"data": {
"video_id": "dQw4w9WgXcQ",
"video_title": "Video Title",
"channel_name": "Channel Name",
"video_duration": 212,
"language": "en",
"is_auto_generated": true,
"ai_transcribed": true,
"word_count": 1847,
"read_time_minutes": 8,
"segments": [
{
"start": 0,
"duration": 4.2,
"text": "First segment of the transcript",
"speaker": "Speaker 1"
}
],
"cached": false,
"permalink": "https://tubescript.cc/transcript/dQw4w9WgXcQ"
}
}Rate limits
Rate limits reset at midnight UTC. Free tier usage is tracked by IP address. Cached transcripts do not count against your limit.
Code examples
curl -X POST https://tubescript.cc/api/transcript \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://youtube.com/watch?v=dQw4w9WgXcQ", "stream": false}'const response = await fetch(
"https://tubescript.cc/api/transcript",
{
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
url: "https://youtube.com/watch?v=dQw4w9WgXcQ",
stream: true
})
}
);
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const text = decoder.decode(value);
const lines = text.split("\n");
for (const line of lines) {
if (line.startsWith("data: ")) {
const data = JSON.parse(line.slice(6));
console.log(data);
}
}
}import requests
import json
response = requests.post(
"https://tubescript.cc/api/transcript",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json={
"url": "https://youtube.com/watch?v=dQw4w9WgXcQ",
"stream": True
},
stream=True
)
for line in response.iter_lines():
if line:
decoded = line.decode("utf-8")
if decoded.startswith("data: "):
data = json.loads(decoded[6:])
print(data)Error codes
Error response format
{
"success": false,
"error": {
"code": "RATE_LIMITED",
"message": "You've used all 2 free transcripts today.",
"reset_at": "2026-02-15T00:00:00.000Z"
}
}Ready to integrate?
Get your API key with the Team plan. Unlimited web transcripts plus 100 API requests per day.
View Pricing