YouTube 频道帖子 API
POST
接口健康状态
- 24h 健康值
- 正常
- 健康 / 正常
- 可用
正常
24 小时趋势
30 天趋势
频道帖子:返回列表,每次一页、固定 10 条(最后一页可能更少),要更多就把响应顶层的 next_page_token 作为 page_token 再调;limit 照收但不起作用;主要字段 id、url、text、author_name、author_username、author_id。支持翻页:把响应里的 next_page_token 作为 page_token 传回拿下一页,其他参数不变,每页算一次调用。
请求发到 POST https://api.everyinfra.com/api/v1/social,platform 填 youtube,action 填 community_posts。 单价 $0.56 / 千次(每次 $0.000556),失败和空结果都不收费。 同步返回;慢任务可在请求体加 "mode": "async",先拿 job_id 再轮询。
AI 提示词
#请帮我用 EveryInfra 的「YouTube 频道帖子」接口(youtube/community_posts)写一个数据采集脚本。
接口约定:
- 请求:POST https://api.everyinfra.com/api/v1/social,请求头 Authorization: Bearer <API Key>;Key 从环境变量 EVERYINFRA_API_KEY 读取,不要写进代码。
- 请求体里 platform 填 youtube,action 填 community_posts,参数放在 params 里。
- 必填参数:
- url:YouTube 频道链接(youtube.com/@NASA、youtube.com/channel/UC…),也可以只给 @用户名或 UC 开头的频道编号。返回频道「帖子」页里的帖子,新的在前。
- 可选参数:
- page_token:翻页令牌。第一页不传;响应有 next_page_token 时原样作 page_token 传回,其他参数不变。一页 10 条,limit 不起作用。每页算一次调用;令牌 24 小时有效。
- 返回一组记录,每条记录的主要字段:id、url、text、author_name、author_username、author_id、author_url、author_avatar_url、like_count、comment_count、published_text(YouTube 页面上写的发布时间)、attachment_type(帖子带了什么:image 一张图、…);一共 18 个字段,完整列表见 https://api.everyinfra.com/api/v1/social/catalog?platform=youtube。
- 示例请求体:
{
"platform": "youtube",
"action": "community_posts",
"params": {
"url": "https://www.youtube.com/@MrBeast"
}
}
- 计费:$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 | 是 | community_posts | 能力标识,固定值。 |
url | body.params | string | 是 | - | YouTube 频道链接(youtube.com/@NASA、youtube.com/channel/UC…),也可以只给 @用户名或 UC 开头的频道编号。返回频道「帖子」页里的帖子,新的在前。 |
page_token | body.params | string | 否 | - | 翻页令牌。第一页不传;响应有 next_page_token 时原样作 page_token 传回,其他参数不变。一页 10 条,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": "community_posts",
"params": {
"url": "https://www.youtube.com/@MrBeast"
}
}'OpenAPI 定义 (JSON)示例从环境变量 EVERYINFRA_API_KEY 读取 Key,复制出去的代码不含你的 Key。
响应示例
#2026年11月21日 15:24(北京时间)用上方代码示例的参数真实调用所得。results 与 count 是那次的真实返回,已隐去名字、账号、头像、主页链接、联系方式等个人信息,列表只保留前 2 条;id、billing、quota 每次调用都不同,只给结构。
json
{ "id": "req_…", "platform": "youtube", "action": "community_posts", "results": [ { "id": "UgkxIkDHJ9iW7XmjtMbke3Ud7rEiV5jSHDnR", "url": "https://www.youtube.com/post/UgkxIkDHJ9iW7XmjtMbke3Ud7rEiV5jSHDnR", "text": "Hunger Games In Real Life drops on Saturday!\nWe designed custom suits that detect when they’re hit by magnetic foam weapons 👀", "author_name": "MrBeast", "author_username": "MrBeast", "author_id": "•••", "author_url": "https://www.youtube.com/@MrBeast", "author_avatar_url": "https://yt3.googleusercontent.com/•••", "like_count": 307000, "comment_count": 6200, "published_text": "10 days ago", "attachment_type": "multi_image", "image_urls": [ "https://yt3.ggpht.com/-nihmRU8RGnrkkYNC73Y_eRRp03ReHeIdKSE8oqRy-HOu0dfZ-7Y5ND61lI9CS3Thlec0shis6WGXQ=s1400-c-fcrop64=1,00001000ffffefff-rw-nd-v1", "https://yt3.ggpht.com/g2LFXicy-wjSH-5pvMPnOnp0YHZXO0VaOzf8Y9yws0OFoH2yQjx_1abszLqWNv6f7BoJ3VnXmB6S=s1400-c-fcrop64=1,00001000ffffefff-rw-nd-v1" ], "platform": "youtube" }, { "id": "Ugkx2lkCYp85jak0n5z7-bq_4ug2Rntk9iWT", "url": "https://www.youtube.com/post/Ugkx2lkCYp85jak0n5z7-bq_4ug2Rntk9iWT", "text": "These last two videos are the best content we’ve ever made and somehow our next 3 uploads are even better. (The team is cooking) I’m feeling more excited and energized about our videos than ever before, new era of Beast coming up 🥰", "author_name": "MrBeast", "author_username": "MrBeast", "author_id": "•••", "author_url": "https://www.youtube.com/@MrBeast", "author_avatar_url": "https://yt3.googleusercontent.com/•••", "like_count": 175000, "comment_count": 5000, "published_text": "1 month ago", "attachment_type": "image", "image_urls": [ "https://yt3.ggpht.com/9davaq2roo2vRpZ80IIGBiCAy6CmeYfm17AkJbLofKYVreyWRk9Y3SF2tcHwTpdGSzRXym9Y_6096A=s988-c-fcrop64=1,00c60000ff39ffff-rw-nd-v1" ], "platform": "youtube" } ], "next_page_token": …, "pagination": { … }, "count": 10, "billing": { "charged": …, "charged_usd": …, "balance_after_usd": …, … }, "quota": { … }}
返回字段
#业务数据在 results 里;下表是每条记录可能包含的字段,平台没有提供的值不会被编造。
| 字段 | 含义 |
|---|---|
id | 该记录在原平台上的唯一标识。仅在同一平台内唯一,跨平台可能重复。 |
url | 该记录在原平台上的可访问链接。 |
text | 正文内容,已去除 HTML 标签,全文返回、不截断(个别平台的列表结果本身只有摘要,以该平台的字段说明为准)。 |
author_name | 作者昵称(显示名)。 |
author_username | 作者用户名(@handle),通常可用于拼 URL。 |
author_id | 作者在原平台的唯一 ID。 |
author_url | 作者在原平台的主页链接。 |
author_avatar_url | 作者头像图片链接(多数平台带签名、会过期)。 |
like_count | 点赞数。null 表示该平台或该接口不公开此数据,不等于 0。 |
comment_count | 评论数。null 表示不公开,不等于 0。 |
published_text | YouTube 页面上写的发布时间,是相对说法(如 2 years ago),原样给;页面没写是 null。 |
attachment_type | 帖子带了什么:image 一张图、multi_image 多张图、video 视频、poll 投票;只有文字是 null。 |
image_urls | 图片链接数组,按平台展示顺序;没有图片时不出现这个字段。 |
video_id | 所属视频的编号;帖子评论的回复里是 null。频道帖子里是帖子附带的那条视频的编号,没附视频是 null。 |
video_title | 帖子附带的那条视频的标题,没附视频是 null。 |
poll_options | 投票的选项,文字数组;不是投票帖是空数组。 |
poll_total_votes | 投票的总票数,整数(YouTube 页面给的是约数,如 1.8M 记作 1800000);不是投票帖是 null。 |
links | 帖子正文里的链接,数组。 |
platform | 数据来源平台标识,与请求里的 platform 一致(如 xiaohongshu、tiktok)。 |
错误与计费
#- 401
- 缺少 Key 或 Key 无效。
- 402
- 余额不足,先充值。
- 422
- 参数名或取值不对,按错误信息给的候选改;不扣费。
- 429
- 超过每分钟请求上限,按 Retry-After 等待后再试。
- 503
- 暂时无法完成,预扣的费用退回;结果未知时先核对,不要直接重发。
- 200 空结果
- 没有数据,不扣费。