# B站 评论 API (bilibili.comments)

- Canonical page: https://everyinfra.com/bilibili-api/comments
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "bilibili", "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 10, max 10 per call (larger values are capped)
- Mode: sync; add "mode": "async" for slow tasks

B站评论接口按视频 `url` 读取这条视频评论区里的评论，每条带正文、点赞数、回复数、评论者昵称与主页链接、发布时间和所属视频的 BV 号。它回答「观众在评论区说了什么」，适合做口碑与情感分析、收集观众反馈和发现高赞观点。

`url` 建议用 https://www.bilibili.com/video/<BV号> 这样的完整链接。评论、弹幕和字幕是三种不同的文字：评论是评论区里的讨论，弹幕是播放时飘过的实时短评，字幕是语音转写，按分析目的选对能力。`reply_count` 高的评论往往是讨论的焦点。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| url | not declared | yes | not declared | B 站视频完整链接，建议 https://www.bilibili.com/video/<BV号>。comments 查评论区，danmaku 查第一分 P 的播放弹幕，subtitles 查语音转写；三者不是同一种文字数据。danmaku 需要能从链接里提取 BV 号。 |
| limit | integer (1–10) | no | 10 | 这次调用最多返回的条数，整数，1–10；不传按默认值，实际返回可能少于这个数。超过上限照收，按上限返回。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| like_count | 点赞数。null 表示该平台或该接口不公开此数据，不等于 0。 |
| reply_count | 回复数，通常用于评论的子回复。null 表示不公开。 |
| author_name | 作者昵称（显示名）。 |
| author_id | 作者在原平台的唯一 ID。 |
| author_url | 作者在原平台的主页链接。 |
| posted_at | 发布时间，ISO 8601 格式、UTC 时区（如 2026-08-07T12:34:56+00:00）。平台只给非标准字符串时原样透传，解析前建议做容错。null 表示平台未公开。 |
| video_id | 视频 BV 号。 |
| 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": "bilibili",
  "action": "comments",
  "params": {
    "url": "https://www.bilibili.com/video/BV1DYjA6KEJ7"
  }
}'
```

```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": "bilibili",
        "action": "comments",
        "params": {
            "url": "https://www.bilibili.com/video/BV1DYjA6KEJ7",
        },
    },
    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": "bilibili",
  "action": "comments",
  "results": [
    {
      "id": "•••",
      "text": "当至冬海关检查我的背包时：",
      "like_count": 8927,
      "reply_count": 173,
      "author_name": "•••",
      "author_id": "•••",
      "author_url": "https://space.bilibili.com/•••",
      "posted_at": "2026-06-18T13:00:49+00:00",
      "video_id": "BV1DYjA6KEJ7",
      "platform": "bilibili"
    },
    {
      "id": "•••",
      "text": "万人血书保护最好的派蒙（1/————）\n（敢动派蒙你就似定了老米）",
      "like_count": 3207,
      "reply_count": 50,
      "author_name": "•••",
      "author_id": "•••",
      "author_url": "https://space.bilibili.com/•••",
      "posted_at": "2026-06-18T13:01:56+00:00",
      "video_id": "BV1DYjA6KEJ7",
      "platform": "bilibili"
    }
  ],
  "count": 20,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 评论、弹幕和字幕有什么区别？

评论是评论区里的讨论，带点赞和回复数；弹幕是播放时飘过的实时短评；字幕是视频语音的转写。三者用同一个视频链接，分别对应 B 站的评论、弹幕和字幕能力。

### 评论按什么顺序返回？

按平台返回的顺序给出，这个能力目前没有排序参数。需要按热度看时，拿到结果后按 `like_count` 或 `reply_count` 自行排序。

### 怎么把评论和视频对应起来？

每条评论都带 `video_id`，即所属视频的 BV 号。批量读取多条视频的评论时，用它把评论归到各自的视频下面。

## Also

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