xhs-cliSAFE
小红书命令行工具 — 搜索、阅读、点赞、收藏、评论,全在终端完成 | Xiaohongshu CLI
Overview
From the repository's own README, as read at the audited commit. Badges and raw HTML are left out.
xiaohongshu-cli 这是逆向 API 出来的版本。 速度更加快更加稳定。但是风控上应该不如当前这个直接用浏览器操作真实。
中文 | English
[](https://pypi.org/project/xhs-cli/) [](LICENSE)
小红书命令行工具 — 在终端中搜索笔记、查看主页、点赞、收藏、评论。
推荐项目
- twitter-cli - 在终端中操作 X/Twitter 的 CLI 工具
- bilibili-cli - 哔哩哔哩 CLI 工具
功能
- 搜索 — 按关键词搜索笔记,Rich 表格展示
- 阅读 — 查看笔记内容、数据、评论
- 用户资料 — 查看用户信息、笔记、粉丝、关注
- 推荐 Feed — 获取探索页推荐内容
- 话题 — 搜索话题标签
- 互动 — 点赞/取消、收藏/取消、评论、删除笔记
- 发布 — 发布图文笔记
- 认证 — 自动提取 Chrome cookie,或 browser-assisted 扫码登录(终端二维码渲染)
- JSON 输出 — 所有数据命令支持
--json - Token 自动缓存 —
xsec_token搜索后自动缓存,后续命令免手动传
命令一览
所有数据命令支持--json输出。xsec_token自动缓存,无需手动传递。
特别鸣谢
IPWO住宅代理覆盖 195+ 个国家和地区,提供动态住宅代理、静态住宅代理及不限量住宅代理。 适用于开发 CLI 工具、集成 MCP 服务,构建 AI Agent 与自动化工作流,为多地区网络访问和数据采集任务提供灵活的住宅代理选择。 支持免费测试,9 折折扣码:0203
安装
需要 Python 3.8+。
# 推荐:使用 uv uv tool install xhs-cli # 或使用 pipx pipx install xhs-cli
从源码安装(开发用)
git clone [email protected]:jackwener/xhs-cli.git cd xhs-cli uv sync
本地一键冒烟测试
在本地已登录(有 ~/.xhs-cli/cookies.json)的情况下,直接运行:
./scripts/smo
fb3081a8406bOBSERVED · 2026-10-14Install
Commands as the repository documents them. They are shown, not run.
uv tool install xhs-cli
git clone [email protected]:jackwener/xhs-cli.git
uv sync
npx skills add jackwener/xhs-cli
git clone [email protected]:jackwener/xhs-cli.git .agents/skills/xhs-cli
uv tool install xhs-cli
Host compatibility
What the documentation claims. We have not run a compatibility test.
| Host | Status | Notes |
|---|---|---|
| claude-code | mentioned | |
| openclaw | mentioned |
What it tells the agent
The instruction file, verbatim from the audited commit — this is the text the model reads, and the surface the audit's instruction layer examines. Quoted here so you can judge it without cloning anything.
---
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](https://github.com/jackwener/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
```bash
# Install (requires Python 3.8+)
uv tool install xhs-cli
# Or: pipx install xhs-cli
```
## Authentication
All commands require valid cookies to function.
```bash
xhs status # Check saved login session (no browser extraction)
xhs login # Auto-extract Chrome cookies
xhs login --cookie "a1=..." # Or provide cookies manually
```
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
```bash
xhs search "咖啡" # Search notes (rich table output)
xhs search "咖啡" --json # Raw JSON output
```
### Read Note
```bash
# View note (xsec_token auto-resolved from search cache)
xhs read <note_id>
xhs read <note_id> --comments # Include comments
xhs read <note_id> --xsec-token <token> # Manual token
xhs read <note_id> --json
```
### User
```bash
# Look up user profile (by internal user_id, hex format)
xhs user <user_id>
xhs user <user_id> --json
# List user's published notes
xhs user-posts <user_id>
xhs user-posts <user_id> --json
# Followers / Following
xhs followers <user_id>
xhs following <user_id>
```
### Discovery
```bash
xhs feed # Explore page recommended feed
xhs feed --json
xhs topics "旅行" # Search topics/hashtags
xhs topics "旅行" --json
```
### Interactions (require login)
```bash
# Like / Unlike (xsec_token auto-resolved)
xhs like <note_id>
xhs like <note_id> --undo
# Favorite / Unfavorite
xhs favorite <note_id>
xhs favorite <note_id> --undo
# Comment
xhs comment <note_id> "好棒!"
# Delete your own note
xhs delete <note_id>
```
### Favorites
```bash
xhs favorites # List your favorites
xhs favorites --max 10 # Limit count
xhs favorites --json
```
### Post
```bash
xhs post "标题" --image photo1.jpg --image photo2.jpg --content "正文"
xhs post "标题" --image photo1.jpg --content "正文" --json
```
### Account
```bash
xhs status # Quick saved-session check
xhs whoami # Full profile info
xhs whoami --json
xhs login # Login
xhs logout # Clear cookies
```
## JSON Output
Major query commands support `--json` for machine-readable output:
```bash
xhs search "咖啡" --json | jq '.[0].id' # First note ID
xhs whoami --json | jq '.userInfo.userId' # Your user ID
xhs favorites --json | jq '.[0].displayTitle' # First favorite title
```
## Common Patterns for AI Agents
```bash
# Get your user ID for further queries
xhs whoami --json | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('userInfo',{}).get('userId',''))"
# Search and get note IDs (xsec_token auto-cached for later use)
xhs search "topic" --json | python3 -c "import sys,json; [print(n['id']) for n in json.load(sys.stdin)[:3]]"
# Check login before performing actions
xhs status && xhs like <note_id>
# Read a note with comments for summarization
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`.Trust audit
SAFEgrade B · trust 89/100 Nothing in the source contradicts what it says it does. Grade A is reserved for packages that have also passed the behavioural sandbox.
| Layer | What it checks | Result |
|---|---|---|
| L0 | Provenance & inventory | PASS |
| L1 | Static analysis of the code | PASS |
| L2 | Instruction surface (what it tells the agent) | PASS |
| L3 | Class-specific surface | PASS |
| L4 | Behavioural (sandbox) | SKIPPED |
What the source does
- Filesystem
- none-observed
- Network
- none-observed
- Shell
- none-observed
- Dependencies
- pinned
- Secrets in source
- none-found
Findings (0)
No findings outside the package's declared scope.
Gates applied: no_behavioural_pass.
fb3081a8406bfull audit observations/trust-audit/skill/jackwener__xhs-cli.json · Report an issue / request a re-scanAudit history
Every audit this skill has had.
| Date | Source | Verdict | Grade | Score | Change |
|---|---|---|---|---|---|
| 2026-10-14 | fb3081a8406b | SAFE | B | 89 | first audit |
Questions
What does the xhs-cli skill do?
小红书命令行工具 — 搜索、阅读、点赞、收藏、评论,全在终端完成 | Xiaohongshu CLI
Is xhs-cli safe to install?
The audit found nothing in the source that contradicts what it says it does, and graded it B (89/100). Grade A is held back for packages that have also passed a sandboxed behavioural run, which is why a clean skill reads B.
What can xhs-cli access on my machine?
The audit observed no filesystem, network or shell use at all in its source.
Which assistants does xhs-cli work with?
Its documentation mentions claude-code and openclaw. That is what the text claims, not a compatibility test we ran.
How current is this page?
The grade is for one exact copy of the source (fb3081a8406b), read on 2026-10-14. The repository is watched, and a new audit runs when it changes — this is the first audit.