名称: transcriptapi
描述: 完整的 TranscriptAPI 工具包 — 获取 YouTube 字幕、搜索视频和频道、浏览频道上传内容、获取最新视频、探索播放列表。当用户希望以编程方式处理 YouTube 内容、获取用于摘要或分析的字幕、查找视频或监控频道时使用。触发词:YouTube URL、"transcript"、"transcriptapi"、"video summary"、"what did they say"、"find videos about"、"search youtube"。
主页: https://transcriptapi.com
user-invocable: true
元数据: {"openclaw":{"emoji":"📺","requires":{"env":["TRANSCRIPT_API_KEY"],"bins":["node"],"config":["~/.openclaw/openclaw.json"]},"primaryEnv":"TRANSCRIPT_API_KEY"}}
通过 TranscriptAPI.com 提供的完整 YouTube 数据工具包。字幕、搜索、频道、播放列表 — 一个 API 密钥即可。
如果未设置 $TRANSCRIPT_API_KEY,请帮助用户创建账户(100 个免费积分,无需信用卡):
步骤 1 — 注册: 向用户询问其邮箱。
node ./scripts/tapi-auth.js register --email 用户邮箱
→ OTP 将发送至邮箱。询问用户:"请检查您的邮箱,获取 6 位验证码。"
步骤 2 — 验证: 用户提供 OTP 后:
node ./scripts/tapi-auth.js verify --token 步骤1的令牌 --otp 验证码
API 密钥将保存至
~/.openclaw/openclaw.json。详情请参阅下方的文件写入部分。修改前会备份现有文件。
手动选项:transcriptapi.com/signup → 仪表板 → API 密钥。
验证和保存密钥命令会将 API 密钥保存到 ~/.openclaw/openclaw.json(设置 skills.entries.transcriptapi.apiKey 和 enabled: true)。修改前,现有文件会备份到 ~/.openclaw/openclaw.json.bak。
若要在代理之外的终端/CLI 中使用此 API 密钥,请手动将其添加到 shell 配置文件中:
export TRANSCRIPT_API_KEY=<你的密钥>
完整 OpenAPI 规范:transcriptapi.com/openapi.json — 请查阅此文件以获取最新的参数和模式。
所有请求:-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
频道端点接受 channel 参数 — 可以是 @句柄、频道 URL 或 UC... ID。无需预先解析。播放列表端点接受 playlist 参数 — 可以是播放列表 URL 或 ID。
curl -s "https://transcriptapi.com/api/v2/youtube/transcript\
?video_url=视频URL&format=text&include_timestamp=true&send_metadata=true" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
| 参数 | 必需 | 默认值 | 验证规则 |
|---|---|---|---|
video_url |
是 | — | YouTube URL 或 11 位视频 ID |
format |
否 | json |
json 或 text |
include_timestamp |
否 | true |
true 或 false |
send_metadata |
否 | false |
true 或 false |
接受格式:https://youtube.com/watch?v=ID, https://youtu.be/ID, youtube.com/shorts/ID, 或纯 ID。
响应 (format=json):
{
"video_id": "dQw4w9WgXcQ",
"language": "en",
"transcript": [
{ "text": "We're no strangers...", "start": 18.0, "duration": 3.5 }
],
"metadata": { "title": "...", "author_name": "...", "author_url": "..." }
}
curl -s "https://transcriptapi.com/api/v2/youtube/search?q=查询词&type=video&limit=20" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
| 参数 | 必需 | 默认值 | 验证规则 |
|---|---|---|---|
q |
是 | — | 1-200 个字符(自动修剪) |
type |
否 | video |
video 或 channel |
limit |
否 | 20 |
1-50 |
响应 (type=video):
{
"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):
{
"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
}
curl -s "https://transcriptapi.com/api/v2/youtube/channel/resolve?input=@TED" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
| 参数 | 必需 | 验证规则 |
|---|---|---|
input |
是 | 1-200 个字符 — @句柄、URL 或 UC... ID |
响应:
{ "channel_id": "UCsT0YIqwnpJCM-mx7-gSA4Q", "resolved_from": "@TED" }
如果输入已经是有效的 UC[a-zA-Z0-9_-]{22} ID,则立即返回,无需查询。
# 第一页 (100 个视频)
curl -s "https://transcriptapi.com/api/v2/youtube/channel/videos?channel=@NASA" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
# 后续页
curl -s "https://transcriptapi.com/api/v2/youtube/channel/videos?continuation=令牌" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
| 参数 | 必需条件 | 验证规则 |
|---|---|---|
channel |
条件性 | @句柄、频道 URL 或 UC... ID |
continuation |
条件性 | 非空字符串(用于后续页) |
必须且仅提供 channel 或 continuation 中的一个。
响应:
{
"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/latest?channel=@TED" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
| 参数 | 必需 | 验证规则 |
|---|---|---|
channel |
是 | @句柄、频道 URL 或 UC... ID |
通过 RSS 返回最后 15 个视频,包含精确的观看次数和 ISO 时间戳。
响应:
{
"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
}
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) |
# 第一页
curl -s "https://transcriptapi.com/api/v2/youtube/playlist/videos?playlist=PL_播放列表_ID" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
# 后续页
curl -s "https://transcriptapi.com/api/v2/youtube/playlist/videos?continuation=令牌" \
-H "Authorization: Bearer $TRANSCRIPT_API_KEY"
| 参数 | 必需条件 | 验证规则 |
|---|---|---|
playlist |
条件性 | 播放列表 URL 或 ID (PL/UU/LL/FL/OL 前缀) |
continuation |
条件性 | 非空字符串 |
| 端点 | 成本 |
|---|---|
| transcript | 1 |
| search | 1 |
| channel/resolve | 免费 |
| channel/search | 1 |
| channel/videos | 1/页 |
| channel/latest | 免费 |
| playlist/videos | 1/页 |
| 代码 | 含义 | 处理建议 |
|---|---|---|
| 401 | API 密钥错误 | 检查密钥,重新运行设置 |
| 402 | 积分不足 | 前往 transcriptapi.com/billing 充值 |
| 404 | 未找到 | 视频/频道/播放列表不存在或无字幕 |
| 408 | 超时/可重试 | 等待 2 秒后重试一次 |
| 422 | 参数验证错误 | 检查参数格式 |
| 429 | 请求频率受限 | 等待,遵循 Retry-After 头部 |
channel/latest(免费)在获取字幕前检查新上传内容 — 可直接传递 @句柄。