# Bilibili Danmaku Scraper - Bullet Comments by Timeline (`ai-lead-gen-tools/bilibili-danmaku-scraper`) Actor

\[💰$0.02/1K] Scrape Bilibili danmaku bullet comments with a time window. Each row keeps timeline offset, render mode, pool, colour, text and sender hash, with a per-part summary row stating declared and delivered counts. Public endpoint, no proxy, no cookies.

- **URL**: https://apify.com/ai-lead-gen-tools/bilibili-danmaku-scraper.md
- **Developed by:** [Vladimir Che](https://apify.com/ai-lead-gen-tools) (community)
- **Categories:** Social media, Videos
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.02 / 1,000 danmaku scrapeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Bilibili Danmaku Scraper - Bullet Comments by Timeline

Read Bilibili danmaku through the same public endpoint the player itself calls, over plain HTTP with no proxy, no account and no API key. Give the actor video links or BV ids and it fetches each part's danmaku file once, then does every filter locally, so a timeline window costs no extra requests.

The timeline window is the point of this actor. Set `startSec` and `endSec` and you keep only the bullet comments that appear inside that stretch of the video, which is what a study of one scene, one chorus or one incident actually needs. On top of that you filter by render mode, by pool, by text length and by required or forbidden substrings.

A video split into parts carries a separate danmaku file and a separate timeline per part. All parts are read by default, and a `?p=3` suffix on a link narrows that target to a single part.

> **BILIBILI CAPS THE DANMAKU FILE AND THINS THE TIMELINE.** A video declaring 14 744 danmaku served 3 600. The cap removes rows across the whole timeline instead of cutting its tail, so the last record still lands at 1 774 of 1 775 seconds. The per-part summary row reports the declared count, the delivered count and the server maxlimit, and a larger request parameter does not change any of them because the server ignores it.

### What you get

| Field | Description |
|---|---|
| `resultId` | Stable id, built from the part cid and the danmaku id, or from the cid for a summary row |
| `kind` | `danmaku` for a bullet comment, `video` for the per-part summary row |
| `status` | `ok` for a real row, or a diagnostic status when the target failed |
| `reason` | Explanation attached to a diagnostic row, `null` on a normal row |
| `target` | The link or BV id the row came from |
| `bvid` | Bilibili video id |
| `aid` | Numeric legacy video id |
| `cid` | Part id, one per part of a multi-part video |
| `page` | Part number inside the video |
| `pageCount` | How many parts the video has |
| `part` | Part title as the source spells it |
| `title` | Video title |
| `ownerMid` | Numeric uploader id |
| `ownerName` | Uploader display name |
| `dmid` | Danmaku id |
| `offsetSeconds` | Position of the bullet comment on the timeline, in seconds |
| `offsetMs` | Same position in milliseconds |
| `mode` | Render mode as a number |
| `modeName` | Render mode as a name: `scroll`, `bottom`, `top`, `reverse`, `positioned`, `code`, `bas` |
| `pool` | Pool number |
| `poolName` | Pool name: `normal`, `subtitle`, `special` |
| `fontsize` | Font size the comment was sent with |
| `color` | Colour as a decimal number |
| `colorHex` | Same colour as `#rrggbb` |
| `senderHash` | Hashed sender id, as the source serves it |
| `weight` | Weight the source assigns to the comment |
| `sentAt` | Send time as a Unix timestamp |
| `sentAtIso` | Same send time in ISO 8601 |
| `text` | The bullet comment itself |
| `textLength` | Character count of the text |
| `windowStartSec` | Timeline window start applied to the row, `null` when unbounded |
| `windowEndSec` | Timeline window end applied to the row, `null` when unbounded |
| `videoDurationSecs` | Duration of the part in seconds |
| `declaredCount` | Danmaku the source declares for the part, summary row only |
| `deliveredCount` | Danmaku the served file actually carried, summary row only |
| `serverMaxlimit` | Cap the server reported, summary row only |
| `coverageRatio` | Share of the timeline the served file spans, summary row only |
| `rowsKept` | Rows kept after filtering, summary row only |
| `droppedByWindow` | Rows removed by the timeline window, summary row only |
| `droppedByMode` | Rows removed by the mode filter, summary row only |
| `droppedByPool` | Rows removed by the pool filter, summary row only |
| `droppedByLength` | Rows removed by the text length bounds, summary row only |
| `droppedByInclude` | Rows removed because they missed the required substrings, summary row only |
| `droppedByExclude` | Rows removed because they matched a forbidden substring, summary row only |

Fields the current row type does not fill are `null`, never invented. Output is available as JSON, CSV or Excel.

```json
{
  "resultId": "bilibili:danmaku:43468129293:2241212402170006784",
  "kind": "danmaku",
  "status": "ok",
  "reason": null,
  "bvid": "BV1aYW86vEte",
  "aid": 117586960321424,
  "cid": 43468129293,
  "page": 1,
  "pageCount": 1,
  "part": "Faker了一辈子的蹲方魂 终于…",
  "dmid": "2241212402170006784",
  "offsetSeconds": 1.182,
  "offsetMs": 1182,
  "mode": 5,
  "modeName": "top",
  "pool": 0,
  "poolName": "normal",
  "color": 16707842,
  "colorHex": "#fef102",
  "weight": 10,
  "sentAt": 1794264538,
  "sentAtIso": "2026-11-09T22:48:58.000Z",
  "text": "一定要看到最后，有种大狗终于叫了的释怀感",
  "textLength": 20,
  "videoDurationSecs": 101,
  "target": "https://www.bilibili.com/video/BV1aYW86vEte"
}
```

### How to use it

1. Paste one or more video links, BV ids or `av` ids into `videoUrls`.
2. Set the timeline window with `startSec` and `endSec` when you only need one scene.
3. Narrow by render mode, pool or text when the window alone is too wide.
4. Cap the run with `maxItems` and `runBudgetSecs`, then download the dataset.

```json
{
  "videoUrls": ["https://www.bilibili.com/video/BV1WEWs66EBP"],
  "pageScope": "first",
  "startSec": 0,
  "endSec": 600,
  "modes": ["scroll", "top"],
  "minLength": 2,
  "maxItems": 5000,
  "requestDelayMs": 400,
  "requestTimeoutSecs": 25,
  "runBudgetSecs": 300
}
```

| Input | Default | What it does |
|---|---|---|
| `videoUrls` | empty | Video links, BV ids or av ids, one target per video |
| `maxVideos` | `50` | How many of the listed videos to process, in the given order |
| `pageScope` | `all` | Read every part, the first part only, or the last part only |
| `startSec` | empty | Keep only danmaku at or after this second of the timeline |
| `endSec` | empty | Keep only danmaku at or before this second of the timeline |
| `modes` | `[]` | Keep only these render modes, names or numbers |
| `pools` | `[]` | Keep only these pools, names or numbers |
| `minLength` | `0` | Drop text shorter than this many characters |
| `maxLength` | `0` | Drop text longer than this many characters, zero means no bound |
| `includeText` | `[]` | Keep only text containing at least one of these substrings |
| `excludeText` | `[]` | Drop text containing any of these substrings |
| `maxItems` | `20000` | Hard cap on rows for the whole run, summary rows included |
| `requestDelayMs` | `400` | Gap between requests in milliseconds |
| `requestTimeoutSecs` | `25` | Per-request timeout in seconds |
| `runBudgetSecs` | empty | Wall-clock budget, stops requesting when spent |

#### Ready-made tasks

| Task | Input | Question it answers |
|---|---|---|
| [Bilibili Danmaku Scraper: Bullet Comments Timeline](https://apify.com/ai-lead-gen-tools/bilibili-danmaku-scraper/examples/bilibili-danmaku) | `videoUrls`, `pageScope: first`, `startSec`, `endSec` | every bullet comment of one scene, with the exact second it appeared |

Two more inputs, not saved as tasks because they differ from the one above by a single field:

- Top comments only: add `{"modes":["top"],"minLength":4}` to keep the pinned and highlighted comments that carry the most repeated phrases.
- Multi-part series: `{"videoUrls":["https://www.bilibili.com/video/BV1WEWs66EBP"],"pageScope":"all","maxItems":50000}` reads every part as its own timeline.

### Modes

| Mode | What it requests | Rows it leaves |
|---|---|---|
| `all` parts | One video card plus one danmaku file per part | One summary row and the danmaku rows for every part |
| `first` part | One video card plus the danmaku file of part 1 | One summary row and the danmaku rows of part 1 |
| `last` part | One video card plus the danmaku file of the final part | One summary row and the danmaku rows of the final part |
| `?p=` suffix | One video card plus the file of the named part | One summary row and the danmaku rows of that part |

### Use cases

- Audience reaction research - take one scene of a video and read every bullet comment that appeared during it, without reading the whole timeline.
- Language and slang study - collect danmaku from a set of popular videos, keep only the modes that render prominently, and get a corpus with timestamps for alignment.
- Content quality triage - compare `declaredCount` against `deliveredCount` per part to see how much of a crowded timeline the source actually serves.
- Rights and moderation review - pull the text and send time of comments around a specific incident, bounded to the seconds that matter.

### Cost

**$0.02 per 1 000 rows.** The Store adds a 20 % Apify margin on top of that price, and the buyer sees the margin in the invoice, not in this number.

You pay per row the actor actually pushed into the default dataset:

- `danmaku-scraped` - one bullet comment row.
- `video-scraped` - one per-part summary row, which carries the declared and delivered counts.
- `apify-actor-start` - charged once per run, the first five seconds of compute are not billed.

Nothing else is charged. Filters such as the timeline window, mode, pool and text reduce the number of rows and therefore the bill, because filtered out comments are never pushed. Requests that fail are retried and cost nothing extra.

### Honest limits

- The served danmaku file is capped by the server. A video declaring 14 744 danmaku served 3 600, and the cap thins the timeline rather than truncating its end.
- A larger request parameter does not raise the cap. The server ignores it, which is why the actor reports the cap per part instead of pretending to bypass it.
- Only the four segment pages the endpoint serves can be read. Older parts of very long timelines are simply absent from the file.
- Sender identity is a hash served by the source. The actor passes it through and cannot resolve it to an account.
- Danmaku text arrives in the language viewers used, usually Chinese. The actor does not translate, normalise or deduplicate repeated phrases.
- The timeline window is applied to the already served file, so a narrow window on a capped file can return very few rows. That is the source cap, not a bug in the filter.
- `colorHex` and `modeName` are derived from the numeric fields the source serves. The original numbers stay in `color` and `mode`.

### FAQ

**Why did my short window return so few comments?**
Because the server thins the file across the whole timeline before you see it. A crowded video loses rows everywhere, and a narrow window keeps its proportional share.

**Can I get the full danmaku of a video with tens of thousands of comments?**
Not through this endpoint. The cap is applied on the server and no request parameter lifts it. The summary row tells you how much was declared and how much was delivered.

**What does pageScope do for a single-part video?**
Nothing. A video with one part has one danmaku file, so `all`, `first` and `last` return the same rows.

**How do I read only one part of a multi-part video?**
Add `?p=3` to that link. The suffix overrides `pageScope` for that target only.

**Are numeric mode and pool values accepted?**
Yes. `modes` and `pools` accept names and numbers, so `["5"]` and `["top"]` select the same render mode.

**What happens when a video link is wrong?**
The run leaves one diagnostic row with `status` and `reason` for that target and continues with the rest, so one bad link does not stop the run.

**Is the summary row chargeable?**
Yes, it is a dataset row and it is priced at the same per row rate as a comment. It is emitted once per part so you can audit the cap.

**Do I need cookies or a proxy?**
No. The danmaku endpoint answers anonymous requests, and runs complete without a proxy or a login.

**Can I join the output with the video scraper?**
Yes. `resultId` in the video scraper starts with `bilibili:video:` and here with `bilibili:danmaku:`, and both share `bvid` and `cid`, so the join is on `bvid` for video level work and on `cid` for part level work.

### Related actors

- [Bilibili Scraper](/bilibili-scraper) - search, video details, creator profiles and uploads, comments and danmaku across seven modes.

### Changelog

- 2026-11-16: task `bilibili-danmaku` published, linked above and run once from itself.
- 2026-11-14: card rewritten to the publishing standard, price set to $0.02 per 1 000 rows.
- 2026-11-09: 69 559 danmaku rows collected over 77 requests with no duplicates.

# Actor input Schema

## `videoUrls` (type: `array`):

Full video links, bare BV ids or av ids, one target per video. A `?p=3` suffix limits that target to part 3. A bare cid is not accepted because the public view endpoint cannot resolve it back to a video.

## `maxVideos` (type: `integer`):

How many of the listed videos to process, in the order given.

## `pageScope` (type: `string`):

A video that is split into parts carries a separate danmaku file per part and each part is its own timeline. `all` reads every part, `first` only part 1, `last` only the final part. A `?p=` suffix on a target overrides this setting for that target.

## `startSec` (type: `integer`):

Keep only danmaku that appear at or after this second of the timeline. Applied per part, on the file Bilibili already served, so it costs no extra requests. Leave empty to start at zero.

## `endSec` (type: `integer`):

Keep only danmaku that appear at or before this second of the timeline. Must be greater than the window start when both are set. Leave empty to run to the end of the part.

## `modes` (type: `array`):

Keep only these render modes. Leave empty for all. Numeric ids are accepted as well as names: `scroll` is 1 to 3, `bottom` is 4, `top` is 5, `reverse` is 6, `positioned` is 7, `code` is 8, `bas` is 9.

## `pools` (type: `array`):

Keep only these pools. Leave empty for all. Numeric ids are accepted as well as names: `normal` is 0, `subtitle` is 1, `special` is 2. Bilibili also serves pool 3 on some videos; it has no name here, so filter it by the number.

## `minLength` (type: `integer`):

Drop danmaku shorter than this many characters. Zero keeps everything.

## `maxLength` (type: `integer`):

Drop danmaku longer than this many characters. Zero means no upper limit.

## `includeText` (type: `array`):

Keep only danmaku whose text contains at least one of these substrings, case-insensitive.

## `excludeText` (type: `array`):

Drop danmaku whose text contains any of these substrings, case-insensitive.

## `maxItems` (type: `integer`):

Hard cap on dataset rows for the whole run. One summary row per part is emitted first, so the cap also covers those.

## `requestDelayMs` (type: `integer`):

Gap between requests, in milliseconds. Two requests per part at most: the video card and the danmaku file.

## `requestTimeoutSecs` (type: `integer`):

Per-request timeout in seconds.

## `runBudgetSecs` (type: `integer`):

Wall-clock budget. The run stops requesting once it is spent and still writes the rows it already collected.

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.bilibili.com/video/BV1WEWs66EBP"
  ],
  "maxVideos": 50,
  "pageScope": "first",
  "startSec": 0,
  "endSec": 600,
  "modes": [
    "scroll",
    "top"
  ],
  "pools": [
    "normal"
  ],
  "minLength": 0,
  "maxLength": 0,
  "includeText": [],
  "excludeText": [],
  "maxItems": 20000,
  "requestDelayMs": 400,
  "requestTimeoutSecs": 25,
  "runBudgetSecs": 205
}
```

# Actor output Schema

## `dataset` (type: `string`):

Danmaku rows with offset in seconds and milliseconds, render mode, pool, colour in both decimal and hex, sender hash, posting time and decoded text. Each part of a multi-part video is summarised once with how many danmaku Bilibili declares, how many the file actually carried, the server maxlimit and how much of the timeline the file spans, so a capped part is visible instead of silent. Every field is present on every row; unknown values are null.

## `summary` (type: `string`):

Targets requested, started, finished and interrupted, parts actually processed, whether the row cap stopped the run, the timeline window and filters actually applied, requests, retries, HTTP status distribution, rows by kind, danmaku declared against delivered against kept, how many parts hit the server cap, what each filter dropped, the budget state and how many events were charged.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "videoUrls": [
        "https://www.bilibili.com/video/BV1WEWs66EBP"
    ],
    "maxVideos": 50,
    "pageScope": "first",
    "startSec": 0,
    "endSec": 600,
    "modes": [
        "scroll",
        "top"
    ],
    "pools": [
        "normal"
    ],
    "runBudgetSecs": 205
};

// Run the Actor and wait for it to finish
const run = await client.actor("ai-lead-gen-tools/bilibili-danmaku-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "videoUrls": ["https://www.bilibili.com/video/BV1WEWs66EBP"],
    "maxVideos": 50,
    "pageScope": "first",
    "startSec": 0,
    "endSec": 600,
    "modes": [
        "scroll",
        "top",
    ],
    "pools": ["normal"],
    "runBudgetSecs": 205,
}

# Run the Actor and wait for it to finish
run = client.actor("ai-lead-gen-tools/bilibili-danmaku-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "videoUrls": [
    "https://www.bilibili.com/video/BV1WEWs66EBP"
  ],
  "maxVideos": 50,
  "pageScope": "first",
  "startSec": 0,
  "endSec": 600,
  "modes": [
    "scroll",
    "top"
  ],
  "pools": [
    "normal"
  ],
  "runBudgetSecs": 205
}' |
apify call ai-lead-gen-tools/bilibili-danmaku-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ai-lead-gen-tools/bilibili-danmaku-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/bFZ75JDoyE1TdJtGb/builds/WA7kTtnkSyisWsOkh/openapi.json
