嗶哩嗶哩(bilibili)留言 API
依 2026-11-21 規格整理
快速解答
POST /bilibili/pushs/task 帶 /video/BV... 網址,會建立蒐集該影片留言的非同步任務;crawl_second_layer(預設 true)會一併蒐集每則留言底下的回覆。以 GET /bilibili/pushs/task/{task_id} 輪詢,DONE 時回傳 task、total_count 與 data,由新到舊,每頁最多 1000 則。每則留言有 post_id(影片的文件 ID)、push_type(comment 或 reply)、留言者、內容、時間與情緒標籤。蒐集範圍有上限:一個任務最多蒐集影片最熱門的 3 則第一層留言,以及每則底下的前 20 則回覆。資料以網路爬蟲蒐集嗶哩嗶哩公開發布的內容。
常見用途
- 看產品評測或品牌影片底下最顯眼的反應。
- 比較同一主題多支影片的熱門留言情緒。
- 搭配關鍵字搜尋,追蹤重要影片底下的討論。
端點一覽
Base URL 為 https://api.infominer.io/api/v2,每個請求以 auth-header 標頭帶 API 金鑰。
| 方法 | 路徑 | 說明 |
|---|---|---|
| POST | /bilibili/pushs/task |
以 /video/BV... 網址建立留言任務,可一併蒐集回覆。 |
| GET | /bilibili/pushs/task/{task_id} |
輪詢留言任務;DONE 時回傳留言,每頁最多 1000 筆。 |
請求參數
POST /bilibili/pushs/task
| 參數 | 位置 | 型別 | 必填 | 預設值/可用值 | 說明 |
|---|---|---|---|---|---|
post_url |
body | string | 是 | B 站影片網址 https://www.bilibili.com/video/BV.../(可帶追蹤參數)。不接受 av 號網址與 b23.tv 短網址。 | |
crawl_second_layer |
body | boolean | 否 | true |
一併蒐集每則留言底下的回覆。 |
max_pages |
body | integer | 否 | 50(最多 200) |
第一層留言最多爬取的頁數;0 或省略時用預設值。 |
rerun |
body | boolean | 否 | 為了與其他平台一致而接受此參數;每次 POST 都會建立新任務。 |
GET /bilibili/pushs/task/{task_id}
| 參數 | 位置 | 型別 | 必填 | 預設值/可用值 | 說明 |
|---|---|---|---|---|---|
task_id |
path | string | 是 | 建立任務時回傳的任務 ID。 | |
page |
query | integer | 否 | 1 |
頁碼,從 1 開始。 |
pageSize |
query | integer | 否 | 1000 |
每頁留言數,最多 1000。 |
回應欄位
| 資料 | 欄位 | 端點 |
|---|---|---|
| 留言與回覆(data) | id, post_id, author_id, author, push_type, region, content, tm, tm_crawler, sentiment | GET /bilibili/pushs/task/{task_id} |
| 任務(task) | task: id, post_url, status, crawl_second_layer, created_at, total, completed, pages_crawled, reported_total, partial, timed_out, failed_pages, failed_batches, bvid | GET /bilibili/pushs/task/{task_id} |
程式碼範例
curl:建立任務
curl -X POST https://api.infominer.io/api/v2/bilibili/pushs/task \
-H "auth-header: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"post_url": "https://www.bilibili.com/video/BV1000000001/", "crawl_second_layer": true}'
curl:以任務 ID 輪詢
curl "https://api.infominer.io/api/v2/bilibili/pushs/task/$TASK_ID?page=1&pageSize=1000" \
-H "auth-header: YOUR_API_KEY"
Python(requests):建立、輪詢、讀取
import time
import requests
BASE_URL = "https://api.infominer.io/api/v2"
HEADERS = {"auth-header": "YOUR_API_KEY"}
# 1. Create the task
resp = requests.post(
f"{BASE_URL}/bilibili/pushs/task",
headers=HEADERS,
json={
"post_url": "https://www.bilibili.com/video/BV1000000001/",
"crawl_second_layer": True,
},
timeout=30,
)
resp.raise_for_status()
task = resp.json()
# 2. Poll until the task leaves INIT / RUNNING
for _ in range(120):
resp = requests.get(
f"{BASE_URL}/bilibili/pushs/task/{task['id']}",
headers=HEADERS,
params={
"page": 1,
"pageSize": 1000,
},
timeout=30,
)
resp.raise_for_status()
result = resp.json()
status = result.get("status") or result.get("task", {}).get("status")
if status not in ("INIT", "RUNNING"):
break
time.sleep(15)
else:
raise SystemExit("task still running; poll it again later")
task = result.get("task", result)
if status != "DONE" or task.get("partial") or task.get("timed_out"):
raise SystemExit(f"task ended with status {status}; no complete result")
# 3. Read the records (use page / pageSize to fetch further pages)
for row in result.get("data", []):
print(row.get("push_type"), row.get("author"), (row.get("content") or "")[:60])
示意回應樣本
以下為人工撰寫的示意資料:帳號為 sample_user_n,ID 明顯為假值。欄位依 2026-11-21 規格,範例只列出部分欄位。
任務 DONE 後的輪詢回應(示意資料)
{
"task": {
"id": "00000000-0000-4000-8000-000000000001",
"post_url": "https://www.bilibili.com/video/BV1000000001/",
"status": "DONE",
"crawl_second_layer": true,
"created_at": 1780880400,
"total": 3,
"completed": 3,
"pages_crawled": 1,
"reported_total": 46,
"timed_out": false,
"partial": false,
"failed_pages": 0,
"failed_batches": 0,
"bvid": "BV1000000001"
},
"total_count": 3,
"data": [
{
"id": "00000000-0000-4000-8000-000000000003",
"post_id": "00000000-0000-4000-8000-000000000001",
"author_id": "0000000003",
"author": "sample_user_3",
"tm": 1780745400,
"tm_crawler": 1780880403,
"push_type": "comment",
"region": "",
"content": "清单很实用,第一次去营地就照着准备了",
"sentiment": "Positive"
},
{
"id": "00000000-0000-4000-8000-000000000004",
"post_id": "00000000-0000-4000-8000-000000000001",
"author_id": "0000000004",
"author": "sample_user_4",
"tm": 1780743600,
"tm_crawler": 1780880406,
"push_type": "reply",
"region": "",
"content": "请问睡袋选的是几度的?",
"sentiment": "Neutral"
},
{
"id": "00000000-0000-4000-8000-000000000005",
"post_id": "00000000-0000-4000-8000-000000000001",
"author_id": "0000000005",
"author": "sample_user_5",
"tm": 1780741800,
"tm_crawler": 1780880409,
"push_type": "comment",
"region": "",
"content": "防潮垫那段讲得很清楚",
"sentiment": "Positive"
}
],
"page": 1,
"pageSize": 1000
}
限制與注意事項
- 一個任務最多蒐集影片最熱門的 3 則第一層留言,以及每則底下的前 20 則回覆,所以 completed 遠低於 reported_total(B 站顯示的留言數)是正常的。
- B 站留言的 region(IP 所在地)一律為空值。
- 不接受 av 號網址與 b23.tv 短網址,請先展開成 /video/BV... 網址。
- 只有 DONE 的輪詢回應帶資料,PARTIAL、TIMED_OUT 與 FAILED 只回傳任務物件。status 為 DONE 且 partial、timed_out 都是 false,才算完全成功。
- data 包含這支影片所有已蒐集的留言(含先前任務蒐集的),所以 total_count 與 task.completed 不一定相同。數值是蒐集當下的值。
蒐集方式:以網路爬蟲蒐集各平台公開發布的內容。是否適用於您的用途,依用途與法域由買方法務評估,我們可提供來源與蒐集方式說明。
更多 嗶哩嗶哩(bilibili) API 頁面
- 影片關鍵字搜尋
- 留言
申請試用
填寫下方申請表單時,請註明嗶哩嗶哩,並說明要追的關鍵字或影片、是否需要留言,以及預估資料量。我們會確認範圍,並回覆試用與 API 金鑰的安排。
填寫表單申請試用,專人確認範圍後回覆試用與介接安排。
填寫申請表單常見問題
- 可以蒐集 B 站影片的全部留言嗎?
- 不行。一個任務最多蒐集最熱門的 3 則第一層留言,以及每則底下的前 20 則回覆。比對 task.completed 與 reported_total,可以知道蒐集到的比例。
- B 站留言任務什麼時候會失敗?
- 影片不存在、已刪除、未公開或審核中,留言區已關閉,或 B 站拒絕第一頁請求時,任務會以 FAILED 結束。
- 留言怎麼對應回影片?
- 每則留言的 post_id 是影片的文件 ID,與搜尋結果中同一支影片的 id 相同;任務物件也帶有影片的 bvid。
- 資料是怎麼蒐集的?這是嗶哩嗶哩官方的 API 嗎?
- 資料以網路爬蟲蒐集嗶哩嗶哩公開發布的內容。LargitData 與嗶哩嗶哩沒有隸屬或合作關係,這也不是嗶哩嗶哩自身提供的 API。是否適用於您的用途,依用途與法域由買方法務評估,我們可提供來源與蒐集方式說明。