transcriptapi
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTranscriptAPI
TranscriptAPI
Full YouTube data toolkit via TranscriptAPI.com. Transcripts, search, channels, playlists — one API key.
通过TranscriptAPI.com提供的完整YouTube数据工具包。字幕、搜索、频道、播放列表——一个API密钥即可搞定。
Setup
设置
If is not set, help the user create an account (100 free credits, no card):
$TRANSCRIPT_API_KEYStep 1 — Register: Ask user for their email.
bash
node ./scripts/tapi-auth.js register --email USER_EMAIL→ OTP sent to email. Ask user: "Check your email for a 6-digit verification code."
Step 2 — Verify: Once user provides the OTP:
bash
node ./scripts/tapi-auth.js verify --token TOKEN_FROM_STEP_1 --otp CODEAPI key saved to your shell profile and agent config. Ready to use.
Manual option: transcriptapi.com/signup → Dashboard → API Keys.
如果未设置,帮助用户创建账户(100个免费额度,无需信用卡):
$TRANSCRIPT_API_KEY步骤1 — 注册: 询问用户的邮箱。
bash
node ./scripts/tapi-auth.js register --email USER_EMAIL→ 验证码(OTP)将发送至邮箱。询问用户:“请查看您的邮箱获取6位验证码。”
步骤2 — 验证: 用户提供OTP后:
bash
node ./scripts/tapi-auth.js verify --token TOKEN_FROM_STEP_1 --otp CODEAPI密钥将保存到您的shell配置和代理配置中。即可开始使用。
手动注册选项:transcriptapi.com/signup → 控制台 → API密钥。
API Reference
API参考
Full OpenAPI spec: transcriptapi.com/openapi.json — consult this for the latest parameters and schemas.
完整OpenAPI规范:transcriptapi.com/openapi.json——请以此为准获取最新参数和数据结构。
Auth
身份验证
All requests:
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"所有请求需携带:
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"Endpoints
接口端点
Channel endpoints accept — an , channel URL, or ID. No need to resolve first. Playlist endpoints accept — a playlist URL or ID.
channel@handleUC...playlist频道类端点接受参数——可以是@用户名、频道链接或格式的ID,无需提前解析。播放列表类端点接受参数——可以是播放列表链接或ID。
channelUC...playlistGET /api/v2/youtube/transcript — 1 credit
GET /api/v2/youtube/transcript — 1个额度
bash
curl -s "https://transcriptapi.com/api/v2/youtube/transcript\
?video_url=VIDEO_URL&format=text&include_timestamp=true&send_metadata=true" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"| Param | Required | Default | Validation |
|---|---|---|---|
| yes | — | YouTube URL or 11-char video ID |
| no | | |
| no | | |
| no | | |
Accepts: , , , or bare .
https://youtube.com/watch?v=IDhttps://youtu.be/IDyoutube.com/shorts/IDIDResponse ():
format=jsonjson
{
"video_id": "dQw4w9WgXcQ",
"language": "en",
"transcript": [
{ "text": "We're no strangers...", "start": 18.0, "duration": 3.5 }
],
"metadata": { "title": "...", "author_name": "...", "author_url": "..." }
}bash
curl -s "https://transcriptapi.com/api/v2/youtube/transcript\
?video_url=VIDEO_URL&format=text&include_timestamp=true&send_metadata=true" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"| 参数 | 是否必填 | 默认值 | 验证规则 |
|---|---|---|---|
| 是 | — | YouTube链接或11位视频ID |
| 否 | | |
| 否 | | |
| 否 | | |
支持的输入格式:、、或纯ID。
https://youtube.com/watch?v=IDhttps://youtu.be/IDyoutube.com/shorts/ID响应():
format=jsonjson
{
"video_id": "dQw4w9WgXcQ",
"language": "en",
"transcript": [
{ "text": "We're no strangers...", "start": 18.0, "duration": 3.5 }
],
"metadata": { "title": "...", "author_name": "...", "author_url": "..." }
}GET /api/v2/youtube/search — 1 credit
GET /api/v2/youtube/search — 1个额度
bash
curl -s "https://transcriptapi.com/api/v2/youtube/search?q=QUERY&type=video&limit=20" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"| Param | Required | Default | Validation |
|---|---|---|---|
| yes | — | 1-200 chars (trimmed) |
| no | | |
| no | | 1-50 |
Response ():
type=videojson
{
"results": [
{
"type": "video",
"videoId": "dQw4w9WgXcQ",
"title": "Rick Astley - Never Gonna Give You Up",
"channelId": "UCuAXFkgsw1L7xaCfnd5JJOw",
"channelTitle": "Rick Astley",
"channelHandle": "@RickAstley",
"channelVerified": true,
"lengthText": "3:33",
"viewCountText": "1.5B views",
"publishedTimeText": "14 years ago",
"hasCaptions": true,
"thumbnails": [{ "url": "...", "width": 120, "height": 90 }]
}
],
"result_count": 20
}Response ():
type=channeljson
{
"results": [
{
"type": "channel",
"channelId": "UCuAXFkgsw1L7xaCfnd5JJOw",
"title": "Rick Astley",
"handle": "@RickAstley",
"subscriberCount": "4.2M subscribers",
"verified": true,
"rssUrl": "https://www.youtube.com/feeds/videos.xml?channel_id=UC..."
}
],
"result_count": 5
}bash
curl -s "https://transcriptapi.com/api/v2/youtube/search?q=QUERY&type=video&limit=20" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"| 参数 | 是否必填 | 默认值 | 验证规则 |
|---|---|---|---|
| 是 | — | 1-200字符(自动去首尾空格) |
| 否 | | |
| 否 | | 1-50 |
响应():
type=videojson
{
"results": [
{
"type": "video",
"videoId": "dQw4w9WgXcQ",
"title": "Rick Astley - Never Gonna Give You Up",
"channelId": "UCuAXFkgsw1L7xaCfnd5JJOw",
"channelTitle": "Rick Astley",
"channelHandle": "@RickAstley",
"channelVerified": true,
"lengthText": "3:33",
"viewCountText": "1.5B views",
"publishedTimeText": "14 years ago",
"hasCaptions": true,
"thumbnails": [{ "url": "...", "width": 120, "height": 90 }]
}
],
"result_count": 20
}响应():
type=channeljson
{
"results": [
{
"type": "channel",
"channelId": "UCuAXFkgsw1L7xaCfnd5JJOw",
"title": "Rick Astley",
"handle": "@RickAstley",
"subscriberCount": "4.2M subscribers",
"verified": true,
"rssUrl": "https://www.youtube.com/feeds/videos.xml?channel_id=UC..."
}
],
"result_count": 5
}GET /api/v2/youtube/channel/resolve — FREE (0 credits)
GET /api/v2/youtube/channel/resolve — 免费(0额度)
bash
curl -s "https://transcriptapi.com/api/v2/youtube/channel/resolve?input=@TED" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"| Param | Required | Validation |
|---|---|---|
| yes | 1-200 chars — @handle, URL, or UC... ID |
Response:
json
{ "channel_id": "UCsT0YIqwnpJCM-mx7-gSA4Q", "resolved_from": "@TED" }If input is already a valid ID, returns immediately without lookup.
UC[a-zA-Z0-9_-]{22}bash
curl -s "https://transcriptapi.com/api/v2/youtube/channel/resolve?input=@TED" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"| 参数 | 是否必填 | 验证规则 |
|---|---|---|
| 是 | 1-200字符——@用户名、链接或UC...格式ID |
响应:
json
{ "channel_id": "UCsT0YIqwnpJCM-mx7-gSA4Q", "resolved_from": "@TED" }如果输入已经是有效的格式ID,将直接返回结果,无需查询。
UC[a-zA-Z0-9_-]{22}GET /api/v2/youtube/channel/videos — 1 credit/page
GET /api/v2/youtube/channel/videos — 1个额度/页
bash
undefinedbash
undefinedFirst page (100 videos)
第一页(100个视频)
curl -s "https://transcriptapi.com/api/v2/youtube/channel/videos?channel=@NASA"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
curl -s "https://transcriptapi.com/api/v2/youtube/channel/videos?channel=@NASA"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
Next pages
后续页面
curl -s "https://transcriptapi.com/api/v2/youtube/channel/videos?continuation=TOKEN"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
| Param | Required | Validation |
| -------------- | ----------- | --------------------------------------------- |
| `channel` | conditional | `@handle`, channel URL, or `UC...` ID |
| `continuation` | conditional | non-empty string (next pages) |
Provide exactly one of `channel` or `continuation`.
**Response:**
```json
{
"results": [{
"videoId": "abc123xyz00",
"title": "Latest Video",
"channelId": "UCsT0YIqwnpJCM-mx7-gSA4Q",
"channelTitle": "TED",
"channelHandle": "@TED",
"lengthText": "15:22",
"viewCountText": "3.2M views",
"thumbnails": [...],
"index": "0"
}],
"playlist_info": {"title": "Uploads from TED", "numVideos": "5000"},
"continuation_token": "4qmFsgKlARIYVVV1...",
"has_more": true
}curl -s "https://transcriptapi.com/api/v2/youtube/channel/videos?continuation=TOKEN"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
| 参数 | 是否必填 | 验证规则 |
| -------------- | ----------- | --------------------------------------------- |
| `channel` | 可选(二选一) | `@用户名`、频道链接或UC...格式ID |
| `continuation` | 可选(二选一) | 非空字符串(用于获取后续页面) |
必须提供`channel`或`continuation`其中一个参数。
**响应:**
```json
{
"results": [{
"videoId": "abc123xyz00",
"title": "Latest Video",
"channelId": "UCsT0YIqwnpJCM-mx7-gSA4Q",
"channelTitle": "TED",
"channelHandle": "@TED",
"lengthText": "15:22",
"viewCountText": "3.2M views",
"thumbnails": [...],
"index": "0"
}],
"playlist_info": {"title": "Uploads from TED", "numVideos": "5000"},
"continuation_token": "4qmFsgKlARIYVVV1...",
"has_more": true
}GET /api/v2/youtube/channel/latest — FREE (0 credits)
GET /api/v2/youtube/channel/latest — 免费(0额度)
bash
curl -s "https://transcriptapi.com/api/v2/youtube/channel/latest?channel=@TED" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"| Param | Required | Validation |
|---|---|---|
| yes | |
Returns last 15 videos via RSS with exact view counts and ISO timestamps.
Response:
json
{
"channel": {
"channelId": "...",
"title": "TED",
"author": "TED",
"url": "..."
},
"results": [
{
"videoId": "abc123xyz00",
"title": "Latest Video",
"published": "2026-01-30T16:00:00Z",
"viewCount": "2287630",
"description": "Full description...",
"thumbnail": { "url": "...", "width": "480", "height": "360" }
}
],
"result_count": 15
}bash
curl -s "https://transcriptapi.com/api/v2/youtube/channel/latest?channel=@TED" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"| 参数 | 是否必填 | 验证规则 |
|---|---|---|
| 是 | |
通过RSS返回最新15个视频,包含精确播放量和ISO时间戳。
响应:
json
{
"channel": {
"channelId": "...",
"title": "TED",
"author": "TED",
"url": "..."
},
"results": [
{
"videoId": "abc123xyz00",
"title": "Latest Video",
"published": "2026-01-30T16:00:00Z",
"viewCount": "2287630",
"description": "Full description...",
"thumbnail": { "url": "...", "width": "480", "height": "360" }
}
],
"result_count": 15
}GET /api/v2/youtube/channel/search — 1 credit
GET /api/v2/youtube/channel/search — 1个额度
bash
curl -s "https://transcriptapi.com/api/v2/youtube/channel/search\
?channel=@TED&q=climate+change&limit=30" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"| Param | Required | Validation |
|---|---|---|
| yes | |
| yes | 1-200 chars |
| no | 1-50 (default 30) |
bash
curl -s "https://transcriptapi.com/api/v2/youtube/channel/search\
?channel=@TED&q=climate+change&limit=30" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"| 参数 | 是否必填 | 验证规则 |
|---|---|---|
| 是 | |
| 是 | 1-200字符 |
| 否 | 1-50(默认30) |
GET /api/v2/youtube/playlist/videos — 1 credit/page
GET /api/v2/youtube/playlist/videos — 1个额度/页
bash
undefinedbash
undefinedFirst page
第一页
curl -s "https://transcriptapi.com/api/v2/youtube/playlist/videos?playlist=PL_PLAYLIST_ID"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
curl -s "https://transcriptapi.com/api/v2/youtube/playlist/videos?playlist=PL_PLAYLIST_ID"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
Next pages
后续页面
curl -s "https://transcriptapi.com/api/v2/youtube/playlist/videos?continuation=TOKEN"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
| Param | Required | Validation |
| -------------- | ----------- | ---------------------------------------------------- |
| `playlist` | conditional | Playlist URL or ID (`PL`/`UU`/`LL`/`FL`/`OL` prefix) |
| `continuation` | conditional | non-empty string |curl -s "https://transcriptapi.com/api/v2/youtube/playlist/videos?continuation=TOKEN"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
| 参数 | 是否必填 | 验证规则 |
| -------------- | ----------- | ---------------------------------------------------- |
| `playlist` | 可选(二选一) | 播放列表链接或ID(前缀为`PL`/`UU`/`LL`/`FL`/`OL`) |
| `continuation` | 可选(二选一) | 非空字符串 |Credit Costs
额度消耗
| Endpoint | Cost |
|---|---|
| transcript | 1 |
| search | 1 |
| channel/resolve | free |
| channel/search | 1 |
| channel/videos | 1/page |
| channel/latest | free |
| playlist/videos | 1/page |
| 端点 | 消耗额度 |
|---|---|
| transcript | 1 |
| search | 1 |
| channel/resolve | 免费 |
| channel/search | 1 |
| channel/videos | 1/页 |
| channel/latest | 免费 |
| playlist/videos | 1/页 |
Errors
错误码说明
| Code | Meaning | Action |
|---|---|---|
| 401 | Bad API key | Check key, re-run setup |
| 402 | No credits | Top up at transcriptapi.com/billing |
| 404 | Not found | Video/channel/playlist doesn't exist or no captions |
| 408 | Timeout/retryable | Retry once after 2s |
| 422 | Validation error | Check param format |
| 429 | Rate limited | Wait, respect Retry-After |
| 状态码 | 含义 | 处理方式 |
|---|---|---|
| 401 | API密钥无效 | 检查密钥,重新执行设置流程 |
| 402 | 额度不足 | 前往transcriptapi.com/billing充值 |
| 404 | 资源不存在 | 视频/频道/播放列表不存在或无字幕 |
| 408 | 请求超时(可重试) | 等待2秒后重试一次 |
| 422 | 参数验证失败 | 检查参数格式 |
| 429 | 请求频率超限 | 等待,遵循Retry-After响应头指示 |
Tips
使用技巧
- When user shares YouTube URL with no instruction, fetch transcript and summarize key points.
- Use (free) to check for new uploads before fetching transcripts — pass @handle directly.
channel/latest - For research: search → pick videos → fetch transcripts.
- Free tier: 100 credits, 300 req/min. Starter ($5/mo): 1,000 credits, 300 req/min.
- 当用户仅分享YouTube链接未说明需求时,自动获取字幕并总结要点。
- 使用免费的接口检查新上传视频后再获取字幕——可直接传入@用户名。
channel/latest - 研究场景流程:搜索→选择视频→获取字幕。
- 免费版:100个额度,每分钟300次请求。基础版(5美元/月):1000个额度,每分钟300次请求。