Skip to content
OpenSmartRoute
Skillv1.0.0

xhs-cli

Headless-browser-based CLI skill for Xiaohongshu (小红书, RedNote, XHS) to search notes, read posts, browse profiles, like, favorite, comment, and publish from the terminal

by jackwener(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from jackwener/xhs-cli (SKILL.md). Install upstream with npx skills add jackwener/xhs-cli. Copyright stays with the author.

[!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

# Install (requires Python 3.8+)
uv tool install xhs-cli
# Or: pipx install xhs-cli

Authentication

All commands require valid cookies to function.

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

xhs search "咖啡"              # Search notes (rich table output)
xhs search "咖啡" --json       # Raw JSON output

Read Note

# 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

# 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

xhs feed                       # Explore page recommended feed
xhs feed --json
xhs topics "旅行"              # Search topics/hashtags
xhs topics "旅行" --json

Interactions (require login)

# 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

xhs favorites                  # List your favorites
xhs favorites --max 10         # Limit count
xhs favorites --json

Post

xhs post "标题" --image photo1.jpg --image photo2.jpg --content "正文"
xhs post "标题" --image photo1.jpg --content "正文" --json

Account

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:

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

# 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.

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/jackwener-xhs-cli-xhs-cli/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

jackwener-xhs-cli-xhs-cli.ocm.jsonjson
{
  "ocm": "1",
  "id": "jackwener-xhs-cli-xhs-cli",
  "kind": "skill",
  "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",
  "publisher": "jackwener",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general"
    ],
    "tags": [
      "skill-md",
      "xhs",
      "xiaohongshu",
      "rednote",
      "social-media",
      "cli",
      "github"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Headless-browser-based CLI skill for Xiaohongshu (小红书, RedNote, XHS) to search notes, read posts, browse profiles, like, favorite, comment, and publish from the terminal"
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "github",
      "repository": "https://github.com/jackwener/xhs-cli",
      "path": "SKILL.md",
      "ref": "3ce71415dc0816ebb4c3f547baf6c08fb3d5cb5a",
      "url": "https://github.com/jackwener/xhs-cli/blob/3ce71415dc0816ebb4c3f547baf6c08fb3d5cb5a/SKILL.md",
      "key": "jackwener/xhs-cli/SKILL.md"
    }
  },
  "instructions": "> [!NOTE]\n> An alternative package [xiaohongshu-cli](https://github.com/jackwener/xiaohongshu-cli) is available, which uses a reverse-engineered API and runs faster.\n> This package (`xhs-cli`) uses a headless browser (camoufox) approach — slower but more resilient against risk-control detection.\n> Choose whichever best fits your needs.\n\n# xhs-cli Skill\n\nA CLI tool for interacting with Xiaohongshu (小红书). Use it to search notes, read details, browse user profiles, and perform interactions like liking, favoriting, and commenting.\n\n## Prerequisites\n\n```bash\n# Install (requires Python 3.8+)\nuv tool",
  "cost": {
    "context_tokens": 1028
  }
}

Fetch it by URL: GET /api/v1/registry/jackwener-xhs-cli-xhs-cli/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.