用途:gram 是使用 REST/GraphQL API 与 cookie 认证的 Instagram 命令行工具,可在终端读取信息流、帖子、用户资料并执行互动操作。
主要能力:账号与认证方面提供 whoami(显示登录账号)、check(显示凭证来源)、query-ids --refresh(刷新 GraphQL 查询 ID 缓存)。阅读帖子支持 post <shortcode-or-url> 或直接传短码/链接、comments <shortcode> -n 20 查看评论、likers <shortcode> 查看点赞用户。信息流支持 feed -n 20(主页)与 explore -n 20(探索)。用户资料支持 user <username>、posts <username> -n 20、following [username]、followers [username]。搜索支持 search "query" 及 --type users/places/hashtags。互动操作支持 like、unlike、save、unsave、comment、follow、unfollow。
使用方式:安装可运行 npm install -g @cyberdrk/gram,或用 bunx @cyberdrk/gram whoami 一次性执行。认证使用 Instagram 网页会话的 cookie,可通过 --session-id、--csrf-token、--ds-user-id 直接传入,或用 --cookie-source 读取浏览器 cookie;Arc/Brave 需用 --chrome-profile-dir <path>。输出选项含 --json、--json-full、--plain、--no-emoji、--no-color。全局选项含 --timeout、--cookie-timeout 及各类 profile 参数。配置可写在 ~/.config/gram/config.json5 或 ./.gramrc.json5,也可用环境变量 GRAM_TIMEOUT_MS、GRAM_COOKIE_TIMEOUT_MS。
适用场景:需要在终端批量查看 Instagram 内容、导出 JSON 数据或执行简单互动操作的用户。
限制:必须持有有效的 Instagram 网页会话 cookie;遇到 404 可执行 gram query-ids --refresh;cookie 提取失败需确认浏览器已登录并尝试不同 --cookie-source;移动端创建的会话可能因 user-agent 不匹配而失败,需改用桌面浏览器登录;资料未提供收费、价格与平台支持等信息。