| name | xiaohongshu-cli |
| description | Xiaohongshu / RED / 小红书 operations — search notes, read content, post images, browse trending, manage comments, follow users, view notifications. TRIGGER when user mentions 小红书/XHS/RED, wants to search/read/post on Xiaohongshu, browse trending content, or manage their XHS account. DO NOT TRIGGER for general social media questions — answer those directly. |
xiaohongshu-cli
CLI for Xiaohongshu (小红书/RED) via reverse-engineered API. Search, read, post, interact, and manage account.
Tool
export PATH="$HOME/.local/bin:$PATH"
xhs <command> [args]
All commands support --json and --yaml output flags. Use --json for structured parsing.
Commands
Search & Discovery
xhs search "咖啡推荐" --sort general --type all --page 1
xhs search-user "设计师"
xhs topics "露营"
xhs feed
xhs hot --category food
Read & Interact
xhs read <id_or_url>
xhs read <id_or_url> --xsec-token <token>
xhs comments <id_or_url>
xhs comments <id_or_url> --all
xhs sub-comments <note_id> <comment_id>
xhs like <id_or_url>
xhs like <id_or_url> --undo
xhs favorite <id_or_url>
xhs unfavorite <id_or_url>
xhs comment <id_or_url> -c "好棒!"
xhs reply <id_or_url> --comment-id <cid> -c "谢谢!"
xhs delete-comment <note_id> <comment_id> -y
Publish & Manage
xhs post --title "标题" --body "正文内容" --images /path/to/img1.jpg --images /path/to/img2.jpg
xhs post --title "标题" --body "内容" --images img.jpg --topic "咖啡" --private
xhs my-notes --page 0
xhs delete <id_or_url> -y
User & Social
xhs user <user_id>
xhs user-posts <user_id> --cursor <cursor>
xhs favorites
xhs favorites <user_id>
xhs follow <user_id>
xhs unfollow <user_id>
Account & Notifications
xhs status
xhs whoami
xhs notifications --type mentions
xhs notifications --type likes
xhs notifications --type connections
xhs unread
Auth
Authentication uses browser cookies, stored locally after first login.
xhs login
xhs login --cookie-source chrome
xhs login --qrcode
xhs logout
Global option --cookie-source TEXT can override browser selection per-command.
Check status: xhs status to verify login before operations.
Output
- Default: human-readable formatted text
--json: structured JSON (use for parsing)
--yaml: YAML format
- Search results return short indices that can be passed to
xhs read
- Paginated commands use
--cursor or --page for navigation
Behavior Notes
PATH must include $HOME/.local/bin — always export before calling
xhs post requires at least one --images flag; video posting is not supported
xhs delete is experimental — the public web endpoint is unstable
--xsec-token for read is a security token; the CLI caches tokens from search results automatically
- Destructive actions (
delete, delete-comment) require -y to skip confirmation
- Rate limits are enforced server-side; no built-in retry — handle failures at caller level