bird 是一个快速访问 X/Twitter 的命令行工具,使用 GraphQL 和 cookie 认证。
安装方式提供多种选择:可通过 npm、pnpm 或 bun 全局安装 @steipete/bird;在 macOS 上可用 Homebrew 安装预编译二进制(brew install steipete/tap/bird);也可用 bunx @steipete/bird 直接一次性运行而无需安装。
认证采用基于 cookie 的方式。可以直接用 --auth-token / --ct0 传入 cookie,也可以用 --cookie-source 从浏览器读取 cookie。运行 bird check 可以查看当前生效的凭证来源;对于 Arc/Brave 浏览器,需要用 --chrome-profile-dir <path> 指定路径。
主要能力覆盖账户与认证、读取推文、时间线、搜索、新闻与趋势、列表、书签与点赞、社交图谱、互动操作、发帖、媒体上传、分页和输出选项。账户相关命令包括 bird whoami(显示已登录账户)、bird check(显示凭证来源)、bird query-ids --fresh(刷新 GraphQL 查询 ID 缓存)。读取推文可用 bird read <url-or-id> 或简写 bird <url-or-id>,此外 bird thread 查看完整对话线程,bird replies 列出回复。时间线支持 bird home(首页 For You)、bird home --following(关注时间线)、bird user-tweets @handle -n 20(用户主页时间线)、bird mentions(提及你的推文)以及 bird mentions --user @handle(他人被提及的推文)。搜索可用 bird search "query" -n 10、bird search "from:steipete" --all --max-pages 3。新闻与趋势部分提供 bird news -n 10,可加 --ai-only 过滤 AI 精选、--sports 查看体育标签、--with-tweets 包含相关推文,bird trending 是其别名。列表支持 bird lists、bird lists --member-of、bird list-timeline <id> -n 20。书签与点赞包括 bird bookmarks -n 10,并可指定 --folder-id、--include-parent、--author-chain、--full-chain-only 等,另有 bird unbookmark 和 bird likes。社交图谱可查看 bird following、bird followers、bird about @handle。互动操作支持 bird follow @handle 与 bird unfollow @handle。
发帖方面,bird tweet "hello world"、bird reply <url-or-id> "nice thread!",并可通过 --media 和 --alt 附加媒体与替代文本。官方提示发帖操作更可能触发速率限制,如被阻止建议改用浏览器工具。媒体上传支持最多 4 张图片或 1 个视频,例如 bird tweet "pics" --media a.jpg --media b.jpg。
支持分页的命令包括 replies、thread、search、bookmarks、likes、list-timeline、following、followers、user-tweets,可用 --all 获取所有页、--max-pages 限制页数、--cursor 从游标恢复、--delay 设置翻页间隔(毫秒)。
输出选项包括 --json(JSON 输出)、--json-full(含原始 API 响应的 JSON)、--plain(无 emoji 无颜色,便于脚本处理)、--no-emoji、--no-color(或设 NO_COLOR=1)、--quote-depth n(JSON 中引用推文的最大深度,默认 1)。全局选项包括 --auth-token、--ct0、--cookie-source(可重复)、--chrome-profile、--chrome-profile-dir、--firefox-profile、--timeout、--cookie-timeout。
配置文件位于 ~/.config/bird/config.json5(全局)或 ./.birdrc.json5(项目),可设置 cookieSource、chromeProfileDir、timeoutMs、quoteDepth;环境变量有 BIRD_TIMEOUT_MS、BIRD_COOKIE_TIMEOUT_MS、BIRD_QUOTE_DEPTH。
常见问题排查:若出现查询 ID 过期(404 错误),运行 bird query-ids --fresh;若 cookie 提取失败,检查浏览器是否已登录 X,尝试不同的 --cookie-source,对于 Arc/Brave 使用 --chrome-profile-dir。