ClawSkills logoClawSkills

Youtube Channels

处理 YouTube 频道——将句柄解析为 ID,浏览上传内容,获取最新视频,在频道内搜索。当用户询问特定频道时使用。

介绍

# YouTube Channels

通过 [TranscriptAPI.com](https://transcriptapi.com) 提供的 YouTube 频道工具。

## 设置

如果未设置 `$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 密钥已保存至 `~/.openclaw/openclaw.json`。详情请参阅下方的 **文件写入**。修改前会备份现有文件。

手动选项:[transcriptapi.com/signup](https://transcriptapi.com/signup) → Dashboard → API Keys。

## 文件写入

验证和保存密钥命令会将 API 密钥保存到 `~/.openclaw/openclaw.json`(设置 `skills.entries.transcriptapi.apiKey` 和 `enabled: true`)。**修改前会将现有文件备份到 `~/.openclaw/openclaw.json.bak`。**

要在代理之外的终端/CLI 中使用该 API 密钥,请手动将其添加到您的 Shell 配置文件中: `export TRANSCRIPT_API_KEY=<your-key>`

## API 参考

完整的 OpenAPI 规范:[transcriptapi.com/openapi.json](https://transcriptapi.com/openapi.json) — 请查阅此文档以获取最新的参数和架构。

所有频道端点都接受灵活的输入格式 — `@handle`(句柄)、频道 URL 或 `UC...` 频道 ID。无需预先解析。

## GET /api/v2/youtube/channel/resolve — 免费

将 @handle、URL 或 UC... ID 转换为规范频道 ID。

```bash curl -s "https://transcriptapi.com/api/v2/youtube/channel/resolve?input=@TED" \ -H "Authorization: Bearer $TRANSCRIPT_API_KEY" ```

| 参数 | 是否必需 | 验证规则 | | -------- | -------- | ----------------------------------------- | | `input` | 是 | 1-200 个字符 — @handle、URL 或 UC... ID |

**响应:**

```json { "channel_id": "UCsT0YIqwnpJCM-mx7-gSA4Q", "resolved_from": "@TED" } ```

如果输入已经是 `UC[a-zA-Z0-9_-]{22}`,则立即返回。

## GET /api/v2/youtube/channel/latest — 免费

通过 RSS 获取最新的 15 个视频,包含精确的统计数据。

```bash curl -s "https://transcriptapi.com/api/v2/youtube/channel/latest?channel=@TED" \ -H "Authorization: Bearer $TRANSCRIPT_API_KEY" ```

| 参数 | 是否必需 | 验证规则 | | --------- | -------- | ----------------------------------------- | | `channel` | 是 | `@handle`、频道 URL 或 `UC...` ID |

**响应:**

```json { "channel": { "channelId": "UCsT0YIqwnpJCM-mx7-gSA4Q", "title": "TED", "author": "TED", "url": "https://www.youtube.com/channel/UCsT0YIqwnpJCM-mx7-gSA4Q", "published": "2006-04-17T00:00:00Z" }, "results": [ { "videoId": "abc123xyz00", "title": "Latest Video Title", "channelId": "UCsT0YIqwnpJCM-mx7-gSA4Q", "author": "TED", "published": "2026-01-30T16:00:00Z", "updated": "2026-01-31T02:00:00Z", "link": "https://www.youtube.com/watch?v=abc123xyz00", "description": "Full video description...", "thumbnail": { "url": "https://i1.ytimg.com/vi/.../hqdefault.jpg" }, "viewCount": "2287630", "starRating": { "average": "4.92", "count": "15000", "min": "1", "max": "5" } } ], "result_count": 15 } ```

非常适合监控频道 — 免费且提供准确的观看次数和 ISO 时间戳。

## GET /api/v2/youtube/channel/videos — 1 积分/页

所有频道上传内容的分页列表(每页 100 个)。

```bash # First page curl -s "https://transcriptapi.com/api/v2/youtube/channel/videos?channel=@NASA" \ -H "Authorization: Bearer $TRANSCRIPT_API_KEY"

# Next pages curl -s "https://transcriptapi.com/api/v2/youtube/channel/videos?continuation=TOKEN" \ -H "Authorization: Bearer $TRANSCRIPT_API_KEY" ```

| 参数 | 是否必需 | 验证规则 | | --------------- | ---------- | ----------------------------------------- | | `channel` | 条件必需 | `@handle`、频道 URL 或 `UC...` ID | | `continuation` | 条件必需 | 非空(用于后续页面) |

请提供 `channel` 或 `continuation` 中的任意一个,不要同时提供。

**响应:**

```json { "results": [{ "videoId": "abc123xyz00", "title": "Video Title", "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", "ownerName": "TED"}, "continuation_token": "4qmFsgKlARIYVVV1...", "has_more": true } ```

使用 `continuation` 继续调用,直到 `has_more: false`。

## GET /api/v2/youtube/channel/search — 1 积分

在特定频道内搜索。

```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` | 是 | `@handle`、频道 URL 或 `UC...` ID | | `q` | 是 | 1-200 个字符 | | `limit` | 否 | 1-50(默认 30) |

## 典型工作流程

```bash # 1. Check latest uploads (free — pass @handle directly) curl -s "https://transcriptapi.com/api/v2/youtube/channel/latest?channel=@TED" \ -H "Authorization: Bearer $TRANSCRIPT_API_KEY"

# 2. Get transcript of recent video 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" ```

## 错误

| 代码 | 操作 | | ---- | ------------------------------------------------------------ | | 400 | 无效的参数组合(同时或均未提供 channel/continuation) | | 402 | 积分不足 — transcriptapi.com/billing | | 404 | 未找到频道 | | 408 | 超时 — 重试一次 | | 422 | 无效的频道标识符 |

免费层:100 个积分,300 请求/分钟。免费端点(resolve、latest)需要身份验证但不消耗积分。

更多产品