# Bilibili Scraper — videos, stats, search & comments (`istmobot/bilibili-scraper`) Actor

Scrape Bilibili (B站) videos with no login or cookies: keyword search, popular, rankings, uploader channels or video URLs. Get views, likes, coins, favorites, shares, danmaku, comment counts, tags, uploader, duration and top comments. Bilibili API alternative. Export JSON, CSV, Excel.

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

## Pricing

from $0.005 / actor start

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 & Bilibili API — video data, stats, search & comments (B站)

Scrape **Bilibili video data** at scale: views, likes, coins, favorites, shares, **danmaku** counts, comment counts, tags, uploader info, duration, publish date and top comments for any video on **Bilibili (B站)**, China's largest video platform for Gen Z. Use it as an unofficial **Bilibili API** for keyword search, the popular feed, the official rankings, an uploader's channel or your own list of video URLs.

### What is Bilibili Scraper?

Bilibili Scraper is a **Bilibili scraper** that turns Bilibili's public web endpoints into one clean, flat record per video, in English field names, ready for spreadsheets, BI tools and AI pipelines.

- **No login, no cookies, no API key, no browser.** It reads the same public data a logged-out visitor sees.
- **Handles Bilibili's anti-bot layer for you**: anonymous `buvid3` session, **WBI request signing**, and automatic retries with backoff when Bilibili's risk control (`-412` / `-352`) kicks in.
- **Five modes**: keyword **search**, specific **videos**, **popular** now, **ranking** (排行榜, overall or by category) and **uploader** (UP主) videos.
- **Same output in every mode**: every video is enriched with full stats from the video detail endpoint, so search results, rankings and channels all share one schema.
- **Polite by design**: concurrency of 3, requests spaced out, exponential backoff on errors.
- Download your data as **JSON, CSV, Excel, HTML** or XML, or read it via the Apify API.

#### What data can I extract with Bilibili Scraper?

| Field | Description |
|---|---|
| `bvid` / `aid` | Bilibili video ids (BV id and legacy av id) |
| `title` / `description` | Video title and description, plain text |
| `url` / `thumbnail` | Video page URL and cover image |
| `duration` | Length in seconds |
| `publishedAt` | Publish time, ISO 8601 (UTC) |
| `category` / `categoryId` | Bilibili partition (分区) name and id |
| `tags` | Video tags (optional, on by default) |
| `parts` / `isOriginal` | Number of parts (P) and whether it is marked as original (自制) |
| `owner` | Uploader: `mid`, `name`, `face` (avatar) |
| `stats.views` | Plays (播放) |
| `stats.likes` / `stats.coins` / `stats.favorites` / `stats.shares` | Likes (点赞), coins (投币), favorites (收藏), shares (分享) |
| `stats.danmaku` | Danmaku (弹幕) bullet-comment count |
| `stats.comments` | Comment count (评论) |
| `comments` | Optional top comments: text, likes, reply count, author, date |
| `scrapedAt` | When the record was collected |

### How can I use Bilibili data?

- **Global brands & marketers** — find and vet **Chinese creators (KOLs / UP主)** by real engagement (coins and favorites are strong intent signals), then track campaign videos daily.
- **Game, anime and music publishers** — monitor how your titles perform in China: search volume, rankings, danmaku activity and comment sentiment.
- **Market researchers & analysts** — follow trends on the **Chinese video platform** through the popular feed and category rankings.
- **Agencies in China and Asia** — export creator channels and competitor videos to Excel for reports.
- **Data scientists & AI teams** — build datasets of Chinese video titles, tags and comments for NLP and recommendation work.
- **Trend trackers** — schedule the ranking or popular mode hourly to build your own Bilibili trend history.

### How to scrape Bilibili

1. Click **Try for free** on this Actor's page (you need a free Apify account).
2. Choose a **Mode**: search by keyword, specific videos, popular now, ranking or uploader's videos.
3. Fill in a search term, video URLs, a ranking category or uploader ids, and set **Max videos**.
4. Optionally turn on **Include top comments**.
5. Click **Start**. The default input searches for "原神" (Genshin Impact) and returns 20 videos in under a minute.
6. Download the dataset as JSON, CSV, Excel or HTML, or connect it to your tools via the API.

### How much does it cost to scrape Bilibili?

This Actor uses **pay-per-event** pricing, so you only pay for the videos you actually get:

| Event | Price |
|---|---|
| Actor start | $0.005 per run |
| `video-result` (one video in the dataset) | $0.002 per video = **$2 per 1,000 videos** |

**Tags and top comments are included at no extra charge.** Error items (invalid ids, deleted or private videos, blocked requests) are **never charged**.

Example: 1 run × 1,000 videos = $0.005 + $2.00 = **$2.005**.

The Apify free plan includes **$5 of monthly credit**, which covers roughly **2,500 videos** per month. You can set a **maximum cost per run**; once it is reached the Actor stops cleanly and keeps everything scraped so far.

### ⬇️ Input

| Field | Type | Default | Description |
|---|---|---|---|
| `mode` | `search` | `videos` | `popular` | `ranking` | `user` | `search` | What to scrape (required) |
| `searchTerm` | string | — | `search` mode: keyword in Chinese or English, e.g. `原神`, `minecraft` |
| `searchOrder` | `totalrank` | `click` | `pubdate` | `dm` | `stow` | `totalrank` | `search` mode: relevance, most viewed, newest, most danmaku, most favorited |
| `videoUrls` | list of strings | — | `videos` mode: BV ids, av ids or `bilibili.com/video/...` URLs |
| `rankingCategory` | string | `0` | `ranking` mode: `0` all, `1001` Film & TV, `1002` Entertainment, `1003` Music, `1004` Dance, `1005` Animation, `1007` Kichiku, `1008` Games, `1010` Knowledge, `1012` Tech, `1013` Cars, `1014` Fashion & beauty, `1018` Sports, `1020` Food, `1024` Animals |
| `userIds` | list of strings | — | `user` mode: uploader ids (mid) or `space.bilibili.com/...` URLs |
| `maxItems` | integer | `50` | Max videos in search / popular / ranking mode, and per uploader in user mode (ignored in `videos` mode) |
| `includeTags` | boolean | `true` | Add video tags |
| `includeComments` | boolean | `false` | Add top comments |
| `maxComments` | integer | `3` | Comments per video (logged-out access returns at most 3) |

```json
{
  "mode": "search",
  "searchTerm": "原神",
  "searchOrder": "totalrank",
  "maxItems": 20,
  "includeTags": true,
  "includeComments": true
}
```

Top 100 gaming videos of the last 3 days: `{ "mode": "ranking", "rankingCategory": "1008", "maxItems": 100 }`

An uploader's latest 50 uploads: `{ "mode": "user", "userIds": ["https://space.bilibili.com/632887"], "maxItems": 50 }`

### ⬆️ Output

One item per video. The **Overview** table view in Apify Console shows thumbnail, title, uploader, views, likes, coins, favorites, danmaku, comments, duration and category at a glance. Real sample from a `search` run for "原神":

```json
{
  "bvid": "BV1aFHh6FEPz",
  "aid": 117374845977393,
  "title": "丘丘人化的申鹤😭【原神动画】（补档）",
  "description": "",
  "url": "https://www.bilibili.com/video/BV1aFHh6FEPz",
  "thumbnail": "https://i1.hdslb.com/bfs/archive/333cc0b0d502ffb4f46d9ac57d9abc5db90dee52.jpg",
  "duration": 256,
  "publishedAt": "2026-10-03T03:30:01.000Z",
  "category": "网络游戏",
  "categoryId": 65,
  "tags": ["二次元", "催眠", "原神动画", "原神六周年", "闲云", "恶魔化", "黑化", "原神", "申鹤", "丘丘人"],
  "parts": 1,
  "isOriginal": true,
  "owner": {
    "mid": 88942930,
    "name": "缔元破里",
    "face": "https://i1.hdslb.com/bfs/face/a47e85084d60a9b9d2fed3f4f88c3f4e60913e8b.jpg"
  },
  "stats": {
    "views": 108089,
    "likes": 3617,
    "coins": 469,
    "favorites": 5402,
    "shares": 520,
    "danmaku": 248,
    "comments": 283
  },
  "comments": [
    {
      "id": "319426208000",
      "text": "瓦学妹有机会吗？[妙啊][妙啊]",
      "likes": 137,
      "replies": 4,
      "author": { "mid": 695876349, "name": "被占用lD的木瓜桑" },
      "createdAt": "2026-10-03T03:44:35.000Z"
    }
  ],
  "scrapedAt": "2026-10-05T02:30:20.920Z"
}
```

Notes on fields:

- `duration` is in seconds. `publishedAt`, `createdAt` and `scrapedAt` are UTC (Beijing time is UTC+8).
- `category` is Bilibili's partition name in Chinese; `categoryId` is its id.
- `comments` is present only with `includeComments: true`. Bilibili shows logged-out visitors the **top 3 hot comments** per video; `[妙啊]`-style text is Bilibili's emoji markup.
- `tags` is `null` with `includeTags: false`.

#### Error items

```json
{ "input": "BV1AAAAAAAAA", "url": "https://www.bilibili.com/video/BV1AAAAAAAAA", "errorType": "API_ERROR", "error": "code -400: 请求错误" }
```

`errorType` is `NOT_FOUND` (deleted, private or region-locked video), `INVALID_VIDEO_ID`, `INVALID_USER_ID`, `RISK_CONTROL` (Bilibili kept blocking after all retries), `API_ERROR`, `FETCH_FAILED` or `LISTING_FAILED`. **Error items are never charged.**

### Integrations and API

**Apify API** — start a run and get results over HTTP:

```bash
curl -X POST "https://api.apify.com/v2/acts/istmobot~bilibili-scraper/run-sync-get-dataset-items?token=<YOUR_API_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"mode": "ranking", "rankingCategory": "0", "maxItems": 20}'
```

**Python** (`pip install apify-client`):

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_API_TOKEN>")
run = client.actor("istmobot/bilibili-scraper").call(run_input={
    "mode": "search",
    "searchTerm": "minecraft",
    "maxItems": 50,
})
for video in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(video.get("title"), video.get("stats", {}).get("views"))
```

**Node.js** (`npm install apify-client`):

```js
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: '<YOUR_API_TOKEN>' });
const run = await client.actor('istmobot/bilibili-scraper').call({
    mode: 'user',
    userIds: ['632887'],
    maxItems: 30,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

- **Schedules** — run it hourly or daily to track rankings, creator channels and video stats over time.
- **Webhooks** — get notified or trigger your own pipeline when a run finishes.
- **Make, Zapier, n8n** — send Bilibili data to Google Sheets, Airtable, Slack or a database without code.
- **AI agents** — use it from Claude, ChatGPT or any MCP client via the Apify MCP server (https://mcp.apify.com).

### FAQ

**Is it legal to scrape Bilibili?** This Actor only reads publicly available data that any logged-out visitor can see, does not log in and does not bypass any paywall. Public data is generally fine to collect, but uploader names, avatars and comments are personal data / user-generated content — if you store or process them, be mindful of GDPR, China's PIPL and similar laws. You are responsible for using the data in line with applicable laws and Bilibili's terms; if unsure, consult a lawyer.

**Do I need a Bilibili account, cookies or an API key?** No. No login, no cookies and no key. The Actor creates an anonymous visitor session by itself.

**Why only 3 comments per video?** Bilibili limits logged-out visitors to the top 3 hot comments. Getting more requires a logged-in account, which this Actor deliberately does not use. The total comment count is always in `stats.comments`.

**What are coins and danmaku?** Coins (投币) are a limited currency viewers give to videos they value, a strong engagement signal unique to Bilibili. Danmaku (弹幕) are the bullet comments that fly across the video.

**What is "risk control" (-412 / -352)?** Bilibili's anti-bot system. The Actor signs requests the way the website does, retries with exponential backoff and a fresh anonymous session; if a request is still blocked you get a free `RISK_CONTROL` error item instead of a silent gap.

**How many search results can I get?** Bilibili caps search at 50 pages × 20 = 1,000 videos per keyword. Use several keywords or `searchOrder` to go beyond that. Rankings return up to 100 videos.

**How fast is it?** Requests are deliberately spaced out to stay under Bilibili's risk control: roughly 2 videos per second with tags, so 100 videos take about a minute. Comments add one request per video.

**Does it work outside China?** Yes. It runs on Apify's servers, no Chinese IP or proxy needed. A few region-locked videos may return `NOT_FOUND`.

**Can I schedule it?** Yes. Use Apify Schedules to run it on any cron interval and combine with webhooks or integrations to push the results wherever you need them.

### Other Actors you might like

- [Steam Game Intelligence](https://apify.com/istmobot/steam-game-intelligence)
- [Metacritic Scraper](https://apify.com/istmobot/metacritic-scraper)
- [Earnings Call Transcripts Scraper](https://apify.com/istmobot/earnings-call-transcripts-scraper)

### Your feedback

Found a bug or want a new field? Open an issue in the **Issues** tab of this Actor — we read every one.

### Disclaimer

This is an **unofficial** tool. It is not affiliated with, endorsed by or sponsored by Bilibili Inc. (哔哩哔哩).

# Actor input Schema

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

"search": video search by keyword. "videos": the BV ids / video URLs you list. "popular": Bilibili's popular-now feed (综合热门). "ranking": the 3-day ranking (排行榜), overall or per category. "user": an uploader's (UP主) videos, newest first.

## `searchTerm` (type: `string`):

Used in "search" mode. Chinese or English, e.g. "原神", "minecraft", "AI 绘画".

## `searchOrder` (type: `string`):

Used in "search" mode.

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

Used in "videos" mode. BV ids (BV1suam6sEtq), av ids (av117357800330860) or bilibili.com/video/... URLs.

## `rankingCategory` (type: `string`):

Used in "ranking" mode. Bilibili's current (2025+) partitions.

## `userIds` (type: `array`):

Used in "user" mode. Numeric user ids (632887) or space.bilibili.com/... URLs.

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

How many videos to return in search / popular / ranking mode, and per uploader in user mode. Ignored in "videos" mode. Search tops out at 1,000 results, ranking at 100.

## `includeTags` (type: `boolean`):

Add the video's tags. One extra lightweight request per video.

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

Add the video's hot comments (text, likes, reply count, author, date). Without a login Bilibili shows only the top 3 hot comments per video.

## `maxComments` (type: `integer`):

Upper limit of comments per video. Logged-out access currently returns at most 3.

## Actor input object example

```json
{
  "mode": "search",
  "searchTerm": "原神",
  "searchOrder": "totalrank",
  "videoUrls": [
    "BV1suam6sEtq",
    "https://www.bilibili.com/video/BV1UGa961Ejt/"
  ],
  "rankingCategory": "0",
  "userIds": [
    "632887"
  ],
  "maxItems": 20,
  "includeTags": true,
  "includeComments": false,
  "maxComments": 3
}
```

# Actor output Schema

## `results` (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 = {
    "mode": "search",
    "searchTerm": "原神",
    "videoUrls": [
        "BV1suam6sEtq",
        "https://www.bilibili.com/video/BV1UGa961Ejt/"
    ],
    "userIds": [
        "632887"
    ],
    "maxItems": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("istmobot/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",
    "searchTerm": "原神",
    "videoUrls": [
        "BV1suam6sEtq",
        "https://www.bilibili.com/video/BV1UGa961Ejt/",
    ],
    "userIds": ["632887"],
    "maxItems": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("istmobot/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",
  "searchTerm": "原神",
  "videoUrls": [
    "BV1suam6sEtq",
    "https://www.bilibili.com/video/BV1UGa961Ejt/"
  ],
  "userIds": [
    "632887"
  ],
  "maxItems": 20
}' |
apify call istmobot/bilibili-scraper --silent --output-dataset

```

## MCP server setup

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