# B站数据 API | Bilibili video search comments user data (`socialdatax/socialdatax-bilibili-data-api`) Actor

社媒数据助手 SocialDataX 提供的只读 B站 / 哔哩哔哩 / Bilibili data API，支持 Bilibili video search / B站视频搜索、article search / 专栏搜索、content details / 内容详情、Bilibili comments / B站评论导出、comment replies / 评论回复、likes and reposts / 赞转列表、user profiles / 用户资料和用户发布列表。

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

## Pricing

from $4.99 / 1,000 dataset items

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## B站数据 API | Bilibili video search comments user data

这是社媒数据助手 SocialDataX 的 Apify Actor 适配层，提供只读 B站 / 哔哩哔哩 / Bilibili data API。常见用法包括 Bilibili video search / B站视频搜索、article search / 专栏搜索、content details / 内容详情、Bilibili comments / Bilibili video comments / B站评论导出、comment replies / 评论回复、likes and reposts / 赞转列表、user profiles / 用户资料和用户发布列表。

Apify 用户无需配置 SocialDataX API Key；直接通过 Apify Console、Apify API、Dataset export 或自动化工作流运行即可。

支持能力：

- 视频搜索 / video search
- 专栏搜索 / article search
- 内容详情 / content details
- 评论列表 / Bilibili comments
- 评论回复 / comment replies
- 专栏/动态赞转列表 / likes and reposts for articles and dynamics
- 用户资料 / user profiles
- 用户视频列表 / creator videos
- 用户专栏列表 / creator articles
- 用户动态列表 / creator dynamics

This Actor is a read-only, unofficial data API integration. It is not affiliated with Bilibili.

### Support / 联系我们

如果 run 失败、需要更高用量，或想接入批量数据工作流，请通过 SocialDataX support 联系我们：

- Website: <https://socialdatax.com/>

If a run fails, you need higher limits, or you want to discuss a bulk data workflow, contact SocialDataX support:

- Website: <https://socialdatax.com/>

### 选择字段

先选择 `operation`，再填写该 operation 需要的字段。Apify 表单里其它字段可以留空；即使误填了无关字段，Actor 也会忽略。

| Operation | 必填字段 | 可选字段 | 说明 |
| --- | --- | --- | --- |
| `search_videos` | `keyword` | `sort_type`, `publish_time_range`, `duration_range`, `page_token`, `max_items`, `auto_paginate` | 按关键词搜索 B站视频，默认会自动翻页直到达到 `max_items`。 |
| `search_articles` | `keyword` | `sort_type`, `category`, `page_token`, `max_items`, `auto_paginate` | 按关键词搜索 B站专栏。 |
| `get_content_detail` | `url` 或 `content_id` 至少填一个 | 无 | 获取视频、专栏或动态详情；两者都填时优先使用 `url`。 |
| `get_content_comments` | `url` 或 `content_id` 至少填一个 | `sort_type`, `page_token`, `max_items`, `auto_paginate` | 获取视频、专栏或动态的一级评论；两者都填时优先使用 `url`。 |
| `get_content_comment_replies` | `comment_object_id`, `comment_object_type`, `comment_id` | `page_token`, `max_items`, `auto_paginate` | 获取某条一级评论下的回复。先运行 `get_content_comments`，从同一条 Dataset 行复制这三个字段。 |
| `get_content_likes_and_reposts` | `post_id` 或 `url` 至少填一个 | `page_token`, `max_items`, `auto_paginate` | 获取 opus/动态帖子赞转列表；视频链接、BV/av ID、read/cv 或 read/mobile 专栏链接和 cv 专栏 ID 暂不支持。 |
| `get_user_info` | `user_id` 或 `profile_url` 至少填一个 | 无 | 获取用户资料；两者都填时优先使用 `profile_url`。 |
| `list_user_videos` | `user_id` 或 `profile_url` 至少填一个 | `sort_type`, `page_token`, `max_items`, `auto_paginate` | 获取用户发布视频列表。 |
| `list_user_articles` | `user_id` 或 `profile_url` 至少填一个 | `page_token`, `max_items`, `auto_paginate` | 获取用户发布专栏列表。 |
| `list_user_dynamics` | `user_id` 或 `profile_url` 至少填一个 | `page_token`, `max_items`, `auto_paginate` | 获取用户发布动态列表。 |

### 字段填写建议 / Input tips

- `keyword`: 用于 `search_videos` 和 `search_articles`。默认示例是 `露营`。
- `url`: 推荐直接粘贴 B站视频、专栏或动态链接，适用于详情和评论。
- `content_id`: 只填真实内容 ID；如果只有链接，请直接填 `url`。
- `comment_object_id`、`comment_object_type`、`comment_id`: 只从 `get_content_comments` 的同一条 Dataset row 复制。不要粘贴内容链接或分享文案。
- `post_id`: 仅用于 `get_content_likes_and_reposts` 的 opus/动态帖子赞转列表。请先运行 `get_content_detail`，再使用 Dataset 行里的 `post_id` 或 `post.share_url`；视频链接、BV/av ID、read/cv 或 read/mobile 专栏链接和 cv 专栏 ID 暂不支持赞转列表。
- `profile_url`: 推荐直接粘贴完整 B站主页链接，例如 `https://space.bilibili.com/{id}`，适用于用户资料和用户发布列表；用户类 operation 不要填 `b23.tv` 短链接。
- `user_id`: 只填 B站数字 `user_id` / `mid`，也就是用户主页 `space.bilibili.com/{id}` 里的数字 ID。不要填昵称、主页名称、BV 号或 aid；如果只有主页链接，请填 `profile_url`。
- `sort_type`: 不同 operation 的可选值不同。留空时 Actor 会按 operation 使用默认排序。

如果用户把内容链接填到用户类 operation、把主页链接填到内容类 operation，或在评论回复里粘贴内容链接/分享文案，Actor 会跳过 SocialDataX API 请求并在 `OUTPUT` 写入中英文 warning 和支持链接，避免因为明显可修正的输入问题直接失败。

### 输入示例

视频搜索：

```json
{
  "operation": "search_videos",
  "keyword": "露营",
  "page_token": "",
  "max_items": 20,
  "auto_paginate": true
}
```

专栏搜索：

```json
{
  "operation": "search_articles",
  "keyword": "露营",
  "category": "technology",
  "page_token": "",
  "max_items": 20,
  "auto_paginate": true
}
```

内容详情：

```json
{
  "operation": "get_content_detail",
  "url": "https://www.bilibili.com/video/BV1VCVS6PEAd"
}
```

评论列表：

```json
{
  "operation": "get_content_comments",
  "url": "https://www.bilibili.com/video/BV1FZNW6JEKP",
  "page_token": "",
  "sort_type": "hot",
  "max_items": 20,
  "auto_paginate": true
}
```

评论回复：

```json
{
  "operation": "get_content_comment_replies",
  "comment_object_id": "1317705",
  "comment_object_type": 12,
  "comment_id": "1124008638",
  "page_token": "",
  "max_items": 20,
  "auto_paginate": true
}
```

用户视频：

```json
{
  "operation": "list_user_videos",
  "profile_url": "https://space.bilibili.com/402951597",
  "page_token": "",
  "max_items": 20,
  "auto_paginate": true
}
```

`max_items` 默认 `50`，最大 `1000`。`auto_paginate=false` 时只请求当前 `page_token`。

如果用户在 Apify run options 里设置了更低的 paid Dataset item 上限，Actor 会把列表类 `max_items` 自动裁剪到该上限，避免超预算请求过多页面。如果该上限为 `0`，Actor 会直接结束并在 `OUTPUT` 写入 warning，不会请求 SocialDataX API。

### Apify 计划要求

持续使用需要 Apify paid plan。Apify free plan 用户有 5 次 SocialDataX API request 试用额度；每次请求一个接口页面计 1 次，`auto_paginate=true` 时每翻一页都会计入一次。试用额度用完后，请升级 Apify 计划继续使用。

Ongoing use requires an Apify paid plan. Free-plan users get a 5-request SocialDataX API trial. Each requested page counts as one request, so `auto_paginate=true` can consume multiple requests in one run.

### 输出

Actor 会把结果写入 Apify Dataset，适合 JSON、CSV、Excel / XLSX、JSONL 等格式导出。

列表类接口会为 `items[]` 中的每个元素写入一条扁平 dataset row：

```json
{
  "operation": "get_content_comments",
  "item_index": 1,
  "query_content_id": "BV1FZNW6JEKP",
  "query_page_token": "",
  "query_sort_type": "hot",
  "query_max_items": 20,
  "query_auto_paginate": true,
  "comment_object_id": "1317705",
  "comment_object_type": 12,
  "comment_id": "1124008638",
  "content": "这个视频很有用。",
  "reply_count": 2,
  "like_count": 9,
  "author_user_id": "20001",
  "author_name": "评论作者",
  "page_request_index": 1,
  "page_item_count": 20,
  "page_next_page_token": "next-token",
  "page_has_more": true
}
```

详情类接口会写入一条 dataset row。`author`、`user`、`video`、`post` 等常见对象会展开为 `author_*`、`user_*`、`video_*`、`post_*` 字段；图片、话题和数组字段保留 JSON 值。

如果某一页 `items` 为空但仍有分页信息，Actor 会写入一条 `empty_page=true` 的 summary row，避免丢失 `next_page_token`。如果空页已经没有下一页，则不会写入 Dataset row。

如果 run 失败，`OUTPUT` 会保留一条轻量失败摘要，方便在 Apify 控制台里直接看到请求次数、状态码和简要错误信息。

### Apify API 调用

同步运行并直接获取 Dataset items：

```bash
curl -X POST "https://api.apify.com/v2/acts/socialdatax~socialdatax-bilibili-data-api/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "search_videos",
    "keyword": "露营",
    "page_token": "",
    "max_items": 20,
    "auto_paginate": true
  }'
```

Python client 示例：

```python
from apify_client import ApifyClient

client = ApifyClient("<APIFY_TOKEN>")
run = client.actor("socialdatax/socialdatax-bilibili-data-api").call(run_input={
    "operation": "search_videos",
    "keyword": "露营",
    "page_token": "",
    "max_items": 20,
    "auto_paginate": True,
})
items = client.dataset(run["defaultDatasetId"]).list_items().items
```

### 费用

Apify 用户按 Actor 页面展示的 Apify 价格和用量计费，不需要购买或配置 SocialDataX API Key。

# Actor input Schema

## `operation` (type: `string`):

先选择要调用的 B站 / Bilibili 数据能力，然后只填写该 operation 需要的字段；无关字段会被忽略。Choose one Bilibili data operation first, then fill only the fields used by that operation.

## `keyword` (type: `string`):

operation=search\_videos 或 search\_articles 时必填；其它 operation 可留空。Required for video search and article search.

## `sort_type` (type: `string`):

搜索、评论和用户视频列表使用。视频搜索支持 general、view\_count\_descending、time\_descending、danmaku\_count\_descending、collect\_count\_descending；专栏搜索支持 general、time\_descending、view\_count\_descending、like\_count\_descending、comment\_count\_descending；评论支持 hot、time\_descending；用户视频支持 time\_descending、view\_count\_descending、collect\_count\_descending。

## `category` (type: `string`):

仅 operation=search\_articles 时使用。可选 all、animation、gaming、film\_and\_tv、lifestyle、hobbies、light\_novel、technology、notes。

## `publish_time_range` (type: `string`):

仅 operation=search\_videos 时使用。可选 all、day、week、half\_year。

## `publish_time_start_date` (type: `string`):

仅 operation=search\_videos 且需要自定义发布时间范围时使用；格式 YYYY-MM-DD。自定义日期范围时 publish\_time\_range 保持 all，并同时填写结束日期。

## `publish_time_end_date` (type: `string`):

仅 operation=search\_videos 且需要自定义发布时间范围时使用；格式 YYYY-MM-DD。自定义日期范围时 publish\_time\_range 保持 all，并同时填写开始日期。

## `duration_range` (type: `string`):

仅 operation=search\_videos 时使用。可选 all、under\_10\_minutes、between\_10\_and\_30\_minutes、between\_30\_and\_60\_minutes、over\_60\_minutes。

## `url` (type: `string`):

operation=get\_content\_detail、get\_content\_comments、get\_content\_likes\_and\_reposts 时使用。详情和评论可粘贴 B站视频、专栏或动态链接；赞转列表仅支持 opus/动态帖子链接，不支持视频链接或 read/cv、read/mobile 专栏链接。

## `content_id` (type: `string`):

operation=get\_content\_detail 或 get\_content\_comments 时可填；如果有 B站视频、专栏或动态链接，推荐直接填 url。

## `post_id` (type: `string`):

仅 operation=get\_content\_likes\_and\_reposts 时使用；请填写 get\_content\_detail 返回的 post\_id，或填写 opus/动态帖子 url。视频链接、BV/av ID、cv 专栏 ID 暂不支持赞转列表。

## `comment_object_id` (type: `string`):

仅 operation=get\_content\_comment\_replies 时必填。先运行 get\_content\_comments，在 Dataset 里找到 reply\_count > 0 的一级评论行，复制 comment\_object\_id。

## `comment_object_type` (type: `integer`):

仅 operation=get\_content\_comment\_replies 时必填。请从 get\_content\_comments 的同一条 Dataset 行复制 comment\_object\_type。

## `comment_id` (type: `string`):

仅 operation=get\_content\_comment\_replies 时必填。请从 get\_content\_comments 的同一条 Dataset 行复制 comment\_id。

## `user_id` (type: `string`):

operation=get\_user\_info、list\_user\_videos、list\_user\_articles、list\_user\_dynamics 时至少提供 user\_id 或 profile\_url 之一；只填 B站数字 user\_id / mid，不要填昵称、主页名称、BV 号或 aid。

## `profile_url` (type: `string`):

operation=get\_user\_info、list\_user\_videos、list\_user\_articles、list\_user\_dynamics 时使用。推荐直接粘贴完整 Bilibili / B站主页链接，例如 https://space.bilibili.com/{id}；用户类 operation 不要填 b23.tv 短链接。

## `page_token` (type: `string`):

搜索、评论、评论回复、赞转列表和用户内容列表继续翻页时传入上一页返回的完整 next\_page\_token；第一页留空。auto\_paginate=true 时通常不用手动填写。

## `max_items` (type: `integer`):

最多写入多少条 Dataset item。对搜索、评论、评论回复、赞转列表和用户内容列表用于限制自动翻页结果；较大的值可能触发多次 SocialDataX API request。

## `auto_paginate` (type: `boolean`):

开启后 Actor 会按 next\_page\_token 继续请求，直到达到 max\_items 或没有下一页。关闭时只请求当前 page\_token。每翻一页计 1 次 SocialDataX API request。

## Actor input object example

```json
{
  "operation": "search_videos",
  "keyword": "露营",
  "category": "all",
  "publish_time_range": "all",
  "duration_range": "all",
  "max_items": 50,
  "auto_paginate": true
}
```

# Actor output Schema

## `dataset` (type: `string`):

Open flat result rows written to the default Apify Dataset. Export as JSON, CSV, Excel / XLSX, or JSONL.

## `keyValueStore` (type: `string`):

Open the default key-value store. The OUTPUT record contains operation, item count, request count, page-level response summaries, non-fatal warnings, and lightweight failure details when a run fails.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("socialdatax/socialdatax-bilibili-data-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("socialdatax/socialdatax-bilibili-data-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call socialdatax/socialdatax-bilibili-data-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=socialdatax/socialdatax-bilibili-data-api",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/Fjuk8Dw6aaqzYi3hp/builds/UXgjJUHHSMdde2gdu/openapi.json
