Answers

How do I turn a Xiaohongshu share link (xhslink.com) into note data?

Short answer

Pass the link as url to the okdata Xiaohongshu note detail endpoint; short xhslink.com links are resolved for you and you get the note ID, title, full text, images, likes, saves and comment count back for $0.02. Pull the link out of the share text first, because the endpoint takes a link, not the whole message.

Creators send you their campaign notes as share links from the app: a block of text with a title, an emoji and an http://xhslink.com/... link somewhere inside. You want each one as a row with the note ID and today's numbers. Short links redirect through Xiaohongshu, and downloaders often fail on them, especially the newer xhslink.com/o/... mobile links or when cookies are not passed along on the redirect. Note detail accepts the short link and returns the note ID along with its numbers.

Xiaohongshu note detail accepts url, which can be:

  • an xhslink.com short link, any path;
  • a xiaohongshu.com/explore/<id> or /discovery/item/<id> page link, with or without its query string.

The short link is resolved on our side. The response has the note id (keep it; later calls can use it directly), title, full text, image URLs, publish time, likes, saves, comments and shares, hashtags and the author.

Cost

Links Calls Cost
1 1 $0.02
40 campaign notes 40 $0.80
40 notes, checked weekly for 8 weeks 320 $6.40

From share text to data

import os, re, requests

share = "【某品牌新品】超好用! http://xhslink.com/a/AbCdEf 复制本条信息,打开小红书App查看"
link = re.search(r"https?://[^\s,,]+", share).group(0)

r = requests.get(
    "https://api.okdata.online/v1/xiaohongshu/notes/get",
    headers={"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"},
    params={"url": link, "fields": "id,title,published_at,metrics"},
    timeout=60,
)
print(r.json()["data"]["item"])

A xiaohongshu.com link that is not a note page comes back as invalid_params with a sentence saying why, and is not charged.

Pitfalls

  • Send id or url, not both.
  • A share link to a creator's profile is not a note. Send profile links to account profile instead, which also accepts xhslink.com links.
  • Notes that were deleted or made private return not_found, free of charge. That is often the first sign a creator pulled a sponsored post.
  • View counts are not public on Xiaohongshu; metrics.views is null.

Alternatives

If you need the files (images or video) on your disk, XHS-Downloader and similar tools do that well with your own browser session. If you only have a handful of links, opening them in the app and noting the counts is fine. For tracking many campaign notes over weeks, see competitor monitoring, which uses the same call on a schedule.

Updated