# Bilibili Scraper: Videos, Comments, Danmaku & Creators (`sinodata/bilibili-scraper`) Actor

Scrape Bilibili (哔哩哔哩) without login: keyword search, video stats, comments and replies, danmaku with per-minute heatmap, creator profiles and uploads, and trending videos.

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

## Pricing

Pay per event

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 Scraper: Videos, Comments, Danmaku & Creators (哔哩哔哩)

Extract public data from **Bilibili** (哔哩哔哩, B站), China's largest video community for Gen Z, anime, gaming, tech reviews and education. No login, no cookies, no browser. Fast HTTP requests against Bilibili's own web APIs.

### What you can scrape

| Source | What you get |
|---|---|
| **Keyword search** | Videos for any keyword (Chinese or English), sortable by relevance, views, newest, danmaku, favorites or comments, filterable by length |
| **Video URLs** | Full stats: views, likes, coins, favorites, shares, danmaku and comment counts, tags, category, duration, cover, author |
| **Comments** | Top comments and their full reply threads, with likes, reply counts, author name and level |
| **Danmaku (弹幕)** | The bullet comments shown over the video, with timestamp and color, plus a **per-minute activity profile and peak minute** |
| **Creators (UP主)** | Profile (followers, total likes, video count, verification) and their latest uploads |
| **Popular** | Bilibili's current popular list (综合热门) with recommendation reasons |

### Use cases

- **Brand and product monitoring in China**: see how a launch (iPhone, EV, game, cosmetics) is reviewed by Chinese creators and viewers.
- **KOL / influencer discovery**: find creators by keyword, compare followers and engagement before a campaign.
- **Market research and sentiment**: collect comments and danmaku for NLP, sentiment or topic analysis.
- **Content strategy**: find which video lengths, titles and tags get the most views in a niche.
- **Academic research** on Chinese internet culture.

### How to use

1. Add one or more **search keywords**, **video URLs**, **creator URLs**, or turn on **Popular videos**.
2. Choose how many videos per source, and whether to include comments and danmaku.
3. Run, then download the results as JSON, CSV, Excel or via API.

Accepted video inputs: `https://www.bilibili.com/video/BV1GJ411x7h7`, `b23.tv` short links, `BV1GJ411x7h7`, `av170001`.
Accepted creator inputs: `https://space.bilibili.com/946974` or `946974`.

#### Example input

```json
{
  "searchQueries": ["iPhone 17 测评"],
  "maxVideosPerSource": 50,
  "searchSort": "click",
  "fetchFullVideoDetails": true,
  "includeComments": true,
  "maxCommentsPerVideo": 100,
  "includeCommentReplies": true
}
```

### Output

Every record has a `type` field: `video`, `comment`, `danmaku` or `creator`. Use the **Videos** and **Comments** views in the dataset tab, or filter by `type` when exporting.

#### Video

```json
{
  "type": "video",
  "bvid": "BV1GJ411x7h7",
  "url": "https://www.bilibili.com/video/BV1GJ411x7h7",
  "title": "...",
  "authorName": "...",
  "authorMid": 946974,
  "views": 1234567,
  "likes": 45678,
  "coins": 12345,
  "favorites": 23456,
  "shares": 3456,
  "danmakuCount": 7890,
  "commentCount": 4567,
  "publishedAt": "2025-09-12T10:00:00.000Z",
  "durationSeconds": 612,
  "category": "数码",
  "tags": ["iPhone", "测评"]
}
```

#### Comment

```json
{
  "type": "comment",
  "videoBvid": "BV1GJ411x7h7",
  "text": "...",
  "likes": 321,
  "replyCount": 12,
  "authorName": "...",
  "authorLevel": 6,
  "createdAt": "2025-09-12T12:00:00.000Z",
  "parentRpid": null
}
```

#### Danmaku

```json
{
  "type": "danmaku",
  "videoBvid": "BV1GJ411x7h7",
  "totalReturned": 1500,
  "peakMinute": 3,
  "peakMinuteCount": 240,
  "perMinute": { "0": 120, "1": 80, "3": 240 },
  "danmaku": [{ "timeSeconds": 3.2, "text": "前排", "color": "#ffffff", "sentAt": "2025-09-12T10:05:00.000Z" }]
}
```

### Pricing

Pay only for results:

| Event | Price |
|---|---|
| Video | $0.004 |
| Creator profile | $0.004 |
| Comment | $0.001 |
| Danmaku set (one per video, up to 10,000 danmaku) | $0.004 |

1,000 videos with full stats cost $4. The run stops cleanly when it reaches the maximum cost you set.

### Notes and limits

- Only public data visible to a logged-out visitor is collected. Bilibili shows logged-out visitors only the top few (usually 3) top-level comments per video, but their reply threads are fully available, so with replies on (the default) you still get hundreds of comments from popular videos. Commenter IP location is not shown to logged-out visitors, so it is not included.
- Bilibili serves a sample of danmaku (usually up to a few thousand per video) to the public XML endpoint, not the full history.
- Search returns at most 1,000 results per keyword (Bilibili's own limit). Use several specific keywords for broader coverage.
- If you run very large jobs and see many `-352` / `412` errors in the log, enable Apify Proxy (residential) in the Advanced section.
- Respect Bilibili's terms and applicable law, and don't use personal data (names, comments) for spam or harassment.

### Feedback

Found a bug or need a field that's missing? Open an issue on the Issues tab and it will usually be fixed within a day or two.

# Actor input Schema

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

Search Bilibili videos by keyword. Chinese or English both work, e.g. 原神, iPhone 17 测评, AI.

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

Video links (bilibili.com/video/BV..., b23.tv short links), BV ids or av ids.

## `creatorUrls` (type: `array`):

Creator space links (space.bilibili.com/123456) or numeric user ids. Returns the profile plus their latest uploads.

## `includePopular` (type: `boolean`):

Also scrape Bilibili's current popular (综合热门) list.

## `maxVideosPerSource` (type: `integer`):

How many videos to save for each search keyword, each creator and the popular list.

## `searchSort` (type: `string`):

Order of search results.

## `searchDuration` (type: `string`):

Only return search results of this length.

## `fetchFullVideoDetails` (type: `boolean`):

Search and creator lists don't include coins, shares and exact likes. Turn on to fetch each video's full stats and tags (slower, same price).

## `includeComments` (type: `boolean`):

Save comments for every scraped video.

## `maxCommentsPerVideo` (type: `integer`):

Total comments per video, counting replies. Bilibili shows logged-out visitors only the top few (usually 3) top-level comments, so most comments come from the reply threads under them.

## `commentSort` (type: `string`):

Order of top-level comments.

## `includeCommentReplies` (type: `boolean`):

Recommended. Replies are where most of the discussion is visible without login.

## `maxRepliesPerComment` (type: `integer`):

Replies saved under each top-level comment (still limited by Max comments per video).

## `includeDanmaku` (type: `boolean`):

One record per video with the danmaku list and a per-minute activity profile (peak minute).

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

How many danmaku to keep in each video's danmaku record.

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

Usually not needed. If you see many 412/-352 errors on large runs, switch to Apify residential proxy.

## Actor input object example

```json
{
  "searchQueries": [
    "iPhone 17 测评"
  ],
  "includePopular": false,
  "maxVideosPerSource": 30,
  "searchSort": "totalrank",
  "searchDuration": "0",
  "fetchFullVideoDetails": false,
  "includeComments": false,
  "maxCommentsPerVideo": 50,
  "commentSort": "hot",
  "includeCommentReplies": true,
  "maxRepliesPerComment": 20,
  "includeDanmaku": false,
  "maxDanmakuPerVideo": 500,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

No description

## `videos` (type: `string`):

No description

## `comments` (type: `string`):

No description

# 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 = {
    "searchQueries": [
        "iPhone 17 测评"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("sinodata/bilibili-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 = { "searchQueries": ["iPhone 17 测评"] }

# Run the Actor and wait for it to finish
run = client.actor("sinodata/bilibili-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 '{
  "searchQueries": [
    "iPhone 17 测评"
  ]
}' |
apify call sinodata/bilibili-scraper --silent --output-dataset

```

## MCP server setup

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