# Bilibili Danmaku (Bullet Comments) Scraper (`axery/bilibili-danmaku-scraper`) Actor

Extract timed danmaku (bullet comments) and timecodes from Bilibili videos by BV ID or URL. Fast, lightweight HTTP-only scraper.

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

## Pricing

from $0.50 / 1,000 danmaku comment scrapeds

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 (Bullet Comments) Scraper 🚀

Extract timed danmaku (bullet screen comments), exact playback timestamps, sender user hashes, color codes, and display modes from any Bilibili video by URL or BV ID.

Fast, lightweight, and HTTP-only. No browser rendering or Bilibili account required.

***

### 🌟 Key Features

- **Accurate Timestamps:** Get exact playback timecodes down to millisecond precision (`time_seconds` and `time_formatted` e.g. `01:02`).
- **Full Comment Metadata:** Extracts color hex codes (`#FFFFFF`, `#FF0000`), font size, display mode (rolling, top, bottom), and user CRC32 hash.
- **Multi-Part Video Support:** Automatically resolves all video parts/pages (CIDs) for multi-episode series and playlists.
- **Ultra-Fast & Stable:** Direct HTTP REST API implementation with sub-second execution speed.
- **Cost-Efficient:** Minimal memory requirement (256MB - 512MB) and low Pay-Per-Event pricing.

***

### 📥 Input Parameters

| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `videoUrls` | Array of Strings | **Yes** | `["BV1uv411q7Mv"]` | List of Bilibili video URLs or BV IDs. |
| `maxDanmaku` | Integer | No | `1000` | Maximum danmaku comments to retrieve per video part. Set to `0` for all available. |
| `proxyConfiguration` | Object | No | `{ "useApifyProxy": false }` | Optional proxy settings. |

#### Example Input

```json
{
  "videoUrls": [
    "https://www.bilibili.com/video/BV1uv411q7Mv",
    "BV1GJ411x7h7"
  ],
  "maxDanmaku": 500
}
```

***

### 📤 Sample Output

Each comment is saved as an individual dataset record:

```json
{
  "bvid": "BV1uv411q7Mv",
  "cid": 214334689,
  "part": 1,
  "part_title": "Video Part 1",
  "time_seconds": 61.58,
  "time_formatted": "01:01",
  "mode": 1,
  "font_size": 25,
  "color_hex": "#FFFFFF",
  "created_at": "2024-03-15T08:24:19+00:00",
  "user_hash": "772dfab9",
  "row_id": "364581290381023",
  "text": "2333333333 太搞笑了"
}
```

***

### 🎯 Ideal Use Cases

- **Audience Engagement Heatmaps:** Map comment density spikes across video timelines to identify the most viral moments.
- **AI & NLP Sentiment Analysis:** Feed real-time Chinese vernacular and bullet-chat commentary into LLMs.
- **Anime & Gaming Research:** Track audience sentiment across ACG content and livestream archives.
- **Subtitle & Commentary Alignment:** Sync community reactions with video playback for archive platforms.

***

### 💰 Pricing (Pay-Per-Event)

- **Actor Start:** $0.005 per run
- **Danmaku Result:** $0.0005 per comment scraped (only $0.50 per 1,000 comments)

# Actor input Schema

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

List of Bilibili video URLs (e.g. https://www.bilibili.com/video/BV1uv411q7Mv) or raw BV IDs (e.g. BV1uv411q7Mv).

## `maxDanmaku` (type: `integer`):

Maximum number of danmaku comments to extract per video part/page. Set to 0 for unlimited.

## `proxyConfiguration` (type: `object`):

Optional proxy configuration. Standard Apify proxies are supported.

## Actor input object example

```json
{
  "videoUrls": [
    "BV1uv411q7Mv"
  ],
  "maxDanmaku": 1000,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `danmaku` (type: `string`):

Timed danmaku comments with playback timestamp, sender user hash, color hex code, and text.

# 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": [
        "BV1uv411q7Mv"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("axery/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": ["BV1uv411q7Mv"] }

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

```

## MCP server setup

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