SuperAPI AI Directory

xiaohongshu-comment

General & other

View repository

Updated 10-16 08:41

About this skill

Xiaohongshu Comment Analysis (Dubaoya)

Quack! Bring back a Xiaohongshu note's comment section for you to see. Give this duck a note link or noteId, and this duck will fish out the note's top-level comments, lay them out in a "comment/likes" table, and then help you review the comment section's sentiment, needs, and competitor voices. If there are many comments, just flip through them page by page with the cursor.

Data goes through doubaoya.com one line, authentication uses your own token (environment variable DOUBAOYA_API_KEY, in the form dyh_…)。


Applicable scenarios

Scenario How to use What you get
View comment section feedback Paste the note link and pull out the comment section to view page by page What real users are saying
Sentiment/word-of-mouth review Pull the comments and do four-dimensional sentiment analysis Positive/negative/needs/competitors clear at a glance
Dig out user needs Find demands like "link please" "tutorial please" in the comments Find direction for the next topic/product
Competitor voice monitoring See whether competitors are named in the comments Understand where competitors stand in users' minds
Break down viral comments Pull comments for viral notes and see why highly liked comments are popular Learn interaction phrasing and copy golden lines

Workflow (4 steps)

1. Extract noteId

Get it from what the user provided noteId:

  • User gives a link (e.g. https://www.xiaohongshu.com/explore/6a2ac3020000000035022d8e) → extract the noteId from the last segment of the link.
  • User directly gives a noteId (e.g. 6a2ac3020000000035022d8e) → use it directly.
  • Not provided → proactively ask "Please send this duck the Xiaohongshu note link"; you may also first use search-type skills (such as xiaohongshu-hot-notes / xiaohongshu-crawler) to find the target note and get the real noteId from the results.
  • If a note was already queried in the previous round and this round only says things like "next page" or "flip again" → continue using the previous round's noteId.

Iron rule of authenticity: the noteId must come from a link provided by the user or a real result returned by some search skill,never fabricate an id out of thin air. If you cannot get a real noteId, stop and ask; do not use a fake id to call the API.

2. Call the script to fetch data

First page (do not pass --cursor, leave the first-page cursor empty):

python3 "$SKILL_PATH/scripts/fetch_xhs_comments.py" "<noteId>"

Pagination (take the previous page's data from nextCursor and pass it in as-is):

python3 "$SKILL_PATH/scripts/fetch_xhs_comments.py" "<noteId>" --cursor "<上一页nextCursor>"

The script prints the data from the success envelope to stdout as JSON.Run the script only once per page pull, do not loop multiple calls in the same round to scrape the entire comment section all at once—just read the current page's stdout.

Cursor pagination mindset: the first page is achieved by "not passing --cursor" (the server treats an empty cursor as the first page); after that, each page takes from the previous page's data.nextCursor Take the next page cursor and pass it through as-is to --cursor,Do not rewrite or concatenate the cursor。nextCursor Empty / missing = already at the end, no next page.

3. Render the comments table

From data.items(the comments array), take the fields and lay them out into a Markdown table in the format below. Read the fields defensively—content(comment content),likeCount(likes) may be missing; if missing, leave blank or write "—", and don't let one bad data item crash the whole table. If the comment content is too long (over 40 characters), it can be truncated with …appended. If the like count is ≥ 10000, use the x.xw format.

# Comment Likes
1 This method really works, saved 1.2w
2 Please make a detailed tutorial, blogger 860

4. Comment review + page-turning prompt

After the table, do a section in this duck's tone:four-dimensional sentiment review(based on the current page's comments, understanding Xiaohongshu community expressions: recommending/avoiding, "absolutely awesome" "yyds" "saved", etc.):

  • ✅ Positive: what users are praising (cite representative comment keywords).
  • ⚠️ Negative: where complaints/doubts are concentrated.
  • 💡 Demand: what users are asking for (asking for links/tutorials/dupes)—this is a goldmine for topic ideas.
  • 🔍 Competitors: whether other brands are named in the comments; if not, write "No competitors mentioned."

After the review, give a one-line page-turning prompt:

  • nextCursor is non-empty → "This page is done; reply 'next page' and this duck will keep flipping."
  • nextCursor is empty → "You've reached the end of the comments."

The review is presentation-layer processing and does not affect API calls; don't ask the user "what is your real purpose", and don't make up comments.


Get the key (passcode)

  1. Open doubaoya.com
  2. Log in
  3. and go to Passcode Center
  4. Generate passcode(in the form dyh_…)

Configure it as an environment variable (the script only recognizes this):

export DOUBAOYA_API_KEY="dyh_你的口令"

Iron rule: never print the passcode, never write it to a file, never echo it back to the user. The script itself also never outputs the passcode. All requests are sent only to doubaoya.com, and the passcode must not be taken to any other domain.


API and envelope

  • POST https://doubaoya.com/api/apis/xiaohongshu/comments/call
  • Auth header:Authorization: Bearer $DOUBAOYA_API_KEY
  • Request body:
    { "noteId": "6a2ac3020000000035022d8e" }
    
    • noteId: string, required
    • cursor: string, optional—only carried when paging(not passed on the first page; "empty cursor" is achieved by omitting it); when paging, pass the previous page's nextCursor
    • sort: string, optional—comment sorting; if not needed, don't pass it
  • Return envelope:
    {
      "success": true,
      "requestId": "...",
      "data": {
        "items": [ { "content": "…", "likeCount": 1234 } ],
        "nextCursor": "…"
      },
      "error": null
    }
    
    • data.items: this page's comment list (each item contains content comment content,likeCount likes)
    • data.nextCursor: next page cursor; empty / missing means the end
  • First check success: if it is true , then read data; otherwise read error.code / error.message。

Error handling

When the script fails, print to stderr [error] CODE: message and exit with code 1. Common cases:

HTTP code Meaning Handling
401 MISSING_API_KEY / UNAUTHORIZED No passcode provided or the passcode is invalid Check DOUBAOYA_API_KEY, and go to Passcode Center to regenerate it.Do not echo the token
400 VALIDATION_ERROR Invalid parameters (e.g., noteId is empty / invalid link) Check the note link and extract the noteId again
402 INSUFFICIENT_CREDITS Insufficient quota Go to doubaoya.com to top up/renew your quota
404 ENDPOINT_NOT_FOUND Incorrect API path Usually this means the script has been modified; restore the default endpoint path
502 PROVIDER_FAILED Temporary upstream failure (refunded automatically) Safe to retry
— NETWORK_ERROR Cannot connect to doubaoya.com Check your network and retry

502 PROVIDER_FAILED will be refunded automatically; retrying is safe and you will not be charged twice. When 0 comments are retrieved, it will show "This note has no comments yet" and suggest checking whether the note exists or has been deleted.


Directory structure

xiaohongshu-comment/
├── SKILL.md                   # 本文件
└── scripts/
    └── fetch_xhs_comments.py  # 零依赖评论拉取脚本(urllib),调用 doubaoya.com