# Bilibili Scraper — Videos, Comments & Danmaku (`astravalabs/bilibili-scraper`) Actor

Bilibili (哔哩哔哩) videos from keywords or URLs with full stats (views, likes, coins, favorites, shares), tags and uploader, plus optional comments and danmaku. No login, no cookies. Pay per result; deleted videos are free.

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

## Pricing

from $2.50 / 1,000 videos

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

Collect Bilibili (哔哩哔哩, B站) videos by keyword or URL with their full
public stats (views, likes, coins, favorites, shares, danmaku and comment
counts), tags, category and uploader. Optionally add each video's comments
and its danmaku (the on-screen comments), all in one run and one dataset.

No Bilibili account, cookies or API key. Pay only for what you get: videos
that are deleted or hidden are free.

Use it for Chinese social listening, brand and campaign monitoring, creator
research, trend tracking, audience sentiment, and NLP or LLM datasets.

### Quick start

Search two keywords, 20 videos each:

```json
{ "keywords": ["原神", "minecraft"], "maxVideosPerKeyword": 20 }
```

Specific videos with their comments and danmaku:

```json
{
  "videoUrls": ["https://www.bilibili.com/video/BV1xx411c7mD", "BV1GJ411x7h7", "av170001"],
  "includeComments": true,
  "maxCommentsPerVideo": 200,
  "includeDanmaku": true
}
```

Daily monitor: only videos you haven't collected yet, newest first, from the
last week:

```json
{
  "keywords": ["新能源汽车", "电动车 评测"],
  "sort": "newest",
  "publishedAfter": "2026-11-05",
  "onlyNewVideos": true,
  "stateKey": "ev-monitor"
}
```

### What you get

Every row has a `type`: `video`, `comment` or `danmaku`. The **Videos**,
**Comments** and **Danmaku** tabs in the output show each one.

A video (real data, abridged):

```json
{
  "type": "video",
  "bvid": "BV1cmW26cE3q",
  "url": "https://www.bilibili.com/video/BV1cmW26cE3q",
  "title": "原神||都是XP抽卡害了我啊",
  "description": "都是XP抽卡害了我啊",
  "category": "手机游戏",
  "tags": ["原神", "抽卡", "二次元", "深渊"],
  "durationSeconds": 210,
  "publishedAt": "2026-11-11T11:35:32Z",
  "uploaderName": "白羽Baiyuleta",
  "uploaderId": 2447707,
  "uploaderUrl": "https://space.bilibili.com/2447707",
  "views": 18868,
  "likes": 535,
  "coins": 45,
  "favorites": 66,
  "shares": 31,
  "danmakuCount": 60,
  "commentCount": 461,
  "source": "keyword",
  "keyword": "原神",
  "searchRank": 2,
  "commentsCollected": 30,
  "danmakuCollected": 60
}
```

A comment:

```json
{
  "type": "comment",
  "bvid": "BV1Nxxr6oES2",
  "commentId": 323644711328,
  "text": "终于解决了我哥玩电脑登录不了我的世界的问题了，终于可以和他联机了！",
  "likes": 1,
  "replyCount": 0,
  "postedAt": "2026-11-11T11:28:42Z",
  "isPinned": false,
  "authorId": "u_e0e00677db341dc0"
}
```

A danmaku:

```json
{
  "type": "danmaku",
  "bvid": "BV1cmW26cE3q",
  "offsetSeconds": 194.669,
  "text": "拜托，你多少金的木偶队了，打这玩意都要96s",
  "mode": "scroll",
  "color": "#ffffff",
  "sentAt": "2026-11-11T14:09:07Z"
}
```

#### Commenter privacy

Commenters are never named. By default each comment has a pseudonymous
`authorId` (`u_…`). It's stable, so you can count unique commenters or spot
repeat ones across runs, but it can't be turned back into a Bilibili account.
Set `authorPrivacy` to `omit` to leave it out. Nicknames, avatars and
IP-region labels are never collected. Uploaders, as public creators, are
named.

### Options

| Field | Default | What it does |
|---|---|---|
| `keywords` | — | Search terms, Chinese or English (up to 100). |
| `videoUrls` | — | Video links, BV ids or av numbers (up to 5,000). |
| `maxVideosPerKeyword` | 50 | Videos per keyword (Bilibili search tops out around 1,000). |
| `maxVideos` | 1000 | Whole-run limit on videos saved (and charged). |
| `sort` | relevance | `relevance`, `mostViewed`, `newest`, `mostDanmaku`, `mostFavorited`. |
| `duration` | any | `under10`, `10to30`, `30to60`, `over60` (minutes). |
| `publishedAfter` / `publishedBefore` | — | Date window for keyword results (UTC days). |
| `onlyNewVideos` / `stateKey` | off / `default` | Skip keyword results returned by earlier runs with the same key. |
| `includeComments` | off | Top-level comments, pinned first in `hot` order. |
| `maxCommentsPerVideo` | 100 | Up to 2,000. |
| `commentSort` | hot | `hot` or `newest`. |
| `authorPrivacy` | pseudonymous | `pseudonymous` or `omit`. |
| `includeDanmaku` | off | Danmaku of the video's first part, in playback order. |
| `maxDanmakuPerVideo` | 1000 | Up to 5,000. |

### Pricing

| What | Price |
|---|---|
| Video | **$2.50 per 1,000** ($0.0025 each) |
| Comment | **$1.00 per 1,000** ($0.001 each) |
| Danmaku | **$1.00 per 1,000** ($0.001 each) |

Plus Apify's small Actor-start fee. Comments and danmaku are only collected
(and charged) when you switch them on. Deleted, hidden or under-review videos
cost nothing, and neither do inputs that aren't videos.

### Coverage and reliability

Measured on a 355-video run over 10 Chinese and English keywords plus URLs,
with comments and danmaku (November 2026):

- **Every available video collected:** 354 of 354, plus 3,109 comments and
  15,007 danmaku, in about four minutes. The one deleted video was reported
  and not charged.
- **Cross-checked against the video pages:** on 50 random videos, title,
  uploader, duration, publish time and all stats (views, likes, coins,
  favorites, comments) matched 50/50.
- **Field coverage:** stats, uploader, duration and publish time on 100% of
  videos, tags on 99.7%, category on 99%.
- **No duplicate comments,** and every commenter id pseudonymous.

Bilibili's `danmakuCount` is a lifetime total that includes danmaku it no
longer shows, so the danmaku you receive (everything Bilibili currently
serves) can be fewer than that number. `commentCount` includes replies; the
Actor collects top-level comments.

### Limits

- **Search depth:** Bilibili search returns about 1,000 results per keyword.
  Use several keywords, sorts or date windows to go wider.
- **Danmaku:** everything Bilibili currently serves for the video, which is
  all of it on most videos and the most recent ~1,000–3,000 on very busy ones.
  Multi-part videos: first part only.
- **Comments:** top-level comments with their reply counts; replies themselves
  are not collected. On some very busy videos Bilibili shows no "hot"
  ranking to logged-out visitors. The Actor then collects the newest comments
  and notes it in the run report.
- **Channels:** uploader pages and channel video lists aren't supported.
- **Category** is filled for keyword results; for URL inputs it may be empty.
- Short `b23.tv` links aren't resolved. Open them and paste the full URL.

### Run report

The `RUN_REPORT` record in the run's key-value store lists each video's
outcome (saved, not publicly available, could not be collected), how many
comments and danmaku it got, notes such as "comments closed", and how each
keyword was paged.

### Is it legal?

The Actor reads only what Bilibili shows any logged-out visitor, with no
login, no paywall and nothing hidden. It collects no commenter names, and
commenter ids are pseudonymised by default. You're responsible for using the
data in line with Bilibili's terms and the data-protection laws that apply to
you, including China's PIPL for personal information.

# Actor input Schema

## `keywords` (type: `array`):

Search Bilibili for each keyword (Chinese or English) and collect the matching videos. Up to 100 keywords.

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

Bilibili video links, BV ids (BV1xx411c7mD) or av numbers (av170001). Up to 5,000. Short b23.tv links are not resolved; open them and paste the full URL.

## `maxVideosPerKeyword` (type: `integer`):

How many videos to collect for each keyword. Bilibili search returns about 1,000 results per keyword at most.

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

Hard cap on video rows for the whole run (URLs first, then keyword results in order).

## `sort` (type: `string`):

Order of keyword search results.

## `duration` (type: `string`):

Only keyword results of this length.

## `publishedAfter` (type: `string`):

Only keyword results published on or after this date (YYYY-MM-DD, UTC). Video URLs are always collected.

## `publishedBefore` (type: `string`):

Only keyword results published on or before this date (YYYY-MM-DD, UTC).

## `onlyNewVideos` (type: `boolean`):

Skip keyword results this Actor already returned in earlier runs with the same state key. Ideal for scheduled monitoring.

## `stateKey` (type: `string`):

Name of the memory used by 'Only videos not collected before'. Use different keys for independent monitors.

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

Also collect top-level comments for each video (charged per comment).

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

Comments are fetched 20 per page.

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

Hot (Bilibili's ranking, pinned first) or newest first.

## `authorPrivacy` (type: `string`):

Commenters are never named. 'Pseudonymous' gives each one a stable anonymous id (u\_…) so you can count unique commenters; 'Omit' leaves the id out.

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

Also collect danmaku (the on-screen comments) for each video's first part, in playback order (charged per danmaku).

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

Bilibili serves all current danmaku of most videos, and the most recent ~1,000–3,000 on very busy ones.

## Actor input object example

```json
{
  "keywords": [
    "原神",
    "minecraft"
  ],
  "videoUrls": [
    "https://www.bilibili.com/video/BV1xx411c7mD"
  ],
  "maxVideosPerKeyword": 20,
  "maxVideos": 1000,
  "sort": "relevance",
  "duration": "any",
  "onlyNewVideos": false,
  "stateKey": "default",
  "includeComments": false,
  "maxCommentsPerVideo": 100,
  "commentSort": "hot",
  "authorPrivacy": "pseudonymous",
  "includeDanmaku": false,
  "maxDanmakuPerVideo": 1000
}
```

# Actor output Schema

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

Videos, and the comments and danmaku you asked for (the type column tells them apart).

## `runReport` (type: `string`):

Per-video outcome, per-keyword paging, unavailable videos and request counts.

# 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 = {
    "keywords": [
        "原神",
        "minecraft"
    ],
    "videoUrls": [
        "https://www.bilibili.com/video/BV1xx411c7mD"
    ],
    "maxVideosPerKeyword": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("astravalabs/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 = {
    "keywords": [
        "原神",
        "minecraft",
    ],
    "videoUrls": ["https://www.bilibili.com/video/BV1xx411c7mD"],
    "maxVideosPerKeyword": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("astravalabs/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 '{
  "keywords": [
    "原神",
    "minecraft"
  ],
  "videoUrls": [
    "https://www.bilibili.com/video/BV1xx411c7mD"
  ],
  "maxVideosPerKeyword": 20
}' |
apify call astravalabs/bilibili-scraper --silent --output-dataset

```

## MCP server setup

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