YouTube 频道内搜索 API
POST
接口健康状态
- 24h 健康值
- 正常
- 健康 / 正常
- 可用
正常
24 小时趋势
30 天趋势
频道内搜索:返回列表,每次一页、每页最多 30 条,条数不固定(短页不代表到底),要更多就把响应顶层的 next_page_token 作为 page_token 再调,没有 next_page_token 才是到底;limit 照收但不起作用;主要字段 type、id、url、title、text、author_name。支持翻页:把响应里的 next_page_token 作为 page_token 传回拿下一页,其他参数不变,每页算一次调用。
请求发到 POST https://api.everyinfra.com/api/v1/social,platform 填 youtube,action 填 search_in_channel。 单价 $0.56 / 千次(每次 $0.000556),失败和空结果都不收费。 同步返回;慢任务可在请求体加 "mode": "async",先拿 job_id 再轮询。
AI 提示词
#请帮我用 EveryInfra 的「YouTube 频道内搜索」接口(youtube/search_in_channel)写一个数据采集脚本。
接口约定:
- 请求:POST https://api.everyinfra.com/api/v1/social,请求头 Authorization: Bearer <API Key>;Key 从环境变量 EVERYINFRA_API_KEY 读取,不要写进代码。
- 请求体里 platform 填 youtube,action 填 search_in_channel,参数放在 params 里。
- 必填参数:
- url:YouTube 频道链接(youtube.com/@NASA、youtube.com/channel/UC…),也可以只给 @用户名或 UC 开头的频道编号。只在这个频道里搜。
- keyword:搜索词,最多 200 个字;结果里有视频、Shorts 和播放列表,看每行的 type。
- 可选参数:
- page_token:翻页令牌。第一页不传;响应有 next_page_token 时原样作 page_token 传回,其他参数不变。一页约 30 条,按 YouTube 给的整页,limit 不起作用。每页算一次调用。
- 返回一组记录,每条记录的主要字段:type、id、url、title、text、author_name、author_username、author_id、author_url、author_avatar_url、author_is_verified(频道有没有认证标记)、view_count;一共 20 个字段,完整列表见 https://api.everyinfra.com/api/v1/social/catalog?platform=youtube。
- 示例请求体:
{
"platform": "youtube",
"action": "search_in_channel",
"params": {
"url": "https://www.youtube.com/@NASA",
"keyword": "moon"
}
}
- 计费:$0.56 / 千次;失败和空结果不扣费。
- 一次要采几十上百个时,在请求体加 "mode": "async":先拿到 job_id,再轮询 GET https://api.everyinfra.com/api/v1/jobs/{job_id} 取结果。
- 返回 422 时,按错误信息里的候选参数和允许值修正;返回 429 或 503 时,按 Retry-After 等待后重试。
写代码前,先问清楚我要采哪些对象、一共多少个、需要哪些字段、结果存成什么格式,再把方案和大概花费讲给我确认。请求参数
#| 参数名 | 位置 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|---|
Authorization | header | string | 是 | - | Bearer 加你的 API Key。在控制台创建;不要放进网址或代码仓库。 |
platform | body | string | 是 | youtube | 平台标识,固定值。 |
action | body | string | 是 | search_in_channel | 能力标识,固定值。 |
url | body.params | string | 是 | - | YouTube 频道链接(youtube.com/@NASA、youtube.com/channel/UC…),也可以只给 @用户名或 UC 开头的频道编号。只在这个频道里搜。 |
keyword | body.params | string | 是 | - | 搜索词,最多 200 个字;结果里有视频、Shorts 和播放列表,看每行的 type。 |
page_token | body.params | string | 否 | - | 翻页令牌。第一页不传;响应有 next_page_token 时原样作 page_token 传回,其他参数不变。一页约 30 条,按 YouTube 给的整页,limit 不起作用。每页算一次调用;令牌 24 小时有效。没有 next_page_token 就是翻不下去了。 |
代码示例
#bash
curl -X POST 'https://api.everyinfra.com/api/v1/social' \
-H "Authorization: Bearer $EVERYINFRA_API_KEY" \
-H 'Content-Type: application/json' \
--data-raw '{
"platform": "youtube",
"action": "search_in_channel",
"params": {
"url": "https://www.youtube.com/@NASA",
"keyword": "moon"
}
}'OpenAPI 定义 (JSON)示例从环境变量 EVERYINFRA_API_KEY 读取 Key,复制出去的代码不含你的 Key。
url 填频道链接,keyword 填要在这个频道里搜的词。
响应示例
#2026年11月21日 15:24(北京时间)用上方代码示例的参数真实调用所得。results 与 count 是那次的真实返回,已隐去名字、账号、头像、主页链接、联系方式等个人信息,列表只保留前 2 条;id、billing、quota 每次调用都不同,只给结构。
json
{ "id": "req_…", "platform": "youtube", "action": "search_in_channel", "results": [ { "type": "video", "id": "IfRqrrBbT-Y", "url": "https://www.youtube.com/watch?v=IfRqrrBbT-Y", "title": "Artemis II Moon Mission Complete!", "text": "Our Artemis II Moon mission is complete!\nSpace Launch System rocket launched crew into space\nOrion spacecraft provided a safe “home away from home” for astronauts\nFlew around the Moon,...", "author_name": "NASA", "author_username": "NASA", "author_id": "•••", "author_url": "https://www.youtube.com/@NASA", "author_avatar_url": "https://yt3.googleusercontent.com/•••", "author_is_verified": true, "view_count": 987902, "duration": "00:03:33", "published_text": "7 months ago", "thumbnail_url": "https://i.ytimg.com/vi/IfRqrrBbT-Y/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLB1B1sNNE_AOGy5LPLeaDP38ZN80A", "badges": [ "CC" ], "platform": "youtube" }, { "type": "video", "id": "Vg-EQ7MOu6I", "url": "https://www.youtube.com/watch?v=Vg-EQ7MOu6I", "title": "Around the Moon for All Humanity: Artemis II (Official Launch Trailer)", "text": "Action. Wonder. Adventure. Artemis II has got it all. Don't miss the moment. Our crewed Moon mission will launch as early as April 1.\n\nUnder Artemis, NASA will send astronauts on increasingly...", "author_name": "NASA", "author_username": "NASA", "author_id": "•••", "author_url": "https://www.youtube.com/@NASA", "author_avatar_url": "https://yt3.googleusercontent.com/•••", "author_is_verified": true, "view_count": 1650126, "duration": "00:01:16", "published_text": "7 months ago", "thumbnail_url": "https://i.ytimg.com/vi/Vg-EQ7MOu6I/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLAwlAQUzbi1WhsHnEROLKj3nvYryA", "badges": [ "CC" ], "platform": "youtube" } ], "next_page_token": …, "pagination": { … }, "count": 30, "billing": { "charged": …, "charged_usd": …, "balance_after_usd": …, … }, "quota": { … }}
返回字段
#业务数据在 results 里;下表是每条记录可能包含的字段,平台没有提供的值不会被编造。
| 字段 | 含义 |
|---|---|
type | 记录类型,取值随能力而定(如 video / image / text)。 |
id | 该记录在原平台上的唯一标识。仅在同一平台内唯一,跨平台可能重复。 |
url | 该记录在原平台上的可访问链接。 |
title | 标题。平台无标题概念时(如纯文本帖)为 null。 |
text | 正文内容,已去除 HTML 标签,全文返回、不截断(个别平台的列表结果本身只有摘要,以该平台的字段说明为准)。 |
author_name | 作者昵称(显示名)。 |
author_username | 作者用户名(@handle),通常可用于拼 URL。 |
author_id | 作者在原平台的唯一 ID。 |
author_url | 作者在原平台的主页链接。 |
author_avatar_url | 作者头像图片链接(多数平台带签名、会过期)。 |
author_is_verified | 频道有没有认证标记。 |
view_count | 浏览/播放数。null 表示不公开,不等于 0。 |
duration | 时长。 |
published_text | YouTube 页面上写的发布时间,是相对说法(如 2 years ago),原样给;页面没写是 null。 |
thumbnail_url | 缩略图链接,分辨率低于 image_url。 |
badges | 视频上的角标,文字数组,如 4K、CC、New;没有是空数组。 |
is_live | 是不是正在直播。 |
is_upcoming | 是不是还没开始的首映或预约直播。 |
playlist_id | 这一行是播放列表或合辑时的列表编号,否则是 null。 |
video_count | 视频数。 |
platform | 数据来源平台标识,与请求里的 platform 一致(如 xiaohongshu、tiktok)。 |
错误与计费
#- 401
- 缺少 Key 或 Key 无效。
- 402
- 余额不足,先充值。
- 422
- 参数名或取值不对,按错误信息给的候选改;不扣费。
- 429
- 超过每分钟请求上限,按 Retry-After 等待后再试。
- 503
- 暂时无法完成,预扣的费用退回;结果未知时先核对,不要直接重发。
- 200 空结果
- 没有数据,不扣费。