微博轉發 API 與轉發鏈回溯

依 2026-10-25 規格快照

快速解答

兩種任務可以呈現一則微博貼文的擴散情形。POST /weibo/reposts/task 蒐集單則貼文的轉發;每筆轉發紀錄有 parent_id 指回被轉發的貼文,另有作者、內文、時間、互動數與情感標籤,每頁最多 100 筆。POST /weibo/repost/parent/task 方向相反:從一則轉發沿著上層連結往原文方向回溯(depth 預設 3、最多 10),尚未儲存的上層貼文會一併抓取;DONE 或 PARTIAL 時回傳目前已取得的轉發鏈,由起點貼文往原文方向排列。資料以網路爬蟲蒐集微博公開發布的內容。

常見用途

  • 找出誰在什麼時間轉發了貼文,以及哪些轉發本身也獲得互動。
  • 引用一則廣為流傳的轉發之前,先往原文方向回溯。
  • 為傳播或研究工作,整理一則訊息在帳號之間的流動情形。

端點一覽

Base URL 為 https://api.infominer.io/api/v2,每個請求以 auth-header 標頭帶 API 金鑰。

方法路徑說明
POST /weibo/reposts/task 以貼文網址建立轉發蒐集任務。
GET /weibo/reposts/task/{task_id} 輪詢轉發任務;DONE 時回傳轉發紀錄,每筆帶 parent_id。
POST /weibo/repost/parent/task 由一則轉發往上回溯轉發鏈,上層貼文不在資料庫時自動補抓。
GET /weibo/repost/parent/task/{task_id} 輪詢轉發鏈任務;DONE 或 PARTIAL 時回傳目前已取得的轉發鏈與貼文數。

請求參數

POST /weibo/reposts/task

參數位置型別必填預設值/可用值說明
post_url body string 是 要蒐集轉發的微博貼文網址。

GET /weibo/reposts/task/{task_id}

參數位置型別必填預設值/可用值說明
task_id path string 是 建立任務時回傳的任務 ID。
page query integer 否 1 頁碼,從 1 開始。
pageSize query integer 否 100 每頁轉發數,最多 100。

POST /weibo/repost/parent/task

參數位置型別必填預設值/可用值說明
post_url body string 是 作為回溯起點的轉發網址。
depth body integer 否 3(最多 10) 沿轉發鏈往上回溯的層數。

GET /weibo/repost/parent/task/{task_id}

參數位置型別必填預設值/可用值說明
task_id path string 是 建立任務時回傳的任務 ID。

回應欄位

資料欄位端點
轉發 id, parent_id, url, author, author_id, content, datetime, tm, like_count, comment_count, share_count, sentiment, region GET /weibo/reposts/task/{task_id}
轉發鏈(由起點貼文往原文方向) status, depth, post_url, task, data GET /weibo/repost/parent/task/{task_id}

程式碼範例

curl:建立任務

curl -X POST https://api.infominer.io/api/v2/weibo/reposts/task \
  -H "auth-header: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"post_url": "https://m.weibo.cn/detail/0000000000000001"}'

curl:以任務 ID 輪詢

curl "https://api.infominer.io/api/v2/weibo/reposts/task/$TASK_ID?page=1&pageSize=100" \
  -H "auth-header: YOUR_API_KEY"

curl:由一則轉發往上回溯轉發鏈

curl -X POST https://api.infominer.io/api/v2/weibo/repost/parent/task \
  -H "auth-header: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"post_url": "https://m.weibo.cn/detail/0000000000000201", "depth": 5}'

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}/weibo/reposts/task",
    headers=HEADERS,
    json={
        "post_url": "https://m.weibo.cn/detail/0000000000000001",
    },
    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}/weibo/reposts/task/{task['id']}",
        headers=HEADERS,
        params={
            "page": 1,
            "pageSize": 100,
        },
        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["parent_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": 1,
  "data": [
    {
      "id": "0000000000000201",
      "parent_id": "0000000000000001",
      "url": "https://m.weibo.cn/detail/0000000000000201",
      "author": "sample_user_3",
      "author_id": "0000000000000003",
      "content": "收藏了,下次去的时候试试 //@sample_user_1: 周末在巷子里的咖啡店试了新豆子",
      "datetime": "2026-06-10 14:00:00",
      "tm": 1781071200,
      "like_count": 2,
      "comment_count": 0,
      "share_count": 0,
      "sentiment": "Positive"
    }
  ]
}

限制與注意事項

  • 轉發每頁最多讀取 100 筆。
  • 轉發鏈的 depth 預設 3、最多 10。沒有上層連結或達到 depth 上限時停止,因此不保證回溯到原文。
  • 轉發鏈任務可能以 PARTIAL 結束;此時回傳目前已取得的貼文,depth 為其數量。
  • 轉發鏈任務的輪詢不帶分頁參數。
蒐集方式:以網路爬蟲蒐集各平台公開發布的內容。是否適用於您的用途,依用途與法域由買方法務評估,我們可提供來源與蒐集方式說明。

更多 微博 API 頁面

申請試用

填寫下方申請表單時,請註明微博,並說明要追的關鍵字(中文或英文訂閱)、是否需要留言、轉發與轉發鏈,以及預估資料量。我們會確認範圍,並回覆試用與 API 金鑰的安排。

填寫表單申請試用,專人確認範圍後回覆試用與介接安排。

填寫申請表單

常見問題

轉發任務和轉發鏈任務有什麼不同?
轉發任務往下:從一則貼文蒐集該貼文的轉發。轉發鏈任務往上:從一則轉發沿著上層連結往原文方向回溯。
轉發鏈一定會回溯到原文嗎?
不一定。沒有上層連結或達到 depth 上限(預設 3、最多 10)時就會停止,PARTIAL 的任務只回傳目前已取得的貼文。
可以取得英文的轉發嗎?
對於英譯訂閱涵蓋的關鍵字,POST /weibo/translate/reposts 可依 post_id 回傳一則主貼文的英譯轉發。
資料是怎麼蒐集的?這是微博官方的 API 嗎?
資料以網路爬蟲蒐集微博公開發布的內容。LargitData 與微博沒有隸屬或合作關係,這也不是微博自身提供的 API。是否適用於您的用途,依用途與法域由買方法務評估,我們可提供來源與蒐集方式說明。