Skip to content

Interactions ​

Tools for interacting with notes on Xiaohongshu.

xhs_like_feed ​

Like or unlike a note.

Parameters ​

ParameterTypeRequiredDescription
noteIdstringYesNote ID
xsecTokenstringYesSecurity token from search
unlikebooleanNoIf true, unlike the note (default: false)
accountstringNoSingle account to use
accountsstring[] | "all"NoMultiple accounts

Example ​

Like a note:

json
{
  "noteId": "abc123",
  "xsecToken": "token-from-search"
}

Unlike a note:

json
{
  "noteId": "abc123",
  "xsecToken": "token-from-search",
  "unlike": true
}

Response ​

json
{
  "success": true,
  "action": "like",
  "noteId": "abc123"
}

xhs_favorite_feed ​

Favorite (collect) or unfavorite a note.

Parameters ​

ParameterTypeRequiredDescription
noteIdstringYesNote ID
xsecTokenstringYesSecurity token from search
unfavoritebooleanNoIf true, unfavorite (default: false)
accountstringNoSingle account to use
accountsstring[] | "all"NoMultiple accounts

Example ​

json
{
  "noteId": "abc123",
  "xsecToken": "token-from-search"
}

Response ​

json
{
  "success": true,
  "action": "favorite",
  "noteId": "abc123"
}

xhs_post_comment ​

Post a comment on a note.

Parameters ​

ParameterTypeRequiredDescription
noteIdstringYesNote ID
xsecTokenstringYesSecurity token from search
contentstringYesComment content
accountstringNoSingle account to use
accountsstring[] | "all"NoMultiple accounts

Example ​

json
{
  "noteId": "abc123",
  "xsecToken": "token-from-search",
  "content": "Great post! 👍"
}

Response ​

json
{
  "success": true,
  "commentId": "comment-id-123"
}

xhs_reply_comment ​

Reply to an existing comment.

Parameters ​

ParameterTypeRequiredDescription
noteIdstringYesNote ID
xsecTokenstringYesSecurity token from search
commentIdstringYesComment ID to reply to
contentstringYesReply content
accountstringNoAccount to use

Example ​

json
{
  "noteId": "abc123",
  "xsecToken": "token-from-search",
  "commentId": "comment-456",
  "content": "Thanks for your feedback!"
}

Response ​

json
{
  "success": true,
  "commentId": "reply-id-789"
}

xhs_delete_cookies ​

Delete saved session cookies for an account.

Parameters ​

ParameterTypeRequiredDescription
accountstringNoAccount name or ID

Response ​

json
{
  "success": true
}

Multi-Account Interactions ​

All interaction tools support the accounts parameter for batch operations:

json
{
  "noteId": "abc123",
  "xsecToken": "token",
  "accounts": ["account1", "account2", "account3"]
}

Or use all active accounts:

json
{
  "noteId": "abc123",
  "xsecToken": "token",
  "accounts": "all"
}

Multi-Account Response ​

json
[
  {
    "account": "account1",
    "success": true,
    "result": { "success": true, "action": "like", "noteId": "abc123" },
    "durationMs": 2500
  },
  {
    "account": "account2",
    "success": true,
    "result": { "success": true, "action": "like", "noteId": "abc123" },
    "durationMs": 2300
  },
  {
    "account": "account3",
    "success": false,
    "error": "Rate limited",
    "durationMs": 1500
  }
]

Error Handling ​

Common errors:

ErrorCauseSolution
Not logged inSession expiredRe-login with xhs_add_account
Rate limitedToo many requestsWait before retrying
Note not foundInvalid noteId or tokenGet fresh token from search
Already likedNote was already likedCheck interactInfo in note details

Released under the MIT License.