@northmoon-labs/social-cli
v0.1.0
Published
Agent-ready CLI for Northmoon Social account authorization, publishing, comments, analytics, webhooks, and auto replies.
Maintainers
Readme
Northmoon Social CLI
nmsocial 是给 Agent 使用的 Northmoon Social 命令行工具,让 Agent 可以通过稳定的命令完成社媒账号授权、素材管理、内容发布、评论处理、数据统计和自动回复配置。
你可以使用 nmsocial 完成:
- 获取社媒账号授权链接
- 查询已授权账号
- 上传视频和图片素材
- 创建视频 / 图文发布任务
- 查询发布任务和发布记录
- 查询评论并回复评论
- 配置 webhook 转发地址
- 查询账号、作品、平台统计数据
- 管理自动回复策略
安装
npm install -g @northmoon-labs/social-cli检查是否安装成功:
nmsocial --help也可以直接用 npx 运行:
npx @northmoon-labs/social-cli --help登录
推荐使用 --api-key-stdin 登录,避免 API Key 出现在 shell history 中:
nmsocial login --api-key-stdin如果是 Agent 或自动化客户端调用,也可以直接传入 API Key:
nmsocial login --api-key YOUR_KEY使用 --api-key 更方便自动化,但要注意不要把包含 API Key 的命令输出到公开日志中。
查看当前登录状态:
nmsocial status退出登录:
nmsocial logout更新 CLI
检查是否有新版本:
nmsocial update check更新到 npm 上的最新版本:
nmsocial update只查看将要执行的安装命令,不实际更新:
nmsocial update --dry-run默认会根据当前运行环境选择包管理器,无法判断时使用 npm。你也可以手动指定:
nmsocial update --manager npm
nmsocial update --manager pnpm
nmsocial update --manager bun给 Agent 使用
npm 包内包含一份给 Agent 阅读的 CLI 使用说明:
skills/nmsocial-cli/SKILL.md如果你的 Agent 支持读取 skill、工具说明或外部上下文,可以把这个文件提供给它。该文件只说明如何调用 nmsocial,不包含内部开发文档。
全局参数
| 参数 | 说明 |
| --- | --- |
| --json | 输出稳定 JSON,适合脚本解析 |
| --timeout MS | 设置请求超时时间,单位毫秒 |
| --dry-run | 只预览请求内容,不发送请求 |
| --help | 查看帮助 |
| --version | 查看版本 |
输出格式
默认输出为简洁文本或表格,适合在终端里快速查看,也能减少 Agent 阅读结果时的无关内容。
如果要让脚本或 Agent 稳定解析返回结果,请加上 --json:
nmsocial accounts list --platform tiktok --json平台参数
涉及平台的命令支持平台名称或平台数字:
| 平台名称 | 平台数字 |
| --- | --- |
| tiktok | 1 |
| youtube | 2 |
| instagram | 3 |
| facebook | 4 |
示例:
nmsocial auth-url --platform tiktok
nmsocial auth-url --platform 1账号授权
获取授权链接:
nmsocial auth-url --platform tiktok查询已授权账号:
nmsocial accounts list --platform tiktok --status 1 --page 1 --page-size 20按条件筛选账号:
nmsocial accounts list \
--platform youtube \
--username demo \
--is-verified 1 \
--page-size 50YouTube 剧集
查询剧集列表:
nmsocial youtube series list --open-id CHANNEL_ID创建剧集:
nmsocial youtube series create \
--open-id CHANNEL_ID \
--title "Demo Series" \
--description "Demo description"创建前预览请求内容:
nmsocial youtube series create \
--open-id CHANNEL_ID \
--title "Demo Series" \
--dry-run \
--json素材
查询素材列表:
nmsocial materials list --type 1 --title demo --page 1 --page-size 20上传素材:
nmsocial materials upload ./demo.mp4支持的文件类型:
- 视频:
mp4、mov、avi、mkv、webm、flv、wmv、m4v、3gp - 图片:
jpg、jpeg、png、gif、bmp、webp、heic、heif、tif、tiff
上传后的素材默认保留七天。
发布任务
创建视频发布任务:
nmsocial publish video \
--account OPEN_ID_1 \
--account OPEN_ID_2 \
--content https://example.com/video1.mp4 \
--caption "hello"创建图文发布任务:
nmsocial publish image \
--account OPEN_ID \
--content https://example.com/image1.png \
--content https://example.com/image2.png \
--title "title" \
--caption "caption"定时发布:
nmsocial publish video \
--account OPEN_ID \
--content https://example.com/video.mp4 \
--at 2026-07-18T10:00:00+08:00创建前预览请求内容:
nmsocial publish video \
--account OPEN_ID \
--content https://example.com/video.mp4 \
--video-assign-type 1 \
--privacy public \
--dry-run \
--json--account、--content、--playlist-id 等参数可以重复传入。
任务查询
查询发布任务:
nmsocial tasks list --platform tiktok --page 1 --page-size 20按发布方式或时间筛选:
nmsocial tasks list \
--platform tiktok \
--video-assign-type 1 \
--create-time-begin 1783990000000 \
--create-time-end 1784000000000发布记录
查询发布记录:
nmsocial posts list --platform tiktok --open-id OPEN_ID查询已发布作品统计:
nmsocial posts stats --platform tiktok --main-task-id TASK_ID评论
查询评论:
nmsocial comments list --platform tiktok --open-id OPEN_ID回复评论:
nmsocial comments reply \
--platform tiktok \
--open-id OPEN_ID \
--video-id VIDEO_ID \
--comment-id COMMENT_ID \
--text "Thanks"回复前预览请求内容:
nmsocial comments reply \
--platform tiktok \
--open-id OPEN_ID \
--video-id VIDEO_ID \
--comment-id COMMENT_ID \
--text "Thanks" \
--dry-run \
--jsonWebhook
设置 webhook 转发地址:
nmsocial webhook set --url https://partner.example.com/spost/webhook关闭 webhook 转发:
nmsocial webhook disable数据统计
查询统计概览:
nmsocial stats overview --platform tiktok --start-date 2026-07-11 --end-date 2026-07-17查询账号趋势:
nmsocial stats account trend --platform tiktok --metric followers查询账号排行:
nmsocial stats account rank --metric followerIncrease --order desc --page 1 --page-size 20查询作品趋势:
nmsocial stats post trend --platform tiktok --metric viewCount查询作品排行:
nmsocial stats post rank --metric viewIncrease --order desc --page 1 --page-size 20查询单个作品趋势:
nmsocial stats post detail-trend \
--post-id POST_ID \
--metric viewCount \
--metric likeCount \
--metric commentCount查询平台汇总:
nmsocial stats platform summary --start-date 2026-07-11 --end-date 2026-07-17日期参数格式为 yyyy-MM-dd。
自动回复
查询自动回复策略:
nmsocial auto-replies list --platform tiktok --page 1 --page-size 20查看策略详情:
nmsocial auto-replies detail --id STRATEGY_ID创建策略:
nmsocial auto-replies create \
--name "Demo auto reply" \
--platform tiktok \
--account-id ACCOUNT_RECORD_ID \
--trigger-rule keyword \
--keyword price \
--keyword coupon \
--send-rule sequence \
--content "Thanks for your comment" \
--content-delay 0 \
--once-per-user false \
--repeat-interval-hours 24 \
--stop-on-user-reply true \
--enabled true通过 JSON 文件创建:
nmsocial auto-replies create --from-file ./auto-reply.json --dry-run --json通过 JSON 文件更新:
nmsocial auto-replies update --id STRATEGY_ID --from-file ./auto-reply.json启用、停用或删除策略:
nmsocial auto-replies enable --id STRATEGY_ID
nmsocial auto-replies disable --id STRATEGY_ID
nmsocial auto-replies delete --id STRATEGY_IDJSON 输出
需要在脚本中解析输出时,建议使用 --json。
成功响应:
{
"ok": true,
"data": {},
"error": null,
"meta": {
"providerCode": 200,
"providerMessage": "ok",
"providerTimestamp": "2026-07-14T15:34:08.576+08:00",
"requestId": "11"
}
}错误响应:
{
"ok": false,
"data": null,
"error": {
"code": "SOCIAL_API_ERROR",
"message": "invalid api key",
"status": 403,
"payload": {}
},
"meta": null
}使用建议
- 创建或更新发布任务、评论回复、webhook、自动回复策略前,可以先使用
--dry-run --json预览请求内容。 nmsocial status会隐藏完整 API Key。- 不要把 API Key 直接写在 shell 命令中。
