youtube-api

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

YouTube API

YouTube API

YouTube data access via TranscriptAPI.com — no Google API quota needed.
通过TranscriptAPI.com访问YouTube数据——无需Google API配额。

Setup

设置步骤

If
$TRANSCRIPT_API_KEY
is not set, help the user create an account (100 free credits, no card):
Step 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 CODE
API key saved to your shell profile and agent config. Ready to use.
Manual option: transcriptapi.com/signup → Dashboard → API Keys.
如果未设置
$TRANSCRIPT_API_KEY
,请协助用户创建账号(100免费额度,无需绑定银行卡):
步骤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 CODE
API密钥将保存至你的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
channel
— an
@handle
, channel URL, or
UC...
ID. Playlist endpoints accept
playlist
— a playlist URL or ID.
EndpointMethodCost
/transcript?video_url=ID
GET1
/search?q=QUERY&type=video
GET1
/channel/resolve?input=@handle
GETfree
/channel/latest?channel=@handle
GETfree
/channel/videos?channel=@handle
GET1/page
/channel/search?channel=@handle&q=Q
GET1
/playlist/videos?playlist=PL_ID
GET1/page
所有端点地址:
https://transcriptapi.com/api/v2/youtube/...
频道类端点接受
channel
参数——可以是
@用户名
、频道URL或
UC...
格式的ID。播放列表类端点接受
playlist
参数——可以是播放列表URL或ID。
端点地址请求方法消耗额度
/transcript?video_url=ID
GET1
/search?q=QUERY&type=video
GET1
/channel/resolve?input=@handle
GET免费
/channel/latest?channel=@handle
GET免费
/channel/videos?channel=@handle
GET1/每页
/channel/search?channel=@handle&q=Q
GET1
/playlist/videos?playlist=PL_ID
GET1/每页

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

参数验证规则

FieldRule
channel
@handle
, channel URL, or
UC...
ID
playlist
Playlist URL or ID (
PL
/
UU
/
LL
/
FL
/
OL
prefix)
q
(search)
1-200 chars
limit
1-50
continuation
non-empty string
字段规则说明
channel
支持
@用户名
、频道URL或
UC...
格式的ID
playlist
支持播放列表URL或带
PL
/
UU
/
LL
/
FL
/
OL
前缀的ID
q
(搜索关键词)
长度为1-200个字符
limit
取值范围1-50
continuation
非空字符串

Why Not Google's API?

为何不使用Google官方API?

Google YouTube Data APITranscriptAPI
Quota10,000 units/day (100 searches)Credit-based, no daily cap
SetupOAuth + API key + projectSingle API key
TranscriptsNot availableCore feature
Pricing$0.0015/unit overage$5/1000 credits
对比项Google YouTube Data APITranscriptAPI
配额限制每日10,000单位(约100次搜索)基于额度计费,无每日上限
配置流程OAuth授权 + API密钥 + 项目创建仅需单个API密钥
字幕支持不提供核心功能
定价超额部分0.0015美元/单位5美元/1000额度

Errors

错误码说明

CodeMeaningAction
401Bad API keyCheck key
402No creditstranscriptapi.com/billing
404Not foundResource doesn't exist
408Timeout/retryableRetry once after 2s
422Validation errorCheck param format
429Rate limitedWait, respect Retry-After
Free tier: 100 credits, 300 req/min. Starter ($5/mo): 1,000 credits.
错误码含义处理建议
401API密钥无效检查密钥是否正确
402额度不足前往transcriptapi.com/billing充值
404资源不存在确认资源是否存在
408请求超时/可重试等待2秒后重试一次
422参数验证失败检查参数格式是否符合要求
429请求频率超限等待一段时间,遵循Retry-After响应头提示
免费额度:100额度,每分钟300次请求。基础版(5美元/月):1000额度。