For AI

Answers

What are uid, mid and bid on Weibo?

Short answer

uid is the numeric account ID, mid is the numeric post ID (16 digits today), and bid is the same mid written in base62, the 9-character code in links like weibo.com/<uid>/<bid>. okdata Weibo post search returns the mid as id and the bid inside url for $0.002 a page, and Weibo account profile takes the numeric uid for $0.002.

Weibo uses three identifiers, and two of them are the same number in different clothes. The uid names an account. The mid names a post. The bid is that post's mid encoded in base62, and it is what you see in a post's address: in weibo.com/6082913457/Qkz3PvVLT, the first part is the author's uid and the second the bid.

The three side by side

uid mid bid
Names An account A post A post
Shape Digits, usually 10 Digits, 16 for current posts 9 characters from 0-9, a-z, A-Z
Example 6082913457 5249013377610245 Qkz3PvVLT
Seen in weibo.com/u/<uid>, every author object Web and app JSON (mid, idstr) Post URLs (mblogid in web JSON)

The names are not used consistently. In Weibo's web and app JSON, mid is the numeric string and the short code is mblogid. In the documentation of the official API, id is the number and "mid" is the base62 form: statuses/querymid turns a numeric id into a code such as 8Ras3qlz, and statuses/queryid goes back. When a tool asks for a "mid", check whether it wants digits or letters.

Converting mid to bid

Split the numeric mid into groups of 7 digits from the right. Write each group in base62 with the alphabet 0-9a-zA-Z and pad it to 4 characters, except the leftmost group. Join the pieces.

Worked example for 5249013377610245: the groups are 52, 4901337 and 7610245; in base62 they are Q, kz3P and vVLT; joined, Qkz3PvVLT. Going back, split the bid into 4-character groups from the right, decode each and pad to 7 digits. We checked the method against six real posts whose numeric mid and link code we had from the same response; all six matched.

What okdata takes and returns

Endpoint Takes Returns Cost
Weibo post search query id = mid, url = weibo.com/uid/bid, author.id = uid $0.002 a page
Weibo account profile id = numeric uid the account, with id = uid $0.002

author.username holds the account's custom address (个性域名) when it has one, the part after weibo.com/ in a link like weibo.com/somebrand. The profile endpoint does not accept it; use the numeric author.id.

Example

import os, requests

ALPHA = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

def mid_to_bid(mid: str) -> str:
    parts, end = [], len(mid)
    while end > 0:
        start = max(0, end - 7)
        n, code = int(mid[start:end]), ""
        while n:
            n, r = divmod(n, 62)
            code = ALPHA[r] + code
        parts.insert(0, code.rjust(4, "0") if start else code or "0")
        end = start
    return "".join(parts)

assert mid_to_bid("5249013377610245") == "Qkz3PvVLT"

body = requests.get("https://api.okdata.online/v1/weibo/posts/search", timeout=60,
    headers={"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"},
    params={"query": "新品发布", "fields": "id,url,author.id,author.username"}).json()
for p in body["data"]["items"]:
    print(p["author"]["id"], p["id"], mid_to_bid(p["id"]), p["url"])

Limits

  • Keep mids and uids as strings. A 16-digit mid is beyond the 15 digits Excel keeps, and JavaScript code should not do arithmetic on it.
  • There is no Weibo post-by-ID endpoint in the catalog. A mid or bid tells you which post it is, but you reach posts here through search.
  • The uid stays the same when the nickname changes, so key accounts on the uid rather than on a name or a custom address.

For profile numbers from a uid, see getting a Weibo user's followers from their UID.

Sources

  1. Weibo Open Platform: statuses/querymid (numeric id to base62 mid)open.weibo.com · read
  2. Weibo Open Platform: statuses/queryid (base62 mid to numeric id)open.weibo.com · read
  3. Weibo Open Platform: users/showopen.weibo.com · read

Where people asked this (read 2026-11-12)

Updated

Connect once, then just ask.

Every new key comes with $0.10 to try it. One sentence connects your agent.

Start free
Connect your AI

Paste this into your agent

Read https://okdata.online/agents.md and set up okdata for me; my key is in the OKDATA_API_KEY environment variable.

Claude Code, Cursor, Codex and other agents that can open a link set themselves up from it.

MCP serverhttps://api.okdata.online/mcp