Loading...
Loading...
Compare original and translation side by side
https://youtubetranscript.dev/api/v2Authorization: Bearer YOUR_API_KEYhttps://youtubetranscript.dev/api/v2Authorization: Bearer YOUR_API_KEY| Method | Endpoint | Description |
|---|---|---|
| | Extract transcript from a single video |
| | Extract transcripts from up to 100 videos |
| | Check status of an ASR job |
| | Check status of a batch request |
| 方法 | 端点 | 描述 |
|---|---|---|
| | 提取单个视频的字幕 |
| | 提取最多100个视频的字幕 |
| | 检查ASR任务状态 |
| | 检查批量请求状态 |
| Field | Required | Description |
|---|---|---|
| Yes (single) | YouTube URL or 11-character video ID |
| Yes (batch) | Array of IDs or URLs (up to 100) |
| No | ISO 639-1 code (e.g., |
| No | |
| No | |
| No | URL for async delivery (required for |
| 字段 | 是否必填 | 描述 |
|---|---|---|
| 是(单个视频) | YouTube URL或11位视频ID |
| 是(批量) | ID或URL数组(最多100个) |
| 否 | ISO 639-1代码(例如 |
| 否 | |
| 否 | |
| 否 | 异步交付结果的URL(当 |
| Method | Cost | Speed |
|---|---|---|
| Native Captions | 1 credit | 5–10 seconds |
| Translation | 1 credit per 2,500 chars | 5–10 seconds |
| ASR (Audio) | 1 credit per 90 seconds | 2–20 minutes (async) |
| 方式 | 成本 | 速度 |
|---|---|---|
| 原生字幕 | 1积分 | 5–10秒 |
| 翻译 | 每2500字符1积分 | 5–10秒 |
| ASR(音频) | 每90秒1积分 | 2–20分钟(异步) |
import requests
API_KEY = "your_api_key"
response = requests.post(
"https://youtubetranscript.dev/api/v2/transcribe",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json={"video": "dQw4w9WgXcQ"}
)
data = response.json()
for segment in data["data"]["transcript"]:
print(f"[{segment['start']:.1f}s] {segment['text']}")import requests
API_KEY = "your_api_key"
response = requests.post(
"https://youtubetranscript.dev/api/v2/transcribe",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json={"video": "dQw4w9WgXcQ"}
)
data = response.json()
for segment in data["data"]["transcript"]:
print(f"[{segment['start']:.1f}s] {segment['text']}")const response = await fetch("https://youtubetranscript.dev/api/v2/transcribe", {
method: "POST",
headers: {
Authorization: `Bearer ${API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ video: "dQw4w9WgXcQ" }),
});
const { data } = await response.json();
console.log(data.transcript);const response = await fetch("https://youtubetranscript.dev/api/v2/transcribe", {
method: "POST",
headers: {
Authorization: `Bearer ${API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ video: "dQw4w9WgXcQ" }),
});
const { data } = await response.json();
console.log(data.transcript);npm install youtube-audio-transcript-apiimport { YouTubeTranscript } from "youtube-audio-transcript-api";
const yt = new YouTubeTranscript({ apiKey: "your_api_key" });
// Simple extraction
const result = await yt.getTranscript("dQw4w9WgXcQ");
// With translation
const translated = await yt.transcribe({
video: "dQw4w9WgXcQ",
language: "es",
});
// Batch (up to 100 videos)
const batch = await yt.batch({
video_ids: ["dQw4w9WgXcQ", "jNQXAC9IVRw", "9bZkp7q19f0"],
});npm install youtube-audio-transcript-apiimport { YouTubeTranscript } from "youtube-audio-transcript-api";
const yt = new YouTubeTranscript({ apiKey: "your_api_key" });
// 简单提取
const result = await yt.getTranscript("dQw4w9WgXcQ");
// 带翻译的提取
const translated = await yt.transcribe({
video: "dQw4w9WgXcQ",
language: "es",
});
// 批量处理(最多100个视频)
const batch = await yt.batch({
video_ids: ["dQw4w9WgXcQ", "jNQXAC9IVRw", "9bZkp7q19f0"],
});curl -X POST https://youtubetranscript.dev/api/v2/transcribe \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"video": "dQw4w9WgXcQ"}'curl -X POST https://youtubetranscript.dev/api/v2/transcribe \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"video": "dQw4w9WgXcQ"}'curl -X POST https://youtubetranscript.dev/api/v2/batch \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"video_ids": ["dQw4w9WgXcQ", "jNQXAC9IVRw", "9bZkp7q19f0"]}'curl -X POST https://youtubetranscript.dev/api/v2/batch \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"video_ids": ["dQw4w9WgXcQ", "jNQXAC9IVRw", "9bZkp7q19f0"]}'"language": "es"curl -X POST https://youtubetranscript.dev/api/v2/transcribe \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"video": "dQw4w9WgXcQ", "language": "es"}'"language": "es"curl -X POST https://youtubetranscript.dev/api/v2/transcribe \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"video": "dQw4w9WgXcQ", "language": "es"}'curl -X POST https://youtubetranscript.dev/api/v2/transcribe \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"video": "VIDEO_ID", "source": "asr", "webhook_url": "https://yoursite.com/webhook"}'status: "processing"GET /api/v2/jobs/{job_id}curl -X POST https://youtubetranscript.dev/api/v2/transcribe \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"video": "VIDEO_ID", "source": "asr", "webhook_url": "https://yoursite.com/webhook"}'status: "processing"GET /api/v2/jobs/{job_id}| HTTP Status | Error Code | Description |
|---|---|---|
| 400 | | Invalid JSON or missing required fields |
| 401 | | Missing or invalid API key |
| 402 | | Insufficient credits |
| 404 | | No captions available and ASR not used |
| 429 | | Too many requests — check |
| HTTP状态码 | 错误代码 | 描述 |
|---|---|---|
| 400 | | JSON无效或缺少必填字段 |
| 401 | | API密钥缺失或无效 |
| 402 | | 积分不足 |
| 404 | | 无可用字幕且未使用ASR |
| 429 | | 请求过于频繁 — 请查看 |
languagelanguage