# Bilibili API: Video Scraper with Stats, Tags and Danmaku (`sauliusautomatesit/bilibili-api`) Actor

Bilibili (B站) videos by keyword search, video URL, creator or trending list: views, likes, coins, favorites, shares, tags and danmaku (bullet comments). No login. $5 per 1,000 videos.

- **URL**: https://apify.com/sauliusautomatesit/bilibili-api.md
- **Developed by:** [Saulius AutomatesIT](https://apify.com/sauliusautomatesit) (community)
- **Categories:** Social media, Videos, AI
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.25 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 API: videos, stats, tags and danmaku

Get [Bilibili](https://www.bilibili.com) (哔哩哔哩) video data in bulk: search by keyword, look up video URLs, pull a creator's latest uploads, or grab the trending lists. Every video comes with views, likes, coins, favorites, shares, danmaku and comment counts, tags, duration, publish date and creator. Add **danmaku** (弹幕, the bullet comments that fly across the video) with the second of the video each one appears at.

No Bilibili account, no cookies of yours, no browser. **$5 per 1,000 videos**, danmaku $0.20 per 1,000.

### What you can use it for

- **Trend and market research in China**: what is rising on Bilibili for a topic, game, product or brand, sorted by views, newest or most danmaku.
- **Creator and influencer research**: a creator's latest videos with engagement, plus their follower count, for KOL shortlists.
- **Brand monitoring**: schedule a daily keyword run and see new videos about your brand as they appear.
- **Audience reaction**: danmaku shows what viewers said at each moment of a video, ready for sentiment analysis or an LLM.
- **Daily trending snapshots**: the Popular list and the Top 100 ranking, saved every day.

### How to use it

1. Fill any mix of **Search keywords**, **Video URLs**, **Creators** or a **Trending list**.
2. Optional: **Sort search by** (relevance, most views, newest, most danmaku, most favorites) and how many videos to keep.
3. Optional: **Full stats and tags for every video** and **Include danmaku**.
4. Run it and download the results as JSON, CSV or Excel, or read them through the API.

#### Input example

```json
{
  "searchQueries": ["minecraft", "原神"],
  "sortBy": "views",
  "maxVideosPerSearch": 100,
  "creators": ["https://space.bilibili.com/2"],
  "trending": "ranking",
  "includeDanmaku": true,
  "maxDanmakuPerVideo": 100
}
```

### Output

One item per video:

```json
{
  "type": "video",
  "bvid": "BV1zmYP6aEdH",
  "aid": "117363672351162",
  "url": "https://www.bilibili.com/video/BV1zmYP6aEdH",
  "title": "我———问你为什么要折断奥特钥匙!！！（大结局下）",
  "thumbnailUrl": "https://i0.hdslb.com/bfs/archive/c2c33ea113452198230ba208d119f9b85c005a0a.jpg",
  "durationSeconds": 713,
  "publishedAt": "2026-10-01T04:09:58.000Z",
  "category": "特摄",
  "tags": ["奥特曼", "鬼畜", "搞笑", "赛罗", "特摄"],
  "authorName": "百火哥斯拉",
  "authorId": "3461573133732544",
  "authorUrl": "https://space.bilibili.com/3461573133732544",
  "views": 2415970,
  "likes": 309605,
  "coins": 350424,
  "favorites": 162084,
  "shares": 34130,
  "danmakuCount": 123836,
  "commentCount": 52371,
  "source": "ranking",
  "position": 1,
  "scrapedAt": "2026-10-03T16:51:59.323Z"
}
```

And, with **Include danmaku**, one item per danmaku:

```json
{
  "type": "danmaku",
  "bvid": "BV1CrHe6ZEvk",
  "videoUrl": "https://www.bilibili.com/video/BV1CrHe6ZEvk",
  "text": "萌趣的世界才受大众喜爱",
  "videoTimeSeconds": 35.212,
  "sentAt": "2026-10-03T16:43:14.000Z",
  "mode": "scroll",
  "color": "#ffffff",
  "fontSize": 25,
  "senderHash": "55f5d787"
}
```

- `source` says where the video came from (`search`, `video`, `creator`, `popular`, `ranking`), with `searchQuery` or `creatorId` and the `position` in that list.
- Search, creator and trending lists give views, likes, favorites and the basics. Coins, shares, comment count and full tags need **Full stats and tags** (single video URLs always have them).
- For creator lookups, `creatorId` and `creatorFollowers` are the creator you asked for. A collab video on their page can have another creator as `authorName`.
- `category` comes from search and trending lists; single video lookups leave it empty.
- `senderHash` is Bilibili's anonymous hash of the sender, not a user id.

The run summary (videos and danmaku delivered, videos not found, failures) is saved as `OUTPUT` in the run's key-value store. Results are in the dataset's **Videos** and **Danmaku** views.

### Pricing

Pay per result, no subscription:

| Event | Price |
|---|---|
| Video | $0.005 ($5 per 1,000 videos) |
| Danmaku | $0.0002 ($0.20 per 1,000) |
| Actor start | $0.00005 |

1,000 videos with full stats cost $5. 100 videos with 200 danmaku each cost $0.50 + $4. Videos that don't exist cost nothing. Bronze, Silver and Gold Apify plans get 5%, 10% and 15% off. Proxy and compute are included.

### Use it from code

#### API (cURL)

```bash
curl -X POST "https://api.apify.com/v2/acts/sauliusautomatesit~bilibili-api/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"searchQueries": ["minecraft"], "maxVideosPerSearch": 20}'
```

#### Python

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_TOKEN")
run = client.actor("sauliusautomatesit/bilibili-api").call(run_input={
    "searchQueries": ["minecraft"],
    "sortBy": "views",
    "maxVideosPerSearch": 100,
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["views"], item["title"], item["url"])
```

#### JavaScript

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

const client = new ApifyClient({ token: 'YOUR_TOKEN' });
const run = await client.actor('sauliusautomatesit/bilibili-api').call({ trending: 'ranking' });
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.map((v) => `${v.position}. ${v.title} (${v.views} views)`));
```

#### MCP (Claude, Cursor, any MCP client)

Add `https://mcp.apify.com/?tools=sauliusautomatesit/bilibili-api` as a remote MCP server and your agent can search Bilibili as a tool.

### Limits, honestly

- **Search goes 1,000 videos deep per keyword** (50 pages of 20), which is as far as Bilibili search goes. Use several narrower keywords or other sort orders for more.
- **Comments are not included.** Bilibili shows only 3 comments per video to visitors who aren't logged in; you get the comment count. Danmaku is fully available.
- **Danmaku**: Bilibili serves the latest few hundred to a few thousand danmaku per video depending on its length, and the Actor keeps up to 1,000, newest first. Older danmaku archives need a login.
- Creator lookups return the creator's videos newest first; very large back catalogues can be read up to the number you set.
- Bilibili rate-limits busy IPs. The Actor switches IP and asks again, so big runs stay reliable but take a little longer.

### Related Actors

- [YouTube Transcript Scraper](https://apify.com/sauliusautomatesit/youtube-transcript-scraper): transcripts of any YouTube video, channel or playlist.
- [Telegram Channel Scraper](https://apify.com/sauliusautomatesit/telegram-channel-scraper): messages, views and reactions from public Telegram channels.
- [Google Trends API](https://apify.com/sauliusautomatesit/google-trends-api): search interest over time, by region, related and rising queries.

### FAQ

**Do I need a Bilibili account?** No. Everything comes from Bilibili's public pages as a visitor.

**Does it work with Chinese keywords?** Yes, any language. Titles, tags and danmaku come back in the original language.

**Can I track the same keyword or creator every day?** Yes. Save the input as a task and schedule it; each run returns the current numbers.

**How fast is it?** About 20 videos a second for lists, slower with full stats or danmaku, 4 tasks in parallel by default (up to 10).

**Is it legal?** It collects publicly visible video data. You are responsible for how you use the data and for complying with the laws that apply to you.

# Actor input Schema

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

One keyword per line, in any language: `minecraft`, `原神`, `AI 教程`. Each keyword returns up to 1,000 videos, which is as deep as Bilibili search goes.

## `sortBy` (type: `string`):

Order of search results.

## `maxVideosPerSearch` (type: `integer`):

How many videos to keep for each keyword, from the top.

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

Single videos to look up, such as `https://www.bilibili.com/video/BV1CrHe6ZEvk` or `BV1CrHe6ZEvk`. These always come with full stats and tags.

## `creators` (type: `array`):

Creator space URLs or numeric ids, such as `https://space.bilibili.com/2`. Returns their latest videos, newest first, with their follower count.

## `maxVideosPerCreator` (type: `integer`):

How many of each creator's latest videos to keep.

## `trending` (type: `string`):

Also collect Bilibili's own trending lists: Popular (综合热门, refreshed through the day) or the Top 100 ranking (排行榜).

## `maxTrendingVideos` (type: `integer`):

How many trending videos to keep. The ranking has 100.

## `fetchDetails` (type: `boolean`):

Search, creator and trending lists already give views, likes and the basics. Turn this on to add coins, shares, comment count, full tags and the description to every video. Same price; runs slower.

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

Also save each video's danmaku: text, the second of the video it appears at, time sent, colour and mode. Charged per danmaku. Turns on full stats.

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

Most recent danmaku to keep per video, newest first. Bilibili serves the latest few hundred to few thousand per video depending on its length.

## `concurrency` (type: `integer`):

How many keywords, videos or creators run at the same time.

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

Apify Proxy is used by default and is included in the price. Change only if you know you need to.

## Actor input object example

```json
{
  "searchQueries": [
    "minecraft"
  ],
  "sortBy": "relevance",
  "maxVideosPerSearch": 20,
  "maxVideosPerCreator": 30,
  "trending": "none",
  "maxTrendingVideos": 100,
  "fetchDetails": false,
  "includeDanmaku": false,
  "maxDanmakuPerVideo": 200,
  "concurrency": 4,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

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

Video items (type video) and danmaku items (type danmaku). Download as JSON, CSV or Excel, or read it from this API endpoint.

## `summary` (type: `string`):

Videos and danmaku delivered, videos not found and failures.

# 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": [
        "minecraft"
    ],
    "maxVideosPerSearch": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("sauliusautomatesit/bilibili-api").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": ["minecraft"],
    "maxVideosPerSearch": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("sauliusautomatesit/bilibili-api").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": [
    "minecraft"
  ],
  "maxVideosPerSearch": 20
}' |
apify call sauliusautomatesit/bilibili-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,sauliusautomatesit/bilibili-api"
        }
    }
}
```

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/FbrkQQZeYEa7v0pag/builds/A7xs5FkHsoXSGzm2e/openapi.json
