npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

xhs-cli

v1.3.3

Published

小红书创作者 CLI:多账号会话、发帖与数据抓取(人机确认发布)

Readme

xhs-cli

在终端里使用的小红书工具:登录创作者指标创作者后台已发笔记recent)、单篇笔记详情detail)、本地发帖归档posted),以及用标题 + 正文 + 本地图片路径在创作后台填表发帖(post,需本机 Chrome/Chromium)。

支持多账号隔离(每账号独立浏览器会话目录),适合与 Agent 或自动化流程编排配合;发帖仍以本地人机确认为前提。

依赖

  • Node.js 20 及以上
  • Chrome 或 Chromium(本机已安装;CLI 通过 Puppeteer 连接,不随包下载浏览器)

安装

npm install -g xhs-cli

安装后使用命令 xhs。完整子命令列表:xhs help

快速开始

1. 添加账号并登录

账号名仅允许 [a-zA-Z0-9._-]+

xhs account add my-account
xhs account use my-account
xhs login

login 成功后会自动把该账号记为当前账号。会话保存在 ~/.xhs-cli/.cache/accounts/<name>/browser-data

2. 发帖(填表)

xhs post \
  --title "标题" \
  --content "正文至少十个字,须满足小红书长度校验" \
  --image ./cover.png
  • --image 可重复,至少 1 张、最多 18 张;也可用 --content-file <路径> 代替 --content
  • 默认只填表,不会自动点击发布;加 --publish 会在填表后尝试点击页面「发布」按钮。
  • 临时操作其他账号:--account other

3. 查看数据

xhs metrics
xhs recent --limit 20
xhs detail <noteId>
xhs posted

当前账号

| 命令 | 说明 | |------|------| | xhs account use <name> | 设置当前账号(写入 registry.json) | | xhs account current | 打印当前账号 slug | | xhs account list | 列表中带 * 的为当前账号 |

业务命令默认使用当前账号,无需每次写账号参数。临时切换仅支持 --account <slug>

未设置当前账号时,命令会提示先执行 xhs account use <name>

命令一览

| 命令 | 说明 | |------|------| | xhs help | 打印帮助 | | xhs account list | 列出已配置账号 | | xhs account add <name> | 新建账号(首个账号会自动设为当前) | | xhs account show <name> | 查看单账号配置 | | xhs account use <name> | 设置当前账号 | | xhs account current | 显示当前账号 | | xhs login [--account <name>] | 登录创作者中心 | | xhs metrics [--account <name>] | 运营数据摘要 | | xhs recent [--limit N] [--account <name>] | 创作者后台已发笔记 | | xhs detail <noteId> [--account <name>] | 笔记详情 | | xhs posted [--account <name>] | 本地 published/ 归档列表 | | xhs post --title … (--content … \| --content-file …) --image … [--account <name>] | 创作页填表发帖 |

数据目录

默认路径:~/.xhs-cli/.cache/

| 路径 | 说明 | |------|------| | accounts/registry.json | 账号注册表(含 currentAccount) | | accounts/<name>/browser-data/ | 该账号 Chrome 会话(Cookie 等) | | published/ | 本地发帖归档 JSON(xhs posted) |

发帖说明

  • 本工具不会在未经你确认的情况下向小红书发稿。
  • xhs post 未加 --publish 时:填入标题、正文、图片后保持浏览器窗口,由你在页面中确认并发布。
  • --publish 会尝试自动点击「发布」,是否成功以页面实际状态为准。

许可证

GNU General Public License v3.0(GPL-3.0)

链接