# YouTube 话题内容 API (youtube.hashtag)

- Canonical page: [https://everyinfra.com/youtube-api/hashtag](https://everyinfra.com/youtube-api/hashtag?utm_medium=ai_doc&utm_campaign=page_md)
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "youtube", "action": "hashtag", "params": {...}}
- Price: $0.000792 per call ($0.79 per 1,000 requests); failed calls and empty results are not charged
- Returns: list, one page of up to 36 per call; the number of rows varies from page to page and a short page is not the end (limit is ignored; pass the top-level next_page_token from the response as page_token for the next page; no next_page_token means the end)
- Pagination: pass next_page_token back as page_token for the next page, other params unchanged; one call per page, tokens last 24 hours
- 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=hashtag

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| hashtag | not declared | yes | not declared | 话题标签：名字带不带 # 都行（cooking、#cooking、#旅行），或话题页链接 https://www.youtube.com/hashtag/cooking；不分大小写。名字只能是字母、数字、各国文字和下划线，不带空格，最多 100 个字；认不出的在扣费前拒绝（422）。话题下没有能看的视频时返回空结果，不扣费。 |
| country | not declared | no | not declared | 地区，两位国家代码，如 US、JP；不传是 US。影响 YouTube 给哪些视频。 |
| language | not declared | no | not declared | 界面语言，语言代码，如 en、ja、zh-CN；不传是 en。影响 published_text 的写法和多语言标题显示哪种，不翻译内容。 |
| page_token | not declared | no | not declared | 翻页令牌。第一页不传；响应有 next_page_token 时原样作 page_token 传回，其他参数不变。一页约 6～36 条，看话题，多数话题第一页就到底，limit 不起作用。每页算一次调用；令牌 24 小时有效。没有 next_page_token 就是翻不下去了。翻页时 language、country 要和第一页一致。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| 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。 |
| view_count_estimated | 为 true 表示 view_count（播放数）是从 YouTube 显示的约数（如 1.2M）换算的估算值，不是准确数；准确数时没有这个字段。 |
| duration | 时长；channel_lives、playlist_videos、video_search、hashtag 里写成 H:MM:SS。 |
| published_text | YouTube 页面上写的发布时间，是相对说法（如 2 years ago），原样给；页面没写是 null。 |
| thumbnail_url | 缩略图链接，分辨率低于 image_url。 |
| preview_url | 视频的预览链接（channel_lives、playlist_videos、video_search、hashtag）。 |
| badges | 视频上的角标，文字数组，如 4K、CC、New；没有是空数组。 |
| is_live | 是不是正在直播。 |
| is_upcoming | 是不是还没开始的首映或预约直播。 |
| hashtag_name | 话题名，不带 #（hashtag），YouTube 话题页上的写法；只有第一页有，每行相同。 |
| hashtag_video_count | 这个话题下的视频数（hashtag），YouTube 话题页上写的约数，换成整数；只有第一页有、每行相同，YouTube 没写时不返回。 |
| hashtag_video_count_estimated | 为 true 表示 hashtag_video_count 是从 YouTube 显示的约数（如 43M）换算的估算值，不是准确数。 |
| hashtag_channel_count | 用过这个话题的频道数（hashtag），YouTube 话题页上写的约数，换成整数；只有第一页有、每行相同，YouTube 没写时不返回。 |
| hashtag_channel_count_estimated | 为 true 表示 hashtag_channel_count 是从 YouTube 显示的约数（如 4.3M）换算的估算值，不是准确数。 |
| 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": "hashtag",
  "params": {
    "hashtag": "cooking"
  }
}'
```

```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": "hashtag",
        "params": {
            "hashtag": "cooking",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

No real sample for these example parameters yet: structure only, every value is a placeholder (…).

```text
{
  "id": "req_…",
  "platform": "youtube",
  "action": "hashtag",
  "results": [
    {
      "type": …,
      "id": …,
      "url": …,
      "title": …,
      "text": …,
      "author_name": …,
      "author_username": …,
      "author_id": …,
      "author_url": …,
      "author_avatar_url": …,
      "author_is_verified": …,
      "view_count": …,
      "view_count_estimated": …,
      "duration": …,
      "published_text": …,
      "thumbnail_url": …,
      "preview_url": …,
      "badges": …,
      "is_live": …,
      "is_upcoming": …,
      "hashtag_name": …,
      "hashtag_video_count": …,
      "hashtag_video_count_estimated": …,
      "hashtag_channel_count": …,
      "hashtag_channel_count_estimated": …,
      "platform": …
    }
  ],
  "next_page_token": …,
  "pagination": { … },
  "count": …,
  "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
