# Bilibili Danmaku Scraper - Bullet Comments by Video (`teodor_banea/bilibili-danmaku-scraper`) Actor

Scrape the danmaku (弹幕 bullet comments) of public Bilibili videos: text, video time, sent time, display mode, colour and weight. From video links, channels or search. Priced per line. No login, no proxy setup.

- **URL**: https://apify.com/teodor_banea/bilibili-danmaku-scraper.md
- **Developed by:** [Banea Teodor](https://apify.com/teodor_banea) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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 Video

### What does Bilibili Danmaku Scraper do?

Danmaku (弹幕, "bullet comments") are the short comments Bilibili viewers send while watching; they fly across the video at the exact moment they were written. They are the most direct record of how an audience reacts, second by second.

This Actor exports the danmaku of public Bilibili videos — no login, no Bilibili account, no API key and no proxy setup. Enter videos (links, BV ids, av numbers or b23.tv short links), channels (their latest videos) or search keywords (their top videos), and get **one row per danmaku line**: the text, the moment in the video, when it was sent, display mode, colour, font size, pool and Bilibili's quality weight, plus the video title, part and uploader.

For video statistics, search results, channel details, trending boards and hot searches, use the main **Bilibili Scraper** by the same developer.

### Why use this Actor?

- **Priced for volume** — every danmaku line is one row, at a price per 1,000 lines made for datasets of tens of thousands of lines.
- **As deep as Bilibili lets visitors go** — the Actor reads both danmaku sources Bilibili gives logged-out visitors for each part and merges them, which gives about 40 % more lines than the recent-lines list alone.
- **Every part of multi-part videos**, in part and video-time order.
- **Three ways in** — video links, channels (latest videos) and searches (top videos), combinable in one run; each video is read once.
- **Filters** — words in the text, a stretch of the video, a sent-date window.
- **Privacy** — no sender identifier of any kind is output (Bilibili's sender hash is dropped).

### How much does it cost?

Every danmaku line is one billed row. A short busy video gives 1,500-3,000 lines; a long multi-part video can give 10,000-20,000 or more. Set **Maximum results** and **Maximum danmaku per video** to control the bill; videos without danmaku, deleted videos and lines your filters leave out cost nothing beyond the run start.

### The per-part limit

Bilibili shows logged-out visitors only part of a busy video's danmaku history: **the most recent lines, up to about 1,200 per part for a 6-minute part and about 9,600 for an 80-minute part**, plus a weighted selection of a few hundred lines per 6 minutes of video. The Actor reads both and merges them (about 1,650 lines for a busy 6-minute part, about 13,000 for an 80-minute one). Older lines by date need a logged-in account and are not included. The video's own danmaku counter counts the full history, so it is usually higher than the lines you get.

### Input

| Field | Description | Example |
|---|---|---|
| `videoUrls` | Videos: links, BV ids (case-sensitive), av numbers, b23.tv short links. A link to one part (`…?p=3`) reads that part only. | `["https://www.bilibili.com/video/BV17x411w7KC"]` |
| `channels`, `maxVideosPerChannel` | Channels (link, number or exact name) and how many of their newest videos to read. | `["https://space.bilibili.com/546195"]`, `10` |
| `searchQueries`, `sortBy`, `maxVideosPerQuery` | Keywords; which top videos (relevance, most viewed, newest, most danmaku…); how many per keyword. | `["原神"]`, `"danmaku"`, `10` |
| `parts` | `all` parts of multi-part videos (default) or the `first` only. | `"all"` |
| `maxDanmakuPerVideo` | Lines per video (0 = all Bilibili shows, the default). The earliest lines by part and video time are kept. | `0` |
| `textContains` | Keep lines containing any of these words. | `["哈哈"]` |
| `minVideoTimeSec`, `maxVideoTimeSec` | Keep lines shown in this stretch of each part (seconds). | `60`, `120` |
| `sentAfter`, `sentBefore` | Keep lines sent in this window (UTC) — a date or a period such as `"7 days"`. | `"1 day"` |
| `maxResults` | Lines per run (default 1,000; 0 = unlimited, capped at 500,000). | `1000` |

### Output

One row per danmaku line; within each video, rows are ordered by part and video time (several videos are read at once, so their rows can interleave). Example (fictitious text, real prefill video):

```json
{
    "rowType": "danmaku",
    "danmakuId": "2245151313816830976",
    "bvid": "BV17x411w7KC",
    "videoUrl": "https://www.bilibili.com/video/BV17x411w7KC?p=1",
    "videoTitle": "示例视频：手冲咖啡入门",
    "videoDurationSec": 1240,
    "partNumber": 1,
    "partTitle": "P1 开场",
    "partDurationSec": 412,
    "ownerId": 100000001,
    "ownerName": "示例频道 Example Channel",
    "text": "前排！",
    "videoTimeSec": 122.885,
    "sentAt": "2026-11-12T09:15:00Z",
    "displayMode": "scroll",
    "fontSize": 25,
    "color": "#ffffff",
    "pool": "normal",
    "weight": 10,
    "sourceInput": "https://www.bilibili.com/video/BV17x411w7KC",
    "runId": "aBcDeFgHiJkLmNoPq",
    "scrapedAt": "2026-11-19T10:00:00.000Z"
}
```

- `videoTimeSec` is measured from the start of the part.
- `pool` is Bilibili's line pool: `normal` for almost every line, positioned lines included; `subtitle` and `special` are Bilibili's caption and advanced pools.
- Positioned lines (`displayMode` "positioned") carry position data; `text` holds the part viewers read.
- `weight` (0-11) is Bilibili's quality score behind its "smart block" slider; low values are the first to be hidden from viewers.
- Videos, channels and queries that could not be read are listed in the run's key-value store under **ERRORS** with a plain reason (not found, not visible, no videos, invalid BV id).

### Tips and tricks

- **Control the bill:** a few long multi-part videos can give tens of thousands of lines. Start with a small **Maximum results**.
- **Filters make results smaller, not runs faster:** each video is still read in full; only matching lines become (billed) rows. A run stops after reading 20 lines per row of Maximum results (at least 400,000 lines) that your filters or limits leave out, and says so in its status. With a per-video limit and no filters, each video is only read as far as its earliest lines need.
- **BV ids are case-sensitive:** copy them exactly; an all-lower-case id is listed under ERRORS instead of being read as a different video.
- **Duplicates:** a video named twice (or found by both a channel and a search) is read once.

### Scheduling

The Actor keeps no memory between runs. To collect only new lines of the same videos, schedule it with **Sent after** set to the schedule interval (for example `"1 day"` for a daily run, a little more to overlap) and de-duplicate downstream by `danmakuId`. For channels, combine **Videos per channel** with **Sent after** to follow their newest videos.

### Privacy

Rows never contain a sender identifier: Bilibili's per-line sender hash is dropped and no account data is read. The uploader's public channel number and name are included because they identify the video.

### Integrations

Results are a standard Apify dataset: download JSON, CSV or Excel from the run page, read them with the Apify API, or send them to Google Sheets, Zapier, Make, Slack or a webhook with Apify integrations.

# Changelog

This Actor's version history is a separate document: https://apify.com/teodor_banea/bilibili-danmaku-scraper/changelog.md

# Actor input Schema

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

Enter videos, one per line: a link (https://www.bilibili.com/video/BV17x411w7KC), a BV id, an av number (av170001) or a b23.tv short link. A link to one part (…?p=3) reads that part only; other entries follow "Parts of multi-part videos". BV ids are case-sensitive — copy them exactly.

## `channels` (type: `array`):

Enter channels, one per line: a channel link (https://space.bilibili.com/546195), the channel number or the exact channel name. The danmaku of each channel's latest videos are read.

## `maxVideosPerChannel` (type: `integer`):

How many of each channel's newest videos to read.

## `searchQueries` (type: `array`):

Enter keywords, one per line. The danmaku of the top videos of each search are read.

## `sortBy` (type: `string`):

Choose which videos count as the top results of a search.

## `maxVideosPerQuery` (type: `integer`):

How many of the top videos of each search to read.

## `parts` (type: `string`):

Read every part (分P) of a multi-part video, or the first part only.

## `maxDanmakuPerVideo` (type: `integer`):

Limit the lines taken from each video; the earliest lines by part and video time are kept. Set to 0 for all Bilibili shows visitors.

## `textContains` (type: `array`):

Keep only lines containing any of these words (not case-sensitive). Leave empty to keep all lines.

## `minVideoTimeSec` (type: `integer`):

Keep only lines shown at or after this moment of the part (seconds from its start).

## `maxVideoTimeSec` (type: `integer`):

Keep only lines shown at or before this moment of the part (seconds from its start).

## `sentAfter` (type: `string`):

Keep only lines sent on or after this date (UTC), or within a recent period such as "7 days". Use it in scheduled runs to collect only new lines.

## `sentBefore` (type: `string`):

Keep only lines sent before this date (UTC).

## `maxResults` (type: `integer`):

Limit the danmaku lines of the whole run. Set to 0 for unlimited (capped at 500,000 lines to protect you from a surprise bill).

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.bilibili.com/video/BV17x411w7KC",
    "BV1Q541167Qg",
    "av170001"
  ],
  "channels": [
    "https://space.bilibili.com/546195"
  ],
  "maxVideosPerChannel": 10,
  "searchQueries": [
    "原神",
    "LOL"
  ],
  "sortBy": "relevance",
  "maxVideosPerQuery": 10,
  "parts": "all",
  "maxDanmakuPerVideo": 0,
  "textContains": [
    "哈哈",
    "awsl"
  ],
  "maxResults": 200
}
```

# Actor output Schema

## `results` (type: `string`):

Every danmaku line as JSON.

## `table` (type: `string`):

The main columns as a table.

## `resultsCsv` (type: `string`):

The same rows as a CSV download.

## `errors` (type: `string`):

Inputs that could not be read and why. Only present when something went wrong.

# 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/BV17x411w7KC"
    ],
    "maxResults": 200
};

// Run the Actor and wait for it to finish
const run = await client.actor("teodor_banea/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/BV17x411w7KC"],
    "maxResults": 200,
}

# Run the Actor and wait for it to finish
run = client.actor("teodor_banea/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/BV17x411w7KC"
  ],
  "maxResults": 200
}' |
apify call teodor_banea/bilibili-danmaku-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,teodor_banea/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/IJDjByBahMUlCpt6l/builds/ReurNJRuly2HYRL15/openapi.json
