Weibo API in Python: search posts and get comments (2026)

Weibo Open Platform's read endpoints centre on the authorising user, its comment endpoint returns that user's comments only, and an unreviewed app can authorise 15 test accounts; to search public posts and read comments from a program, use a third-party data API. Below it is done with DataXAPI's Python SDK; the free trial covers up to 333 calls. 2 endpoints do it: Weibo realtime search → Weibo post comments. The worked example below is 12 calls and costs $0.0240 in all; a failed call is not charged.

Updated 2026-11-06Open in ChatGPTOpen in Claude

Search two pages of Weibo posts on a keyword, take the comments under the 10 with the most comments, into one CSV: post text, reposts and comments, comment text, comment likes.

Step 1: Weibo realtime search

A page of posts for the search terms, newest first; metrics.comments is the comment count and id the post ID. Long posts are cut short here.

curl -G "https://api.dataxapi.com/v1/weibo/posts/search" \
  --data-urlencode "query=新能源汽车" \
  -H "Authorization: Bearer $DATAXAPI_API_KEY"
# pip install dataxapi
from dataxapi import DataXAPI

dx = DataXAPI()  # reads DATAXAPI_API_KEY
result = dx.weibo.posts.search(query="新能源汽车")
print(result["data"]["items"])
// npm i @dataxapi/sdk
import { DataXAPI } from "@dataxapi/sdk";

const dx = new DataXAPI(); // reads DATAXAPI_API_KEY
const result = await dx.weibo.posts.search({ query: "新能源汽车" });
console.log(result.data.items);
dataxapi call weibo.posts.search 'query=新能源汽车'
Recorded response
{
  "code": "ok",
  "request_id": "814a139c-cdb8-4a40-ac78-d5eea33f4a49",
  "data": {
    "items": [
      {
        "id": "5236052452850013",
        "url": "https://weibo.com/6203910512/imMkNQ4Yv",
        "type": "image",
        "text": "周末的新能源汽车日常,随手记录一下",
        "published_at": "2026-10-12T18:01:10.000Z",
        "author": {
          "id": "6779824410",
          "name": "山野咖啡馆",
          "avatar_url": "https://tvax1.sinaimg.cn/crop.0.0.512.512.180/E3e34Zyl6RyCChKcvEs7K6EZ.jpg",
          "verified": false,
          "followers": 2568
        },
        "metrics": { "likes": 0, "comments": 3, "reposts": 0 },
        "images": [
          "https://tvax1.sinaimg.cn/large/zhuR7jHU35sRnwVn0Z3jHZz1.jpg",
          "https://tvax1.sinaimg.cn/large/OovUGuApFODFZj7FAMuTAB4S.jpg",
          // … 2 more
        ],
        "hashtags": null
      },
      // … 8 more
    ]
  },
  "page": {
    "next_cursor": "c1.Zaf7tnLyz10UhVmeSCiY-wqUpL2K-Pv9eZq__BRv",
    "cursor_expires_at": "2026-10-12T20:03:07.000Z",
    "has_more": true,
    "returned": 9
  },
  "warnings": [],
  "meta": {
    "capability": "weibo.posts.search",
    "result_status": "complete",
    "fetched_at": "2026-10-12T19:03:07.000Z",
    "cached": false,
    "replayed": false,
    "unavailable": {
      "title": "platform",
      "lang": "capability",
      "author.username": "platform",
      "metrics.shares": "platform",
      "metrics.favorites": "capability",
      "metrics.views": "capability",
      "mentions": "capability",
      "is_pinned": "capability",
      "post_id": "platform",
      "parent_id": "platform",
      "root_id": "platform"
    },
    "billing": {
      "amount": "0.002",
      "currency": "USD",
      "balance_after": "9.998"
    }
  }
}

From a response recorded 2026-10-12 19:03 UTC. Names, text and IDs are examples, and so are the links: none is the recorded one (the page shows no one's personal data); the figures are as recorded. Long lists are cut. The request ID, cursor and balance are made up.

Weibo realtime search · $0.0020 / a call · Parameters, fields and errors on the endpoint's page →

Step 2: Weibo post comments

Put the post ID into id for a page of about 20 comments with IP location; the next page comes from page.next_cursor.

curl -G "https://api.dataxapi.com/v1/weibo/posts/comments/list" \
  --data-urlencode "id=5352434046339577" \
  -H "Authorization: Bearer $DATAXAPI_API_KEY"
# pip install dataxapi
from dataxapi import DataXAPI

dx = DataXAPI()  # reads DATAXAPI_API_KEY
result = dx.weibo.posts.comments.list(id="5352434046339577")
print(result["data"]["items"])
// npm i @dataxapi/sdk
import { DataXAPI } from "@dataxapi/sdk";

const dx = new DataXAPI(); // reads DATAXAPI_API_KEY
const result = await dx.weibo.posts.comments.list({ id: "5352434046339577" });
console.log(result.data.items);
dataxapi call weibo.posts.comments.list id=5352434046339577
Recorded response
{
  "code": "ok",
  "request_id": "fa38736b-0eeb-43ec-af8d-6dfed79989b4",
  "data": {
    "items": [
      {
        "id": "5253368837152553",
        "text": "收藏了,周末就去试试",
        "published_at": "2026-09-23T14:03:52.000Z",
        "author": {
          "id": "6802897337",
          "name": "阿杰爱折腾",
          "avatar_url": "https://tvax1.sinaimg.cn/crop.0.0.512.512.180/hFDQqZ0eykmuSoczNDhhphXJ.jpg"
        },
        "metrics": { "likes": 20, "comments": 11 },
        "post_id": "5267001718823362",
        "parent_id": null,
        "root_id": null
      },
      // … 19 more
    ]
  },
  "page": {
    "next_cursor": "c1.LRIoesC7sc0iuzzCBkU3T8z207doNiGKjj2FzQDa",
    "cursor_expires_at": "2026-10-12T20:01:34.000Z",
    "has_more": true,
    "returned": 20
  },
  "warnings": [],
  "meta": {
    "capability": "weibo.posts.comments.list",
    "result_status": "complete",
    "fetched_at": "2026-10-12T19:01:34.000Z",
    "cached": false,
    "replayed": false,
    "unavailable": { "url": "platform", "author.username": "platform" },
    "billing": {
      "amount": "0.002",
      "currency": "USD",
      "balance_after": "9.998"
    }
  }
}

From a response recorded 2026-10-12 19:01 UTC. Names, text and IDs are examples, and so are the links: none is the recorded one (the page shows no one's personal data); the figures are as recorded. Long lists are cut. The request ID, cursor and balance are made up.

Weibo post comments · $0.0020 / a call · Parameters, fields and errors on the endpoint's page →

What the example costs

Two pages of search results, then a page of comments under 10 posts

EndpointCallsPriceSubtotal
Weibo realtime search2$0.0020$0.0040
Weibo post comments10$0.0020$0.0200
Total12$0.0240

Prices are the prices in force when this page was built. A failed call costs nothing.

In your AI (MCP)

Connect DataXAPI to your AI client once. Then say what you want; the agent finds these endpoints, checks the price and calls them on your balance.

Say: Search Weibo for 新能源汽车 (new-energy cars), get the comments under the 10 posts with the most comments as one table, and sum up what people argue about.
What the agent sends to the call tool
{
  "capability": "weibo.posts.search",
  "query": "新能源汽车",
  "idempotency_key": "<a new UUID>"
}

Sign in to copy the setup prompt with your keyAbout the MCP server →

With a Skill

Why DataXAPI

  • Steady: endpoints were available 99.9% of the last 30 days, on a public status page you can check.
  • Fast: a paid call took 1.6 seconds at the median over the last 7 days (counted 2026-11-06).
  • Fewer tokens: across 11 endpoints on Weibo, one recorded real response each, the platform's own JSON comes to 551k tokens and what an AI reads through DataXAPI's MCP server to 17k, 97% fewer; the JSON of a direct API call is 94% fewer too (counted 2026-11-06). Every platform answers in one shape: the author in author, counts in metrics, the next page in page.next_cursor, so another platform needs no new parser.
  • See before you pay: every endpoint's page shows a recorded real response, field by field.
  • Spending you control: a failed call is not charged; each key can have a limit, X-Max-Price caps one call, and the same Idempotency-Key within 24 hours is never charged twice.
  • Ready for AI: a remote MCP server listed in the official MCP registry as com.dataxapi/mcp, usable from Claude, Cursor and ChatGPT.
  • Free trial of up to 333 calls, no card.

Good to know

  • For a long post in full, use weibo.posts.get. No Weibo account or cookie.
  • The hot search list is weibo.trends.list, 50 terms.
  • Without code: connect DataXAPI to Claude or ChatGPT and say the sentence under “In your AI”.

The whole script

The task above as one script that runs as it is: Python, the SDK, your key from DATAXAPI_API_KEY. It writes a CSV file and ends by printing what it called, fetched and was charged.

Python
# pip install dataxapi
# export DATAXAPI_API_KEY=dx_...   (your key)
import csv
from decimal import Decimal
from dataxapi import DataXAPI

dx = DataXAPI()
calls, fetched, charged = 0, 0, Decimal("0")

def run(capability, params):
    """One call; counts it and what it was charged."""
    global calls, charged
    result = dx.call(capability, params)
    calls += 1
    charged += Decimal(str(result["meta"]["billing"]["amount"]))
    return result

QUERY = "新能源汽车"
PAGES, POSTS = 2, 10

# 1. Two pages of posts for the search terms, newest first.
posts, cursor = [], None
for _ in range(PAGES):
    page = run("weibo.posts.search", {"query": QUERY, **({"cursor": cursor} if cursor else {})})
    posts += page["data"]["items"]
    cursor = page["page"]["next_cursor"]
    if not page["page"]["has_more"]:
        break

# 2. A page of comments under the posts with the most comments.
rows = []
for post in sorted(posts, key=lambda each: -(each["metrics"].get("comments") or 0))[:POSTS]:
    for comment in run("weibo.posts.comments.list", {"id": post["id"]})["data"]["items"]:
        rows.append([post.get("text"), post["metrics"].get("reposts"), post["metrics"].get("comments"), comment.get("text"), comment["metrics"].get("likes")])

fetched = len(rows)
with open("weibo-comments.csv", "w", newline="", encoding="utf-8") as file:
    csv.writer(file).writerows([["post", "reposts", "comments", "comment", "comment_likes"], *rows])

print(f"calls: {calls}, items: {fetched}, charged: ${charged}")