# B站 弹幕 API (bilibili.danmaku)

- Canonical page: https://everyinfra.com/bilibili-api/danmaku
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "bilibili", "action": "danmaku", "params": {...}}
- Price: $0.000556 per call ($0.56 per 1,000 requests); failed calls and empty results are not charged
- Returns: list, default 50, max 200 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=bilibili&action=danmaku

## 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–200) | no | 50 | 这次调用最多返回的条数，整数，1–200；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| video_id | 视频 BV 号。 |
| video_time | 视频内时间点。 |
| video_time_seconds | 视频内时间点，秒。 |
| mode | 弹幕模式（滚动/顶部/底部）。 |
| color | 弹幕颜色。 |
| pool | 弹幕池。 |
| sent_at | 弹幕发送时间。 |
| 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": "danmaku",
  "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": "danmaku",
        "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-10-24T22:01:06Z. `results` and `count` are real with personal information (names, handles, avatars, profile links, contact details) removed; the list keeps the first 2 of 50. `id`, `billing` and `quota` differ on every call, so only their shape is shown.

```text
{
  "id": "req_…",
  "platform": "bilibili",
  "action": "danmaku",
  "results": [
    {
      "id": "•••",
      "text": "前排提醒：請不要刷cp",
      "video_id": "BV1DYjA6KEJ7",
      "video_time": "0:00",
      "video_time_seconds": 0,
      "mode": "top",
      "color": "#E70012",
      "pool": "normal",
      "sent_at": "2026-06-18T13:00:52+00:00",
      "platform": "bilibili"
    },
    {
      "id": "•••",
      "text": "《请输入文本》",
      "video_id": "BV1DYjA6KEJ7",
      "video_time": "0:03",
      "video_time_seconds": 3.522,
      "mode": "top",
      "color": "#00A0EA",
      "pool": "normal",
      "sent_at": "2026-06-19T06:06:24+00:00",
      "platform": "bilibili"
    }
  ],
  "count": 50,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

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