youtube-search

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

YouTube Search

YouTube搜索

Search YouTube and fetch transcripts via TranscriptAPI.com.
通过TranscriptAPI.com搜索YouTube内容并获取视频字幕。

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 — 验证: 用户提供验证码后执行以下命令:
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 — 请参考此文档获取最新的参数和结构定义。

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"
ParamRequiredDefaultValidation
q
yes1-200 chars (trimmed)
type
no
video
video
or
channel
limit
no
20
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=channel
):
json
{
  "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"
参数必填默认值校验规则
q
1-200个字符(自动去除首尾空格)
type
video
可选值为
video
channel
limit
20
取值范围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=channel
):
json
{
  "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
channel
— an
@handle
, channel URL, or
UC...
ID.
bash
curl -s "https://transcriptapi.com/api/v2/youtube/channel/search\
?channel=@TED&q=climate+change&limit=30" \
  -H "Authorization: Bearer $TRANSCRIPT_API_KEY"
ParamRequiredValidation
channel
yes
@handle
, channel URL, or
UC...
ID
q
yes1-200 chars
limit
no1-50 (default 30)
Returns up to ~30 results (YouTube limit). Same video response shape as global search.
在指定频道内搜索视频。支持传入
channel
参数,值可以是
@用户名
、频道URL或
UC...
格式的频道ID。
bash
curl -s "https://transcriptapi.com/api/v2/youtube/channel/search\
?channel=@TED&q=climate+change&limit=30" \
  -H "Authorization: Bearer $TRANSCRIPT_API_KEY"
参数必填校验规则
channel
支持
@用户名
、频道URL或
UC...
格式的频道ID
q
1-200个字符
limit
取值范围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
undefined
bash
undefined

1. 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"
curl -s "https://transcriptapi.com/api/v2/youtube/search\ ?q=python+web+scraping&type=video&limit=5"
-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"
undefined
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"
undefined

Errors

错误码说明

CodeAction
402No credits — transcriptapi.com/billing
404Not found
408Timeout — retry once
422Invalid channel identifier
Free tier: 100 credits, 300 req/min.
错误码处理方式
402额度不足 — 请前往transcriptapi.com/billing充值
404资源未找到
408请求超时 — 可重试一次
422频道标识符无效
免费套餐:100个额度,每分钟最多300次请求。