| name | xhs-cli |
| description | Headless-browser-based CLI skill for Xiaohongshu (小红书, RedNote, XHS) to search notes, read posts, browse profiles, like, favorite, comment, and publish from the terminal |
| author | jackwener |
| version | 1.0.0 |
| tags | ["xhs","xiaohongshu","小红书","rednote","social-media","cli"] |
[!NOTE]
An alternative package xiaohongshu-cli is available, which uses a reverse-engineered API and runs faster.
This package (xhs-cli) uses a headless browser (camoufox) approach — slower but more resilient against risk-control detection.
Choose whichever best fits your needs.
xhs-cli Skill
A CLI tool for interacting with Xiaohongshu (小红书). Use it to search notes, read details, browse user profiles, and perform interactions like liking, favoriting, and commenting.
Prerequisites
uv tool install xhs-cli
Authentication
All commands require valid cookies to function.
xhs status
xhs login
xhs login --cookie "a1=..."
Authentication first uses saved local cookies. If unavailable, it auto-detects local Chrome cookies via browser-cookie3. If extraction fails, QR code login is available.
Command Reference
Search
xhs search "咖啡"
xhs search "咖啡" --json
Read Note
xhs read <note_id>
xhs read <note_id> --comments
xhs read <note_id> --xsec-token <token>
xhs read <note_id> --json
User
xhs user <user_id>
xhs user <user_id> --json
xhs user-posts <user_id>
xhs user-posts <user_id> --json
xhs followers <user_id>
xhs following <user_id>
Discovery
xhs feed
xhs feed --json
xhs topics "旅行"
xhs topics "旅行" --json
Interactions (require login)
xhs like <note_id>
xhs like <note_id> --undo
xhs favorite <note_id>
xhs favorite <note_id> --undo
xhs comment <note_id> "好棒!"
xhs delete <note_id>
Favorites
xhs favorites
xhs favorites --max 10
xhs favorites --json
Post
xhs post "标题" --image photo1.jpg --image photo2.jpg --content "正文"
xhs post "标题" --image photo1.jpg --content "正文" --json
Account
xhs status
xhs whoami
xhs whoami --json
xhs login
xhs logout
JSON Output
Major query commands support --json for machine-readable output:
xhs search "咖啡" --json | jq '.[0].id'
xhs whoami --json | jq '.userInfo.userId'
xhs favorites --json | jq '.[0].displayTitle'
Common Patterns for AI Agents
xhs whoami --json | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('userInfo',{}).get('userId',''))"
xhs search "topic" --json | python3 -c "import sys,json; [print(n['id']) for n in json.load(sys.stdin)[:3]]"
xhs status && xhs like <note_id>
xhs read <note_id> --comments --json
Error Handling
- Commands exit with code 0 on success, non-zero on failure
- Error messages are prefixed with ❌
- Login-required commands show clear instruction to run
xhs login
xsec_token is auto-resolved from cache; manual --xsec-token available as fallback
Safety Notes
- Do not ask users to share raw cookie values in chat logs.
- Prefer auto-extraction via
xhs login over manual cookie input.
- If auth fails, ask the user to re-login via
xhs login.