小紅書留言 API
依 2026-10-25 規格快照
快速解答
以筆記網址呼叫 POST /xhs/pushs/task,會建立非同步任務,蒐集該則筆記的留言。order_type 可選 hot、time 或 both;crawl_second_layer=true 時一併蒐集第二層回覆;get_all=true 時關閉重複檢查,蒐集全部留言。以 GET /xhs/pushs/task/{task_id} 輪詢;DONE 時回傳留言與 total_count,每頁最多 1000 筆。每則留言以 post_id 指回所屬筆記,並有作者、內文、情感標籤與時間戳記。資料以網路爬蟲蒐集小紅書公開發布的內容。
常見用途
- 閱讀使用者在產品評價與推薦筆記底下提出的問題與抱怨。
- 蒐集使用者在留言中的提問,作為產品頁、常見問題或客服的參考。
- 比較競品相關筆記的留言情感。
端點一覽
Base URL 為 https://api.infominer.io/api/v2,每個請求以 auth-header 標頭帶 API 金鑰。
| 方法 | 路徑 | 說明 |
|---|---|---|
| POST | /xhs/pushs/task |
以筆記網址建立留言任務,可選排序、第二層回覆與關閉重複檢查。 |
| GET | /xhs/pushs/task/{task_id} |
輪詢筆記留言任務;DONE 時回傳留言,每頁最多 1000 筆。 |
請求參數
POST /xhs/pushs/task
| 參數 | 位置 | 型別 | 必填 | 預設值/可用值 | 說明 |
|---|---|---|---|---|---|
post_url |
body | string | 是 | 小紅書筆記網址。 | |
crawl_second_layer |
body | boolean | 否 | false |
一併蒐集第二層回覆。 |
get_all |
body | boolean | 否 | false |
關閉重複檢查,蒐集全部留言。 |
order_type |
body | string | 否 | 預設 hot; 可用值 hot | time | both |
留言排序方式。 |
GET /xhs/pushs/task/{task_id}
| 參數 | 位置 | 型別 | 必填 | 預設值/可用值 | 說明 |
|---|---|---|---|---|---|
task_id |
path | string | 是 | 建立任務時回傳的任務 ID。 | |
page |
query | integer | 否 | 1 |
頁碼,從 1 開始。 |
pageSize |
query | integer | 否 | 1000 |
每頁留言數,最多 1000。 |
回應欄位
| 資料 | 欄位 | 端點 |
|---|---|---|
| 留言 | id, post_id, author, author_id, content, push_type, sentiment, tm, tm_crawler, region | GET /xhs/pushs/task/{task_id} |
程式碼範例
curl:建立任務
curl -X POST https://api.infominer.io/api/v2/xhs/pushs/task \
-H "auth-header: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"post_url": "https://www.xiaohongshu.com/explore/000000000000000000000001", "order_type": "time", "crawl_second_layer": true}'
curl:以任務 ID 輪詢
curl "https://api.infominer.io/api/v2/xhs/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}/xhs/pushs/task",
headers=HEADERS,
json={
"post_url": "https://www.xiaohongshu.com/explore/000000000000000000000001",
"order_type": "time",
"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}/xhs/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")
if status == "FAILED":
raise SystemExit("task failed")
if status != "DONE":
print("task ended with status", status, "- results may be incomplete")
# 3. Read the records (use page / pageSize to fetch further pages)
for row in result.get("data", []):
print(row["post_id"], row["author"], row["content"][:60])
示意回應樣本
以下為人工撰寫的示意資料:帳號為 sample_user_n,ID 為明顯的假值。欄位依 2026-10-25 規格快照;樣本只呈現部分欄位,完整清單見上方表格。
任務狀態為 DONE 後的輪詢回應(示意資料)
{
"task": {
"id": "00000000-0000-4000-8000-000000000001",
"status": "DONE"
},
"total_count": 2,
"data": [
{
"id": "0000000000000101",
"post_id": "000000000000000000000001",
"author": "sample_user_3",
"author_id": "0000000000000003",
"tm": 1781065800,
"tm_crawler": 1781150400,
"content": "请问敏感肌可以用吗?",
"sentiment": "Neutral"
},
{
"id": "0000000000000102",
"post_id": "000000000000000000000001",
"author": "sample_user_4",
"author_id": "0000000000000004",
"tm": 1781067600,
"tm_crawler": 1781150400,
"content": "跟着你的步骤用了两周,脸没那么干了",
"sentiment": "Positive"
}
]
}
限制與注意事項
- 留言每頁最多讀取 1000 筆。
- crawl_second_layer 預設為 false。快照沒有說明第二層回覆在回應中的巢狀方式或與上層留言的關聯,請以試用資料確認。
- 留言任務預設會做重複檢查;要蒐集全部留言時,把 get_all 設為 true。
- 每則筆記的資料量與更新頻率,依專案範圍確認。
蒐集方式:以網路爬蟲蒐集各平台公開發布的內容。是否適用於您的用途,依用途與法域由買方法務評估,我們可提供來源與蒐集方式說明。
更多 小紅書 API 頁面
申請試用
填寫下方申請表單時,請註明小紅書,並說明要搜尋的關鍵字或品類、是否需要留言與第二層回覆,以及預估資料量。我們會確認範圍,並回覆試用與 API 金鑰的安排。
填寫表單申請試用,專人確認範圍後回覆試用與介接安排。
填寫申請表單常見問題
- 可以取得小紅書留言底下的回覆嗎?
- 可以。建立留言任務時把 crawl_second_layer 設為 true。
- post_url 接受哪一種筆記網址?
- 小紅書筆記網址。本頁的樣本使用 https://www.xiaohongshu.com/explore/{note_id};可接受的網址格式請以試用資料確認。
- 留言如何對應到所屬筆記?
- 每筆留言紀錄都有 post_id 欄位,指向所屬筆記。
- 資料是怎麼蒐集的?這是小紅書官方的 API 嗎?
- 資料以網路爬蟲蒐集小紅書公開發布的內容。LargitData 與小紅書沒有隸屬或合作關係,這也不是小紅書自身提供的 API。是否適用於您的用途,依用途與法域由買方法務評估,我們可提供來源與蒐集方式說明。