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

Scrape Bilibili (B站) search results, video stats, full creator upload lists, creator profiles, trending videos, comments and danmaku. No login needed. Clean English field names.

- **URL**: https://apify.com/xiaolu_ling/bilibili-scraper.md
- **Developed by:** [CN Data Lab](https://apify.com/xiaolu_ling) (community)
- **Categories:** Social media, Videos
- **Stats:** 2 total users, 1 monthly users, 83.3% 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, Creators, Comments & Danmaku

Get public data from [Bilibili](https://www.bilibili.com) (哔哩哔哩, B站), the largest video community in China. Use it for market research, influencer discovery, trend tracking, brand monitoring and AI datasets.

No Bilibili account is needed. Field names are in English. Text content stays in the original language.

### What you can scrape

| Mode | Input | Output |
|---|---|---|
| **Search videos** | Keywords | Up to 1,000 videos per keyword, sorted by relevance, date, views, danmaku or favorites |
| **Video details** | Video URLs or BV IDs | Views, likes, coins, favorites, shares, comments, danmaku count, tags, duration, author |
| **All videos of a creator** | Space URLs or creator IDs | The **complete** upload list of a creator, sorted by newest or most views |
| **Creator profiles** | Space URLs or creator IDs | Followers, total likes, video count, level, verification, bio |
| **Trending videos** | Nothing | The current Bilibili popular list with full statistics |
| **Comments** | Video URLs or BV IDs | Comment text, likes, reply count, author, date |
| **Danmaku** | Video URLs or BV IDs | Bullet comments with their position in the video and send time |

### Why this scraper

- **Complete creator upload lists.** You get every public video of a channel.
- **Full statistics on list results.** Turn on "Add full video details" and each search or creator result also has coins, shares, likes, favorites, comment counts and tags.
- **Pay per result.** You pay only for the items you receive. There is no monthly rental.
- **Low memory.** The Actor uses the Bilibili web APIs, not a browser. It runs with 256 MB.

### Input examples

Search the newest videos for two keywords:

```json
{
    "mode": "search",
    "queries": ["iPhone 17", "原神"],
    "maxItems": 200,
    "sort": "newest"
}
```

Get every video of a creator with full statistics:

```json
{
    "mode": "creatorVideos",
    "queries": ["https://space.bilibili.com/546195"],
    "maxItems": 1000,
    "includeDetails": true
}
```

Get the danmaku of a video:

```json
{
    "mode": "danmaku",
    "queries": ["https://www.bilibili.com/video/BV1GJ411x7h7"],
    "maxItems": 5000
}
```

### Output examples

Video (search with `includeDetails`, or the video mode):

```json
{
    "type": "video",
    "bvid": "BV1aZpw6DEKJ",
    "aid": 117393435138792,
    "cid": 42511303711,
    "url": "https://www.bilibili.com/video/BV1aZpw6DEKJ",
    "title": "第一次去美国，被吓到了……",
    "description": "暴雪嘉年华真好玩！！",
    "coverUrl": "https://i0.hdslb.com/bfs/archive/ebc616f717a9c799243e57c2129f095ddec81eab.jpg",
    "durationSeconds": 689,
    "publishedAt": "2026-10-06T12:28:51.000Z",
    "tags": ["美国", "老番茄", "旅游", "魔兽世界", "搞笑", "Vlog"],
    "authorName": "老番茄",
    "authorMid": 546195,
    "viewCount": 2152024,
    "danmakuCount": 3403,
    "commentCount": 1732,
    "likeCount": 84705,
    "coinCount": 18327,
    "favoriteCount": 14581,
    "shareCount": 2740,
    "query": "BV1aZpw6DEKJ",
    "scrapedAt": "2026-10-09T02:47:35.990Z"
}
```

Creator profile:

```json
{
    "type": "creator",
    "mid": 546195,
    "url": "https://space.bilibili.com/546195",
    "name": "老番茄",
    "bio": "新浪微博：_老番茄_",
    "level": 6,
    "followerCount": 20828339,
    "followingCount": 6,
    "videoCount": 680,
    "totalLikes": 195741077,
    "isVerified": true,
    "verifiedTitle": "2025百大UP主、2025年度商业影响力奖UP主",
    "vipLabel": "年度大会员"
}
```

Comment:

```json
{
    "type": "comment",
    "commentId": "3760801399",
    "videoBvid": "BV1GJ411x7h7",
    "text": "坏消息：被骗了\n好消息：真好听",
    "likeCount": 764833,
    "replyCount": 2193,
    "createdAt": "2020-11-29T12:26:45.000Z",
    "authorName": "老咸鱼A",
    "authorMid": 320773657,
    "authorLevel": 6
}
```

Danmaku:

```json
{
    "type": "danmaku",
    "videoBvid": "BV1GJ411x7h7",
    "text": "我是一万个点赞，正在反复横跳",
    "videoTimeSeconds": 0.601,
    "sentAt": "2020-11-07T09:54:55.000Z",
    "danmakuId": "40685126698926083"
}
```

### Limits you should know

- **Search:** Bilibili returns at most 1,000 videos per keyword. Use more specific keywords or different sort orders to get more.
- **List results without details:** Search results have no coin and share counts. Creator-video results have only title, cover, duration, publish date and views. Turn on "Add full video details" to get all statistics.
- **Comments:** Bilibili shows only the top comments (about 3 per video) to visitors who are not logged in. To get more, put the `SESSDATA` cookie of your own Bilibili account in the "cookie" input. The cookie is stored as a secret and is sent only to Bilibili.
- **Danmaku:** Bilibili keeps a limited pool for each video. The Actor returns the current pool of the first part of the video.
- **Sub-replies** of comments are not scraped.

### Pricing

Pay per result. Each video, creator profile or comment in the dataset is one result. Danmaku lines have their own, much lower price because one video can have thousands of them. You do not pay for failed queries.

### FAQ

**Do I need a Bilibili account or cookies?**
No. Only the full comment list needs a cookie.

**Can I call it from an API, n8n, Make or an AI agent?**
Yes. Use the Apify API, the integrations tab, or the Apify MCP server.

**Is it legal to scrape Bilibili?**
The Actor collects only data that is publicly visible without login. Results can contain personal data such as user names. Make sure that your use follows the law that applies to you.

**Something does not work or you need another field?**
Open an issue on the Issues tab.

# Actor input Schema

## `mode` (type: `string`):

Select the type of data. The meaning of "Queries" depends on this mode.

## `queries` (type: `array`):

Keywords for the search mode. Video URLs or BV IDs for the video, comments and danmaku modes. Creator space URLs or numeric creator IDs (mid) for the creator modes. Not used by the trending mode.

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

Maximum number of results for each query. Bilibili search returns at most 1,000 videos per keyword.

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

Search supports all options. Creator videos support newest and views. Comments support relevance (hot) and newest.

## `includeDetails` (type: `boolean`):

Applies to the search and creator-videos modes. Adds likes, coins, favorites, shares, comment counts and tags to each video. Runs take longer.

## `cookie` (type: `string`):

Only needed to get more than the top comments. Bilibili shows about 3 comments per video to visitors who are not logged in. Paste the SESSDATA cookie value of your own Bilibili account.

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

Proxy servers used for the requests.

## Actor input object example

```json
{
  "mode": "search",
  "queries": [
    "iPhone 17"
  ],
  "maxItems": 20,
  "sort": "relevance",
  "includeDetails": false,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

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

All scraped items in the default dataset.

# 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 = {
    "mode": "search",
    "queries": [
        "iPhone 17"
    ],
    "maxItems": 20,
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("xiaolu_ling/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 = {
    "mode": "search",
    "queries": ["iPhone 17"],
    "maxItems": 20,
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("xiaolu_ling/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 '{
  "mode": "search",
  "queries": [
    "iPhone 17"
  ],
  "maxItems": 20,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call xiaolu_ling/bilibili-scraper --silent --output-dataset

```

## MCP server setup

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