# YouTube 评论 API (youtube.comments)

- Canonical page: https://everyinfra.com/youtube-api/comments
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "youtube", "action": "comments", "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=comments

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| url | not declared | yes | not declared | 具体 YouTube 视频 URL，返回该视频评论。 |
| since | not declared | no | not declared | 评论的最早发布日期，格式 YYYY-MM-DD；它筛选评论，不筛选视频发布日期。 |
| sort | enum: newest / popular | no | not declared | 评论排序：newest 最新评论、popular 热门评论。 |
| limit | integer (1–100) | no | 20 | 这次调用最多返回的条数，整数，1–100；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| author_name | 作者昵称（显示名）。 |
| like_count | 点赞数。null 表示该平台或该接口不公开此数据，不等于 0。 |
| reply_count | 回复数，通常用于评论的子回复。null 表示不公开。 |
| posted_at | 发布时间，ISO 8601 格式、UTC 时区（如 2026-08-07T12:34:56+00:00）。平台只给非标准字符串时原样透传，解析前建议做容错。null 表示平台未公开。 |
| is_reply | 是否为回复。 |
| reply_to_id | 被回复评论 ID。 |
| 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": "comments",
  "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": "comments",
        "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-10-24T18:28:34Z. `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": "comments",
  "results": [
    {
      "id": "UgzKYksqeQ5gA3t0g0F4AaABAg",
      "text": "I Rick rolled my entire French class because we had to study a city in France and make a quiz about it as well as a presentation, I decided to make a Kahoot quiz because it’s very easy. I put a link in to this saying it’s the kahoot link. The teacher needless to say got very very…",
      "author_name": "•••",
      "like_count": 105000,
      "reply_count": 636,
      "posted_at": "6 years ago (edited)",
      "is_reply": false,
      "platform": "youtube"
    },
    {
      "id": "Ugw10bSluCDSZMIxUSB4AaABAg",
      "text": "Let’s put the meme aside, this is actually a banging song.",
      "author_name": "•••",
      "like_count": 219000,
      "reply_count": 596,
      "posted_at": "6 years ago",
      "is_reply": false,
      "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
