youtube-search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseYouTube Search
YouTube搜索
Search YouTube and fetch transcripts via TranscriptAPI.com.
通过TranscriptAPI.com搜索YouTube内容并获取视频字幕。
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 — 验证: 用户提供验证码后执行以下命令:
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 — 请参考此文档获取最新的参数和结构定义。
GET /api/v2/youtube/search — 1 credit
GET /api/v2/youtube/search — 消耗1个额度
Search YouTube globally for videos or channels.
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 |
Video search response:
json
{
"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
}Channel search response ():
type=channeljson
{
"results": [{
"type": "channel",
"channelId": "UCuAXFkgsw1L7xaCfnd5JJOw",
"title": "Rick Astley",
"handle": "@RickAstley",
"url": "https://www.youtube.com/@RickAstley",
"description": "Official channel...",
"subscriberCount": "4.2M subscribers",
"verified": true,
"rssUrl": "https://www.youtube.com/feeds/videos.xml?channel_id=UC...",
"thumbnails": [...]
}],
"result_count": 5
}全局搜索YouTube的视频或频道。
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 |
视频搜索响应示例:
json
{
"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",
"url": "https://www.youtube.com/@RickAstley",
"description": "Official channel...",
"subscriberCount": "4.2M subscribers",
"verified": true,
"rssUrl": "https://www.youtube.com/feeds/videos.xml?channel_id=UC...",
"thumbnails": [...]
}],
"result_count": 5
}GET /api/v2/youtube/channel/search — 1 credit
GET /api/v2/youtube/channel/search — 消耗1个额度
Search videos within a specific channel. Accepts — an , channel URL, or ID.
channel@handleUC...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) |
Returns up to ~30 results (YouTube limit). Same video response shape as global search.
在指定频道内搜索视频。支持传入参数,值可以是、频道URL或格式的频道ID。
channel@用户名UC...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) |
最多返回约30条结果(YouTube限制),返回的视频数据结构与全局搜索一致。
GET /api/v2/youtube/channel/resolve — FREE
GET /api/v2/youtube/channel/resolve — 免费
Convert @handle to channel ID:
bash
curl -s "https://transcriptapi.com/api/v2/youtube/channel/resolve?input=@TED" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"将@用户名转换为频道ID:
bash
curl -s "https://transcriptapi.com/api/v2/youtube/channel/resolve?input=@TED" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"Workflow: Search → Transcript
工作流:搜索 → 获取字幕
bash
undefinedbash
undefined1. Search for videos
1. 搜索视频
curl -s "https://transcriptapi.com/api/v2/youtube/search\
?q=python+web+scraping&type=video&limit=5"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
curl -s "https://transcriptapi.com/api/v2/youtube/search\
?q=python+web+scraping&type=video&limit=5"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
2. Get transcript from result
2. 根据搜索结果获取字幕
curl -s "https://transcriptapi.com/api/v2/youtube/transcript\
?video_url=VIDEO_ID&format=text&include_timestamp=true&send_metadata=true"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
undefinedcurl -s "https://transcriptapi.com/api/v2/youtube/transcript\
?video_url=VIDEO_ID&format=text&include_timestamp=true&send_metadata=true"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
undefinedErrors
错误码说明
| Code | Action |
|---|---|
| 402 | No credits — transcriptapi.com/billing |
| 404 | Not found |
| 408 | Timeout — retry once |
| 422 | Invalid channel identifier |
Free tier: 100 credits, 300 req/min.
| 错误码 | 处理方式 |
|---|---|
| 402 | 额度不足 — 请前往transcriptapi.com/billing充值 |
| 404 | 资源未找到 |
| 408 | 请求超时 — 可重试一次 |
| 422 | 频道标识符无效 |
免费套餐:100个额度,每分钟最多300次请求。