youtube-api
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseYouTube API
YouTube API
YouTube data access via TranscriptAPI.com — no Google API quota needed.
通过TranscriptAPI.com访问YouTube数据——无需Google 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配置文件及Agent配置中,即可开始使用。
手动注册选项:访问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——请查阅该文档获取最新参数与数据结构。
Endpoint Reference
端点参考
All endpoints:
https://transcriptapi.com/api/v2/youtube/...Channel endpoints accept — an , channel URL, or ID. Playlist endpoints accept — a playlist URL or ID.
channel@handleUC...playlist| Endpoint | Method | Cost |
|---|---|---|
| GET | 1 |
| GET | 1 |
| GET | free |
| GET | free |
| GET | 1/page |
| GET | 1 |
| GET | 1/page |
所有端点地址:
https://transcriptapi.com/api/v2/youtube/...频道类端点接受参数——可以是、频道URL或格式的ID。播放列表类端点接受参数——可以是播放列表URL或ID。
channel@用户名UC...playlist| 端点地址 | 请求方法 | 消耗额度 |
|---|---|---|
| GET | 1 |
| GET | 1 |
| GET | 免费 |
| GET | 免费 |
| GET | 1/每页 |
| GET | 1 |
| GET | 1/每页 |
Quick Examples
快速示例
Search videos:
bash
curl -s "https://transcriptapi.com/api/v2/youtube/search\
?q=python+tutorial&type=video&limit=10" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"Get transcript:
bash
curl -s "https://transcriptapi.com/api/v2/youtube/transcript\
?video_url=dQw4w9WgXcQ&format=text&include_timestamp=true&send_metadata=true" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"Resolve channel handle (free):
bash
curl -s "https://transcriptapi.com/api/v2/youtube/channel/resolve?input=@TED" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"Latest videos (free):
bash
curl -s "https://transcriptapi.com/api/v2/youtube/channel/latest?channel=@TED" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"Browse channel uploads (paginated):
bash
curl -s "https://transcriptapi.com/api/v2/youtube/channel/videos?channel=@NASA" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"搜索视频:
bash
curl -s "https://transcriptapi.com/api/v2/youtube/search\
?q=python+tutorial&type=video&limit=10" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"获取字幕:
bash
curl -s "https://transcriptapi.com/api/v2/youtube/transcript\
?video_url=dQw4w9WgXcQ&format=text&include_timestamp=true&send_metadata=true" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"解析频道用户名(免费):
bash
curl -s "https://transcriptapi.com/api/v2/youtube/channel/resolve?input=@TED" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"获取最新视频(免费):
bash
curl -s "https://transcriptapi.com/api/v2/youtube/channel/latest?channel=@TED" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"浏览频道上传视频(分页):
bash
curl -s "https://transcriptapi.com/api/v2/youtube/channel/videos?channel=@NASA" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"Use continuation token from response for next pages
使用响应中的continuation token获取下一页内容
**Browse playlist (paginated):**
```bash
curl -s "https://transcriptapi.com/api/v2/youtube/playlist/videos?playlist=PL_PLAYLIST_ID" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
**浏览播放列表(分页):**
```bash
curl -s "https://transcriptapi.com/api/v2/youtube/playlist/videos?playlist=PL_PLAYLIST_ID" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"Parameter Validation
参数验证规则
| Field | Rule |
|---|---|
| |
| Playlist URL or ID ( |
| 1-200 chars |
| 1-50 |
| non-empty string |
| 字段 | 规则说明 |
|---|---|
| 支持 |
| 支持播放列表URL或带 |
| 长度为1-200个字符 |
| 取值范围1-50 |
| 非空字符串 |
Why Not Google's API?
为何不使用Google官方API?
| Google YouTube Data API | TranscriptAPI | |
|---|---|---|
| Quota | 10,000 units/day (100 searches) | Credit-based, no daily cap |
| Setup | OAuth + API key + project | Single API key |
| Transcripts | Not available | Core feature |
| Pricing | $0.0015/unit overage | $5/1000 credits |
| 对比项 | Google YouTube Data API | TranscriptAPI |
|---|---|---|
| 配额限制 | 每日10,000单位(约100次搜索) | 基于额度计费,无每日上限 |
| 配置流程 | OAuth授权 + API密钥 + 项目创建 | 仅需单个API密钥 |
| 字幕支持 | 不提供 | 核心功能 |
| 定价 | 超额部分0.0015美元/单位 | 5美元/1000额度 |
Errors
错误码说明
| Code | Meaning | Action |
|---|---|---|
| 401 | Bad API key | Check key |
| 402 | No credits | transcriptapi.com/billing |
| 404 | Not found | Resource doesn't exist |
| 408 | Timeout/retryable | Retry once after 2s |
| 422 | Validation error | Check param format |
| 429 | Rate limited | Wait, respect Retry-After |
Free tier: 100 credits, 300 req/min. Starter ($5/mo): 1,000 credits.
| 错误码 | 含义 | 处理建议 |
|---|---|---|
| 401 | API密钥无效 | 检查密钥是否正确 |
| 402 | 额度不足 | 前往transcriptapi.com/billing充值 |
| 404 | 资源不存在 | 确认资源是否存在 |
| 408 | 请求超时/可重试 | 等待2秒后重试一次 |
| 422 | 参数验证失败 | 检查参数格式是否符合要求 |
| 429 | 请求频率超限 | 等待一段时间,遵循Retry-After响应头提示 |
免费额度:100额度,每分钟300次请求。基础版(5美元/月):1000额度。