# Bilibili Scraper (B站) - Videos, Comments & Danmaku (`improved_knot_vyk/bilibili-scraper`) Actor

Returns Bilibili videos with views, likes, coins, favorites, shares, danmaku and comment counts, tags and author in every row. Search (up to 5,000 per term), trending, rankings, creators, comments and replies, danmaku profiles with sentiment. $2 per 1,000 results. No login.

- **URL**: https://apify.com/improved_knot_vyk/bilibili-scraper.md
- **Developed by:** [Nicolas Alexandre](https://apify.com/improved_knot_vyk) (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

Scrape **Bilibili** (哔哩哔哩), China's biggest video platform: search videos by keyword, get any video by URL,
trending videos, the top 100 ranking by category, creators with their uploads, comments and danmaku.
**$2 per 1,000 videos.** Also known as B站, 哔哩哔哩, Bilibili crawler, Bilibili API, Bilibili data extractor.

### Why this Actor

| | This Actor | Most popular Bilibili scraper on the Store |
|---|---|---|
| Videos | **$2 per 1,000** | $20 per 1,000 |
| Comments and replies | **$2 per 1,000** | $20 per 1,000 |
| Danmaku profile | **$5 per 1,000** | $50 per 1,000 |

100,000 videos a month cost **$200** here instead of $2,000.

- Views, likes, **coins**, favorites, shares, danmaku and comment counts, tags, duration, author, publish date.
- Creator stats: followers, videos, total likes, level, verification.
- **Comments and replies**, and a **danmaku profile** per video (count, unique senders, per-minute rate, peak
  minute, sample across the timeline), with optional sentiment.
- **Deep search**: up to 5,000 videos per term with date windows, date filters, extra terms and automatic Chinese
  brand names (apple → 苹果).
- Fast and light: 60 search results in about 2 seconds, trending top 100 in about 1 second. No login, no browser.
- **Pay per result**: you pay only for videos and creators returned. Missing or blocked items are free.

### Use cases

- **Market and trend research in China**: what is trending, in which category, with how much engagement.
- **Brand and campaign monitoring**: search your brand or product and track views, likes and coins over time.
- **Creator discovery**: find creators by topic and compare followers, output and engagement.
- **Data for AI agents and analytics**: stable JSON fields, easy to use from the API, Make, Zapier or n8n.

### Modes

| Mode | Input | What you get |
|---|---|---|
| Search by keyword | `searchTerms`, `sort`, `duration`, `publishedAfter`, `publishedBefore` | Up to 5,000 videos per term |
| Videos by URL | `videoUrls` (links or BV ids) | Full stats and tags for each video |
| Comments | `videoUrls` | Only the comments and replies of those videos |
| Trending | `maxItems` | Bilibili's current popular list |
| Ranking | `rankingCategory` | Top 100 overall or by category (tech, gaming, music...) |
| Creators | `creatorUrls` | One creator row plus their latest videos |

Options for any mode that returns videos:

- **Full stats and tags** (`includeDetails`, on by default): coins, shares, likes and tags in every search and
  creator row, at the same price. Trending and ranking rows have them already. Turn it off for faster runs.
- **Comments** (`includeComments`, `maxComments`, `commentSort`, `includeReplies`): comment and reply rows.
- **Danmaku profile** (`includeDanmaku`, `danmakuSampleSize`): one summary row per video.
- **Sentiment** (`sentiment`): positive, negative or neutral with a score from -1 to +1 on comments and danmaku.

```json
{
  "mode": "search",
  "searchTerms": ["原神", "rust programming"],
  "maxItems": 200,
  "sort": "views",
  "includeDetails": true
}
```

### Example output: video

```json
{
  "type": "video",
  "bvid": "BV1hp4y1k7SV",
  "aid": 970073238,
  "url": "https://www.bilibili.com/video/BV1hp4y1k7SV",
  "title": "Rust编程语言入门教程（Rust语言/Rust权威指南配套）【已完结】",
  "description": "配套教材：《The Rust Programming Language》v1\n2025新版视频（更新ing）：https://b23.tv/bCo2OtB",
  "cover": "https://i0.hdslb.com/bfs/archive/3bcd51d8e8035931e282079a7a256ec7e1e8e80d.jpg",
  "durationSeconds": 43777,
  "publishedAt": "2020-10-21T12:59:36Z",
  "category": "计算机技术",
  "categoryId": 2103,
  "tags": [
    "教学视频",
    "程序员",
    "视频教程",
    "编程",
    "#编程vlog#"
  ],
  "authorMid": "361469957",
  "authorName": "软件工艺师",
  "stats": {
    "views": 1716307,
    "likes": 26181,
    "coins": 27729,
    "favorites": 59838,
    "shares": 5773,
    "danmaku": 25028,
    "comments": 2582
  },
  "source": "search",
  "searchTerm": "rust programming",
  "position": 1,
  "scrapedAt": "2026-10-13T10:36:18Z"
}
```

### Example output: creator

```json
{
  "type": "creator",
  "mid": "546195",
  "url": "https://space.bilibili.com/546195",
  "name": "老番茄",
  "bio": "新浪微博：_老番茄_",
  "followers": 20841228,
  "following": 6,
  "videoCount": 681,
  "totalLikes": 196033978,
  "level": 6,
  "verified": true,
  "verifiedTitle": "2025百大UP主、2025年度商业影响力奖UP主、2022年度联合创作奖UP主",
  "scrapedAt": "2026-10-13T10:40:19Z"
}
```

### Example output: comment

```json
{
  "type": "comment",
  "rpid": "320569850704",
  "videoBvid": "BV1fSWc6cE7y",
  "text": "你怎么知道我梭哈大成功了[doge]",
  "likes": 20,
  "replyCount": 7,
  "publishedAt": "2026-10-13T07:19:17Z",
  "authorMid": "14712629",
  "authorName": "葉子没吃药",
  "authorLevel": 6,
  "sentiment": {
    "polarity": "neutral",
    "score": 0.0
  },
  "scrapedAt": "2026-10-13T12:09:08Z"
}
```

### Example output: danmaku profile

```json
{
  "type": "danmaku",
  "videoBvid": "BV1fSWc6cE7y",
  "cid": 42696312836,
  "danmakuFetched": 31,
  "uniqueSenders": 26,
  "perMinute": 7.85,
  "peakMinute": 1,
  "peakMinuteCount": 14,
  "firstAtSeconds": 9.4,
  "lastAtSeconds": 203.0,
  "sample": [
    {
      "atSeconds": 9.4,
      "text": "我昨天梭哈第一组右侧赢了"
    },
    {
      "atSeconds": 17.8,
      "text": "可惜了，要是按照刚开始的赔率，龙龙能有200的，有智慧的人还是太多了"
    },
    {
      "atSeconds": 38.4,
      "text": "四个亡语，我能说什么"
    }
  ],
  "sentiment": {
    "polarity": "neutral",
    "score": 0.03
  },
  "scrapedAt": "2026-10-13T12:09:13Z"
}
```

### Output fields

| Field | Description |
|---|---|
| `type` | `video` or `creator`. |
| `bvid`, `aid`, `url` | Video ids and link. |
| `title`, `description`, `cover` | Video text and cover image. |
| `durationSeconds`, `publishedAt` | Length and publish time (UTC). |
| `category`, `categoryId`, `tags` | Category name (when Bilibili sends it), numeric id, and tags. |
| `authorMid`, `authorName` | Creator id and name. |
| `stats` | `views`, `likes`, `coins`, `favorites`, `shares`, `danmaku`, `comments`. |
| `source`, `searchTerm`, `position` | Where the video came from and its rank. |
| `mid`, `name`, `bio`, `followers`, `following`, `videoCount`, `totalLikes`, `level`, `verified`, `verifiedTitle` | Creator rows. |
| `rpid`, `parentRpid`, `videoBvid`, `text`, `likes`, `replyCount`, `publishedAt`, `authorMid`, `authorName`, `authorLevel` | Comment rows (`parentRpid` on replies). |
| `danmakuFetched`, `uniqueSenders`, `perMinute`, `peakMinute`, `peakMinuteCount`, `firstAtSeconds`, `lastAtSeconds`, `sample` | Danmaku profile rows. |
| `sentiment` | `polarity` and `score`, when sentiment is on. |
| `error` | Only on failed items: `NOT_FOUND`, `BLOCKED` or `REQUEST_FAILED`. Not charged. |

### Pricing

| Event | Price |
|---|---|
| `video` | $2 per 1,000 videos |
| `creator` | $2 per 1,000 creators |
| `comment` | $2 per 1,000 comments or replies |
| `danmaku-profile` | $5 per 1,000 videos profiled |

Proxy and compute are included. Set a maximum total charge on the run to cap your spend; the Actor stops cleanly when it is reached.

### FAQ

**Do I need a proxy or a Bilibili account?** No. The Actor uses Bilibili's public web data without login. If
Bilibili rate-limits a request, it switches to Apify Proxy automatically, at no extra cost to you.

**How many comments can I get?** Without login Bilibili shows the top 3 comments of each video; the Actor
returns them with all their replies. Deeper comment pages need a logged-in session, which this Actor does not use.

**Which personal data is included?** Only what Bilibili shows publicly next to content: creator channel facts and,
on comments, the commenter's public name, id and level. Sex, birthday and location are left out.

**Why is the category empty on some videos?** Bilibili often sends only the category id in video details;
`categoryId` is always filled when available.

**How many results can I get per search?** Bilibili shows up to about 1,000 results per query. Use several
related terms, or sort by newest, to go further.

### Issues

Open an issue in the Issues tab; I reply within 24 hours. If the Actor helped you, a review on the Store helps a
lot.

# Actor input Schema

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

Search videos by keyword, get specific videos by URL, only the comments of given videos, trending videos, the top 100 ranking, or creators with their videos.

## `searchTerms` (type: `array`):

Keywords to search, one per line (Chinese or English). Used in Search mode.

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

Links like https://www.bilibili.com/video/BV1GApX6hEXE or bare BV ids. Used in Videos and Comments modes.

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

Links like https://space.bilibili.com/546195 or bare numeric ids. Used in Creators mode.

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

Per search term, per creator (0 = profile only), or in total for trending and ranking. Search goes up to 5,000 per term (past 1,000 it walks back in 30-day windows); ranking up to 100.

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

Order of search results.

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

Filter search results by length.

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

Only videos published on or after this date, YYYY-MM-DD.

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

Only videos published on or before this date, YYYY-MM-DD.

## `searchAliases` (type: `array`):

More queries searched together with each term (for example a brand's Chinese name). Results are merged and duplicates removed.

## `autoLocalize` (type: `boolean`):

For well-known brands typed in English (apple, nike, tesla...), also search their Chinese name (苹果, 耐克, 特斯拉).

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

Category of the top 100 ranking. Used in Ranking mode.

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

Open each video for coins, shares, likes and tags, at the same price. On by default: search and creator lists lack coins and shares. Trending and ranking already include them. Turn off for faster runs with list data only.

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

Add comments and their replies for each video. Without login Bilibili shows the top 3 comments per video; their replies come complete.

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

Comments plus replies per video.

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

Which comments come first.

## `includeReplies` (type: `boolean`):

Add replies under each comment.

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

One row per video summarizing its danmaku (on-screen comments): how many, unique senders, per-minute rate, peak minute and a sample of texts across the timeline.

## `danmakuSampleSize` (type: `integer`):

Danmaku texts in the sample, spread across the video.

## `sentiment` (type: `boolean`):

Add a simple sentiment (positive, negative or neutral, score -1 to +1) to comments and danmaku profiles. Lexicon-based for Chinese and English.

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

Usually not needed. Without a proxy, the Actor switches to Apify Proxy by itself if Bilibili blocks a request.

## Actor input object example

```json
{
  "mode": "search",
  "searchTerms": [
    "原神"
  ],
  "maxItems": 50,
  "sort": "relevance",
  "duration": "any",
  "autoLocalize": true,
  "rankingCategory": "all",
  "includeDetails": true,
  "includeComments": false,
  "maxComments": 20,
  "commentSort": "hot",
  "includeReplies": true,
  "includeDanmaku": false,
  "danmakuSampleSize": 25,
  "sentiment": false,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

Table of videos with their stats.

## `creators` (type: `string`):

Table of creators (Creators mode).

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

Table of comments and replies (when comments are included).

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

One row per video with danmaku statistics and a sample (when danmaku is included).

## `all` (type: `string`):

Every field of every item, including tags and 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 = {
    "searchTerms": [
        "原神"
    ]
};

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

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

```

## MCP server setup

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