For AI

Answers

What is a Xiaohongshu note ID and where do I find it in a link?

Short answer

It is the 24-character hexadecimal string after /explore/ or /discovery/item/ in a note link, before any ?xsec_token. okdata's Xiaohongshu note detail takes that ID, or the whole link, for $0.02 and returns the note with the ID in id; note search returns IDs for about 20 notes per $0.02 call.

Every Xiaohongshu note has an ID of exactly 24 characters, digits and the letters a to f only, such as 66f3c1a8000000002c03e5b7. It is the one piece of a note link that never changes: the xsec_token after the question mark is issued per visit and expires, the share code in an xhslink.com link has to be resolved, but the 24 characters stay the same for as long as the note exists. That makes the ID the right key for a spreadsheet or a database, and the thing to extract when people paste links in every possible format.

Link The note ID is
xiaohongshu.com/explore/66f3c1a8000000002c03e5b7?xsec_token=AB… the segment after /explore/
xiaohongshu.com/discovery/item/66f3c1a8000000002c03e5b7 the segment after /discovery/item/
xiaohongshu.com/user/profile/5f2b7c1e0000000001006a3d/66f3c1a8000000002c03e5b7 the last segment; the one before it is the author's user ID
xhslink.com/a/Hk3pQx2Lm9 not visible; the short link has to redirect first

A regular expression that works for the first three: /(?:explore|discovery/item|user/profile/[0-9a-f]{24})/([0-9a-f]{24}).

What it is easy to confuse with

  • User IDs are also 24 hexadecimal characters. In a /user/profile/ link the first 24-character segment is the account, not a note.
  • Comment IDs have the same shape too. Keep the columns labelled.
  • xsec_token is a long token, not part of the ID; see whether you need an xsec_token.

One property worth knowing: the first 8 characters, read as a hexadecimal number, are a Unix timestamp. In every note we have checked it matches the moment the note was posted (66f3c1a8 is late September 2024). Xiaohongshu does not document this, so use published_at in reports and the ID trick only for a quick sort.

How the API takes it and returns it

Xiaohongshu note detail takes id=66f3c1a8000000002c03e5b7 or url= with an /explore/, /discovery/item/ or xhslink.com link. For a /user/profile/<user>/<note> link, send the last segment as id. No token is needed. You get back id, a canonical url (/explore/<id>), type (image or video), title, text, images, likes, saves, comments, shares and hashtags; with view=full, ext.xsec_token holds the token Xiaohongshu attached, if any. Note search returns the same id for every result.

Task Calls Cost
One ID or link to a full note 1 $0.02
250 IDs from last month's campaign 250 $5.00
One search page of note IDs and counts 1 $0.02

Example

import os, re, requests

links = ["https://www.xiaohongshu.com/discovery/item/66f3c1a8000000002c03e5b7?source=webshare"]
pattern = re.compile(r"/(?:explore|discovery/item|user/profile/[0-9a-f]{24})/([0-9a-f]{24})")
for link in links:
    note_id = pattern.search(link).group(1)
    r = requests.get("https://api.okdata.online/v1/xiaohongshu/notes/get",
                     headers={"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"},
                     params={"id": note_id, "fields": "id,type,title,published_at,metrics.likes"},
                     timeout=60)
    print(r.json()["data"]["item"])

Limits

  • Deleted or private notes return not_found, which is still charged as one call.
  • metrics.views is null; Xiaohongshu does not publish view counts.
  • One note per call; there is no batch detail call. For share links pasted as whole messages, see Xiaohongshu share link to note data.

Sources

  1. XHS-Downloader README: supported link formats (/explore/, /discovery/item/, /user/profile/…/…, xhslink.com)github.com · read
  2. Knowing the note ID, how to get xsec_token? (XHS-Downloader issue #397)github.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