跳到内容
Twexapi
简体中文
Esc
导航打开⌘J预览
本页内容

CLI

使用 TwexAPI CLI 进行推文搜索、粉丝导出、私信、X Articles 与终端 X API 自动化。

当你需要确定性的终端命令、JSON 输出、dry-run 预览与已保存的凭证 profile,且无需编写应用代码即可完成 TwexAPI REST 工作流时,请使用 CLI。

CLI 任务 命令 保存
搜索推文 x-api-scraper search tweets cursor
读取资料 x-api-scraper about screen_name
列出粉丝 x-api-scraper followers cursor

安装

npm install -g @twexapi-dev/x-api-scraper-cli
x-api-scraper --help

需要 Node.js 18 或更高版本。

源码:twexapi-dev/x-api-scraper-cli

认证

TwexAPI dashboard 获取 API 密钥。

export X_API_SCRAPER_KEY="YOUR_API_KEY"

x-api-scraper auth apps add --name prod --api-key "YOUR_API_KEY"
x-api-scraper auth apps use prod
x-api-scraper --app prod about elonmusk

基础示例

# Lookup users
x-api-scraper --app prod users elonmusk sama

# Search tweets
x-api-scraper --app prod search tweets "founder" "ai" --sort Latest

# List followers (v3)
x-api-scraper --app prod followers elonmusk

# Global trending tweets
x-api-scraper --app prod trending tweets --country "United States" --topic "Sports" --count 50

原始 API 请求

直接调用任意 TwexAPI 路径:

x-api-scraper --app prod /twitter/elonmusk/about
x-api-scraper --app prod -X POST -d '["elonmusk","sama"]' /twitter/users

作为 Skill 使用

从 GitHub skill 安装器安装:

npx skills add twexapi-dev/x-api-scraper-cli

或从 ClawHub 安装:

npx clawhub@latest install x-api-scraper-cli

安全说明

  • CLI 从环境变量读取 X_API_SCRAPER_KEYX_API_SCRAPER_BASE_URLX_API_SCRAPER_CONFIG_DIR
  • 默认情况下,已保存的 app 配置与 profile 以纯 JSON 存储在 ~/.x-api-scraper/config.json
  • 在 Agent 工作流中,任何写操作前请先使用 --dry-run

参考

这个页面有帮助吗?