# B站 关键词搜索 API (bilibili.search)

- Canonical page: https://everyinfra.com/bilibili-api/search
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "bilibili", "action": "search", "params": {...}}
- Price: $0.000556 per call ($0.56 per 1,000 requests); failed calls and empty results are not charged
- Returns: list, default 20, max 50 per call
- Mode: sync; add "mode": "async" for slow tasks

B站关键词搜索按 `keyword` 检索视频，返回标题、简介、时长、播放、点赞、评论、弹幕、收藏、投币和分享数，以及分区、标签、UP 主和发布时间。它回答「这个主题在 B 站上有哪些视频、哪些最受欢迎」，适合做选题研究、品牌声量观察和寻找合作 UP 主。

用 `sort` 按综合、最新、播放量或评论排序；注意 `most_liked` 实际是收藏优先，不是按点赞量排序。比较热度时可以多看 `coin_count`：投币是 B 站用户的付费级好评，比点赞含金量高；`danmaku_count` 和评论数并列，能反映观看时的活跃程度。

## Health

- Live health (24h percent, hourly and daily trends): https://api.everyinfra.com/api/v1/social/availability?platform=bilibili&action=search

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| keyword | not declared | yes | not declared | B 站视频搜索词，可填视频标题或主题；不是 UP 主昵称精确查询。查询 UP 主资料或投稿请使用 user_id。 |
| sort | enum: most_commented / most_liked / most_viewed / newest / relevance | no | not declared | 视频排序：relevance 综合、newest 最新、most_viewed 播放量、most_commented 评论相关、most_liked 按收藏量优先，不是点赞量。这组排序只作用于视频搜索，不决定 comments 的评论顺序。 |
| limit | integer (1–50) | no | 20 | 这次调用最多返回的条数，整数，1–50；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| url | 该记录在原平台上的可访问链接。 |
| title | 标题。平台无标题概念时（如纯文本帖）为 null。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| duration_seconds | 时长，单位秒。非视频/音频内容为 null。 |
| duration_sec | platform-native meaning |
| duration_text | 时长的展示文本（如 12:34）。 |
| view_count | 浏览/播放数。null 表示不公开，不等于 0。 |
| like_count | 点赞数。null 表示该平台或该接口不公开此数据，不等于 0。 |
| comment_count | 评论数。null 表示不公开，不等于 0。 |
| danmaku_count | 弹幕数。**B站特有的互动指标，与评论数并列看活跃度**。 |
| favorite_count | 收藏数。 |
| coin_count | 投币数。B站的付费级好评，比点赞含金量高。 |
| share_count | 分享/转发数。null 表示不公开，不等于 0。 |
| thumbnail_url | 缩略图链接，分辨率低于 image_url。 |
| posted_at | 发布时间，ISO 8601 格式、UTC 时区（如 2026-08-07T12:34:56+00:00）。平台只给非标准字符串时原样透传，解析前建议做容错。null 表示平台未公开。 |
| category | 分类名称，取值为原平台的分类体系，未做跨平台归一。 |
| author_name | 作者昵称（显示名）。 |
| author_id | 作者在原平台的唯一 ID。 |
| author_url | 作者在原平台的主页链接。 |
| platform | 数据来源平台标识，与请求里的 platform 一致（如 xiaohongshu、tiktok）。 |
| tags | 标签数组。无标签时为空数组，不是 null。 |

## Example

```bash
curl -X POST 'https://api.everyinfra.com/api/v1/social' \
  -H "Authorization: Bearer $EVERYINFRA_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "platform": "bilibili",
  "action": "search",
  "params": {
    "keyword": "摄影入门"
  }
}'
```

```python
import os
import requests

response = requests.post(
    "https://api.everyinfra.com/api/v1/social",
    headers={"Authorization": f"Bearer {os.environ['EVERYINFRA_API_KEY']}"},
    json={
        "platform": "bilibili",
        "action": "search",
        "params": {
            "keyword": "摄影入门",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

Real response to the example request above, captured 2026-09-26T08:56:04Z. `results` and `count` are real with personal information (names, handles, avatars, profile links, contact details) removed; the list keeps the first 2 of 17. `id`, `billing` and `quota` differ on every call, so only their shape is shown.

```text
{
  "id": "req_…",
  "platform": "bilibili",
  "action": "search",
  "results": [
    {
      "id": "BV1pv411H78e",
      "url": "https://www.bilibili.com/video/BV1pv411H78e",
      "title": "从零开始手把手教你学摄影，20节课带你从小白到大师 | 摄影前期拍摄入门教程",
      "text": "此课程是一套面向零基础小白的零基础摄影前期拍摄系统教程，分为4大部分，一共20节，由浅入深。课程从器材讲解到参数技巧，最后带领大家实战拍摄，可以快速带大家入门摄影，录制于2020年，因故未能发布，现在作为福利分享给大家~\r\n\r\nPS： 如果大家觉得有帮助的话，求个一键三连~\r\n\r\nPART1 知己知彼——认识你的器材\r\nPART2 基础入门——学懂枯燥的参数\r\nPART3 技能提升——拍摄技巧全解\r\nPART4 综合运用——带你复盘拍摄现场",
      "duration_seconds": 28849,
      "duration_text": "480:49",
      "view_count": 8307391,
      "like_count": 301661,
      "comment_count": 3799,
      "danmaku_count": 38430,
      "favorite_count": 752984,
      "thumbnail_url": "https://i1.hdslb.com/bfs/archive/d293a1682ffac131d109bd6180c4df644f632388.png",
      "posted_at": "2021-07-02T03:56:53+00:00",
      "category": "数码",
      "author_name": "•••",
      "author_id": "•••",
      "author_url": "https://space.bilibili.com/•••",
      "platform": "bilibili",
      "tags": [
        "教程",
        "摄影",
        "相机"
      ]
    },
    {
      "id": "BV1MceuzVEz7",
      "url": "https://www.bilibili.com/video/BV1MceuzVEz7",
      "title": "【吊打付费】目前B站最完整的摄影教程，包含了所有干货内容！这还没人看，我不更了！！！",
      "text": "一个冷知识：点赞是免费的！但是可以让辛苦做视频的UP主开心快乐一整天！！！\n 我给大家准备了摄影礼包，评论“666”即可得",
      "duration_seconds": 71221,
      "duration_text": "1187:1",
      "view_count": 2186277,
      "like_count": 50942,
      "comment_count": 12382,
      "danmaku_count": 6525,
      "favorite_count": 124107,
      "thumbnail_url": "https://i2.hdslb.com/bfs/archive/5fffaef73d60995cf40a9336b58fe68b15ca5033.jpg",
      "posted_at": "2025-08-20T09:20:00+00:00",
      "category": "数码",
      "author_name": "•••",
      "author_id": "•••",
      "author_url": "https://space.bilibili.com/•••",
      "platform": "bilibili",
      "tags": [
        "摄影入门",
        "新手摄影",
        "零基础学摄影"
      ]
    }
  ],
  "count": 17,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### `most_liked` 为什么不是按点赞排？

在当前映射里，`most_liked` 实际是收藏优先，不是点赞量。想看点赞最多的视频，可以拿到结果后按 `like_count` 自行排序。

### 怎么判断视频真正受不受欢迎？

除了 `view_count`，多看 `coin_count`、`favorite_count` 和 `danmaku_count`：投币是付费级好评，收藏和弹幕反映观众的投入程度，几项结合起来比单看播放量更可靠。

### 能按 UP 主搜索吗？

`keyword` 搜的是视频标题和主题，不是 UP 主昵称的精确查询。要看某个 UP 主的资料或投稿，用结果里的 `author_id` 调 B 站的主页或用户内容能力。

## Also

- Capability catalog (no key): https://api.everyinfra.com/api/v1/social/catalog?platform=bilibili
- OpenAPI: https://everyinfra.com/openapi.json · Agents guide: https://everyinfra.com/agents.md
