# YouTube 用户内容 API (youtube.user_posts)

- Canonical page: https://everyinfra.com/youtube-api/user_posts
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "youtube", "action": "user_posts", "params": {...}}
- Price: $0.000556 per call ($0.56 per 1,000 requests); failed calls and empty results are not charged
- Returns: list, default 10, max 50 per call
- Mode: sync; add "mode": "async" for slow tasks

YouTube 用户内容按频道 `url` 列出这个频道的常规视频，每条带标题、简介、播放点赞评论数、时长、发布时间、话题标签，以及是否会员专享 `is_members_only`、是否含付费推广 `is_paid_partnership`；频道的订阅数、视频总数和总播放量也随行返回。它回答「这个频道发了什么、哪些视频跑得好」，常用于竞品频道监测、达人筛选和内容复盘。

用 `sort` 选最新、最早或热门，用 `since` 只看某个日期之后发布的视频。Shorts 不在这里，要读请用 Shorts 短视频。不传 `limit` 时读 10 条，单次最多 50 条。`author_view_count` 是频道总播放量。

## Health

- Live health (24h percent, hourly and daily trends): https://api.everyinfra.com/api/v1/social/availability?platform=youtube&action=user_posts

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| url | not declared | yes | not declared | YouTube 频道 URL，用于列出该频道的常规视频；Shorts 请用 shorts 动作。 |
| since | not declared | no | not declared | 频道视频的最早发布日期，格式 YYYY-MM-DD；只用于 user_posts 列表。 |
| sort | enum: newest / oldest / popular | no | not declared | 频道视频排序：newest 最新、oldest 最早、popular 热门。 |
| limit | integer (1–50) | no | 10 | 这次调用最多返回的条数，整数，1–50；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| url | 该记录在原平台上的可访问链接。 |
| title | 标题。平台无标题概念时（如纯文本帖）为 null。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| author_name | 作者昵称（显示名）。 |
| author_username | 作者用户名（@handle），通常可用于拼 URL。 |
| author_id | 作者在原平台的唯一 ID。 |
| author_url | 作者在原平台的主页链接。 |
| like_count | 点赞数。null 表示该平台或该接口不公开此数据，不等于 0。 |
| comment_count | 评论数。null 表示不公开，不等于 0。 |
| view_count | 浏览/播放数。null 表示不公开，不等于 0。 |
| duration | 时长。 |
| posted_at | 发布时间，ISO 8601 格式、UTC 时区（如 2026-08-07T12:34:56+00:00）。平台只给非标准字符串时原样透传，解析前建议做容错。null 表示平台未公开。 |
| thumbnail_url | 缩略图链接，分辨率低于 image_url。 |
| hashtags | 正文里的话题标签数组，按出现顺序；没有时不出现这个字段。 |
| is_comments_disabled | 是否关闭评论。 |
| is_members_only | 是否会员专享视频。 |
| is_paid_partnership | 是否含付费推广。 |
| author_follower_count | 作者粉丝数。null 表示不公开。 |
| author_video_count | 频道视频总数。 |
| author_view_count | 频道总播放量。 |
| author_created_at | platform-native meaning |
| description_links | 视频简介里的链接：text、url。 |
| search_rank | 在这次搜索结果里的名次，从 1 开始。 |
| platform | 数据来源平台标识，与请求里的 platform 一致（如 xiaohongshu、tiktok）。 |

## Example

```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": "user_posts",
  "params": {
    "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  }
}'
```

```python
import os
import requests

response = requests.post(
    "https://api.everyinfra.com/api/v1/social",
    headers={"Authorization": f"Bearer {os.environ['EVERYINFRA_API_KEY']}"},
    json={
        "platform": "youtube",
        "action": "user_posts",
        "params": {
            "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

Real response to the example request above, captured 2026-09-26T08:56:04Z. `results` and `count` are real with personal information (names, handles, avatars, profile links, contact details) removed. `id`, `billing` and `quota` differ on every call, so only their shape is shown.

```text
{
  "id": "req_…",
  "platform": "youtube",
  "action": "user_posts",
  "results": [
    {
      "id": "dQw4w9WgXcQ",
      "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
      "title": "Rick Astley - Never Gonna Give You Up (Official Video) (4K Remaster)",
      "text": "The official video for “Never Gonna Give You Up” by Rick Astley. \n\nNever: The Autobiography 📚 OUT NOW! \nFollow this link to get your copy and listen to Rick’s ‘Never’ playlist ❤️ #RickAstleyNever\nhttps://linktr.ee/rickastleynever\n\n“Never Gonna Give You Up” was a global smash on i…",
      "author_name": "•••",
      "author_username": "•••",
      "author_id": "•••",
      "author_url": "https://www.youtube.com/•••",
      "like_count": 19000000,
      "comment_count": 2457642,
      "view_count": 1820151607,
      "duration": "00:03:33",
      "posted_at": "2009-10-25T06:57:33+00:00",
      "platform": "youtube"
    }
  ],
  "count": 1,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 怎么只拿最近一个月的视频？

传 `since`，格式 YYYY-MM-DD，只返回这个日期之后发布的视频；再把 `sort` 设为 `newest`，最新的排在前面。定期监测一个频道时，把上次读取的日期作为下一次的 `since`，就只拿新增内容。`since` 只对这一页的列表生效，视频详情那页不接受日期筛选。返回的 `posted_at` 是 UTC 时间，换算成本地日期时注意时区差。要的是「最近一个月」，就填一个月前那天的日期。`sort` 改用 `oldest` 时，就是从那天起按发布先后往后读。

### `popular` 排序适合什么场景？

想知道一个频道历史上最成功的内容时用。`sort` 取 `popular` 会把热门视频排在前面，对照它们的标题、时长和 `hashtags`，能总结出这个频道受欢迎的题材。`newest` 是最新优先，适合只看近期动态；`oldest` 把最早发布的排在前面，适合回溯早期作品。一次最多读 50 条，所以热门结论只代表这一批。再对照 `duration`，能看出热门视频偏短还是偏长；排序只在这个频道自己的视频之间进行。

### 怎么找出频道里的商业合作视频？

看 `is_paid_partnership`，为 true 表示这条视频含付费推广。统计这类视频占频道视频的比例，再对照它们的 `view_count`；`description_links` 列出了简介里的链接，可以一并核对。`is_comments_disabled` 标出评论被关闭的视频，统计评论数时要把它们单独分出来。`is_members_only` 为 true 的是会员专享视频，可以和付费推广分开统计。

## Also

- Capability catalog (no key): https://api.everyinfra.com/api/v1/social/catalog?platform=youtube
- OpenAPI: https://everyinfra.com/openapi.json · Agents guide: https://everyinfra.com/agents.md
