# YouTube Shorts 短视频 API (youtube.shorts)

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

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| username | not declared | yes | not declared | YouTube 频道 handle，可带 @；返回该频道的 Shorts，不是全站关键词搜索。 |
| channel | not declared | no | not declared | username 的低优先级兼容输入；公开请求仍须提供 username，且 username 会优先于 channel。请传频道 handle，不要传 /channel/UC… URL。 |
| since | not declared | no | not declared | Shorts 的最早发布日期，格式 YYYY-MM-DD。 |
| sort | enum: newest / oldest / popular | no | not declared | Shorts 排序：newest 最新、oldest 最早、popular 热门。 |
| limit | integer (1–100) | no | 20 | 这次调用最多返回的条数，整数，1–100；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| url | 该记录在原平台上的可访问链接。 |
| title | 标题。平台无标题概念时（如纯文本帖）为 null。 |
| thumbnail_url | 缩略图链接，分辨率低于 image_url。 |
| view_count | 浏览/播放数。null 表示不公开，不等于 0。 |
| like_count | 点赞数。null 表示该平台或该接口不公开此数据，不等于 0。 |
| duration | 时长。 |
| posted_at | 发布时间，ISO 8601 格式、UTC 时区（如 2026-08-07T12:34:56+00:00）。平台只给非标准字符串时原样透传，解析前建议做容错。null 表示平台未公开。 |
| author_name | 作者昵称（显示名）。 |
| author_id | 作者在原平台的唯一 ID。 |
| author_url | 作者在原平台的主页链接。 |
| 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": "shorts",
  "params": {
    "username": "NASA"
  }
}'
```

```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": "shorts",
        "params": {
            "username": "NASA",
        },
    },
    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; the list keeps the first 2 of 20. `id`, `billing` and `quota` differ on every call, so only their shape is shown.

```text
{
  "id": "req_…",
  "platform": "youtube",
  "action": "shorts",
  "results": [
    {
      "id": "QP5Fs3AYuWE",
      "url": "https://www.youtube.com/shorts/QP5Fs3AYuWE",
      "title": "2026 Total Solar Eclipse Over Spain",
      "thumbnail_url": "https://i.ytimg.com/vi/QP5Fs3AYuWE/maxresdefault.jpg?sqp=-oaymwEoCIAKENAF8quKqQMcGADwAQH4AbYIgAKAD4oCDAgAEAEYZSBlKGUwDw==&rs=AOn4CLAT9U1JJD_l2_VOJY3iTy0h7-Tq1w",
      "view_count": 180984,
      "like_count": 5500,
      "duration": "00:00:35",
      "posted_at": "2026-08-12T19:08:21+00:00",
      "author_name": "NASA",
      "author_id": "•••",
      "author_url": "https://www.youtube.com/•••",
      "platform": "youtube"
    },
    {
      "id": "VV_JW4iCni0",
      "url": "https://www.youtube.com/shorts/VV_JW4iCni0",
      "title": "NASA Moon Base Update (Aug. 4, 2026)",
      "thumbnail_url": "https://i.ytimg.com/vi/VV_JW4iCni0/maxres2.jpg?sqp=-oaymwEoCIAKENAF8quKqQMcGADwAQH4AbYIgAKAD4oCDAgAEAEYZSBlKFIwDw==&rs=AOn4CLAcXNzw0zOj2WxgVF5ZilzIObMHRg",
      "view_count": 183127,
      "like_count": 5700,
      "duration": "00:00:32",
      "posted_at": "2026-08-04T16:18:07+00:00",
      "author_name": "NASA",
      "author_id": "•••",
      "author_url": "https://www.youtube.com/•••",
      "platform": "youtube"
    }
  ],
  "count": 20,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## 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
