Latest commit

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

bird 🐦 — fast X CLI for tweeting, replying, and reading

bird is a fast X CLI for tweeting, replying, and reading via X/Twitter GraphQL (cookie auth).

Disclaimer

This project uses X/Twitter’s undocumented web GraphQL API (and cookie auth). X can change endpoints, query IDs, and anti-bot behavior at any time — expect this to break without notice.

Install

npm install -g @steipete/bird
# or
pnpm add -g @steipete/bird
# or
bun add -g @steipete/bird
# one-shot (no install)
bunx @steipete/bird whoami

Homebrew (macOS, prebuilt Bun binary):

brew install steipete/tap/bird

Quickstart

# Show the logged-in account
bird whoami
# Discover command help
bird help whoami
# Read a tweet (URL or ID)
bird read https://x.com/user/status/1234567890123456789
bird 1234567890123456789 --json
# Thread + replies
bird thread https://x.com/user/status/1234567890123456789
bird replies 1234567890123456789
bird replies 1234567890123456789 --max-pages 3 --json
bird thread 1234567890123456789 --max-pages 3 --json
# Search + mentions
bird search "from:steipete" -n 5
bird mentions -n 5
bird mentions --user @steipete -n 5
# User tweets (profile timeline)
bird user-tweets @steipete -n 20
bird user-tweets @steipete -n 50 --json
# Bookmarks
bird bookmarks -n 5
bird bookmarks --folder-id 123456789123456789 -n 5 # https://x.com/i/bookmarks/<folder-id>
bird bookmarks --all --json
bird bookmarks --all --max-pages 2 --json
bird bookmarks --include-parent --json
bird unbookmark 1234567890123456789
bird unbookmark https://x.com/user/status/1234567890123456789
# Likes
bird likes -n 5
# News and trending topics (AI-curated from Explore tabs)
bird news --ai-only -n 10
bird news --sports -n 5
# Lists
bird list-timeline 1234567890 -n 20
bird list-timeline https://x.com/i/lists/1234567890 --all --json
bird list-timeline 1234567890 --max-pages 3 --json
# Following (who you follow)
bird following -n 20
bird following --user 12345678 -n 10 # by user ID# Followers (who follows you)
bird followers -n 20
bird followers --user 12345678 -n 10 # by user ID# Refresh GraphQL query IDs cache (no rebuild)
bird query-ids --fresh

News & Trending

Fetch AI-curated news and trending topics from X's Explore page tabs:

# Fetch 10 news items from all tabs (default: For You, News, Sports, Entertainment)
bird news -n 10
# Fetch only AI-curated news (filters out regular trends)
bird news --ai-only -n 20
# Fetch from specific tabs
bird news --news-only --ai-only -n 10
bird news --sports -n 15
bird news --entertainment --ai-only -n 5
# Include related tweets for each news item
bird news --with-tweets --tweets-per-item 3 -n 10
# Combine multiple tab filters
bird news --sports --entertainment -n 20
# JSON output
bird news --json -n 5
bird news --json-full --ai-only -n 10 # includes raw API response

Tab options (can be combined):

  • --for-you — Fetch from For You tab only
  • --news-only — Fetch from News tab only
  • --sports — Fetch from Sports tab only
  • --entertainment — Fetch from Entertainment tab only
  • --trending-only — Fetch from Trending tab only

By default, the command fetches from For You, News, Sports, and Entertainment tabs (Trending excluded to reduce noise). Headlines are automatically deduplicated across tabs.

Library

bird can be used as a library (same GraphQL client as the CLI):

import{TwitterClient,resolveCredentials}from'@steipete/bird';const{ cookies }=awaitresolveCredentials({cookieSource: 'safari'});constclient=newTwitterClient({ cookies });// Search for tweetsconstsearchResult=awaitclient.search('from:steipete',50);// Fetch news and trending topics from all tabs (default: For You, News, Sports, Entertainment)constnewsResult=awaitclient.getNews(10,{aiOnly: true});// Fetch from specific tabs with related tweetsconstsportsNews=awaitclient.getNews(10,{aiOnly: true,withTweets: true,tabs: ['sports','entertainment']});

Account details (About profile):

constaboutResult=awaitclient.getUserAboutAccount('steipete');if(aboutResult.success&&aboutResult.aboutProfile){console.log(aboutResult.aboutProfile.accountBasedIn);}

Fields:

  • accountBasedIn
  • source
  • createdCountryAccurate
  • locationAccurate
  • learnMoreUrl

Commands

  • bird tweet "<text>" — post a new tweet.
  • bird reply <tweet-id-or-url> "<text>" — reply to a tweet using its ID or URL.
  • bird help [command] — show help (or help for a subcommand).
  • bird query-ids [--fresh] [--json] — inspect or refresh cached GraphQL query IDs.
  • bird home [-n count] [--following] [--json] [--json-full] — fetch your home timeline (For You) or Following feed.
  • bird read <tweet-id-or-url> [--json] — fetch tweet content as text or JSON.
  • bird <tweet-id-or-url> [--json] — shorthand for read when only a URL or ID is provided.
  • bird replies <tweet-id-or-url> [--all] [--max-pages n] [--cursor string] [--delay ms] [--json] — list replies to a tweet.
  • bird thread <tweet-id-or-url> [--all] [--max-pages n] [--cursor string] [--delay ms] [--json] — show the full conversation thread.
  • bird search "<query>" [-n count] [--all] [--max-pages n] [--cursor string] [--json] — search for tweets matching a query; --max-pages requires --all or --cursor.
  • bird mentions [-n count] [--user @handle] [--json] — find tweets mentioning a user (defaults to the authenticated user).
  • bird user-tweets <@handle> [-n count] [--cursor string] [--max-pages n] [--delay ms] [--json] — get tweets from a user's profile timeline.
  • bird bookmarks [-n count] [--folder-id id] [--all] [--max-pages n] [--cursor string] [--expand-root-only] [--author-chain] [--author-only] [--full-chain-only] [--include-ancestor-branches] [--include-parent] [--thread-meta] [--sort-chronological] [--json] — list your bookmarked tweets (or a specific bookmark folder); expansion flags control thread context; --max-pages requires --all or --cursor.
  • bird unbookmark <tweet-id-or-url...> — remove one or more bookmarks by tweet ID or URL.
  • bird likes [-n count] [--all] [--max-pages n] [--cursor string] [--json] [--json-full] — list your liked tweets; --max-pages requires --all or --cursor.
  • bird news [-n count] [--ai-only] [--with-tweets] [--tweets-per-item n] [--for-you] [--news-only] [--sports] [--entertainment] [--trending-only] [--json] — fetch news and trending topics from X's Explore tabs.
  • bird trending — alias for news command.
  • bird lists [--member-of] [-n count] [--json] — list your lists (owned or memberships).
  • bird list-timeline <list-id-or-url> [-n count] [--all] [--max-pages n] [--cursor string] [--json] — get tweets from a list timeline; --max-pages implies --all.
  • bird following [--user <userId>] [-n count] [--cursor string] [--all] [--max-pages n] [--json] — list users that you (or another user) follow; --max-pages requires --all.
  • bird followers [--user <userId>] [-n count] [--cursor string] [--all] [--max-pages n] [--json] — list users that follow you (or another user); --max-pages requires --all.
  • bird about <@handle> [--json] — get account origin and location information for a user.
  • bird whoami — print which Twitter account your cookies belong to.
  • bird check — show which credentials are available and where they were sourced from.

Bookmarks flags:

  • --expand-root-only: expand threads only when the bookmark is a root tweet.
  • --author-chain: keep only the bookmarked author's connected self-reply chain.
  • --author-only: include all tweets from the bookmarked author within the thread.
  • --full-chain-only: keep the entire reply chain connected to the bookmarked tweet (all authors).
  • --include-ancestor-branches: include sibling branches for ancestors when using --full-chain-only.
  • --include-parent: include the direct parent tweet for non-root bookmarks.
  • --thread-meta: add thread metadata fields to each tweet.
  • --sort-chronological: sort output globally oldest to newest (default preserves bookmark order).

Global options:

  • --auth-token <token>: set the auth_token cookie manually.
  • --ct0 <token>: set the ct0 cookie manually.
  • --cookie-source <safari|chrome|firefox>: choose browser cookie source (repeatable; order matters).
  • --chrome-profile <name>: Chrome profile name for cookie extraction (e.g., Default, Profile 2).
  • --chrome-profile-dir <path>: Chrome/Chromium profile directory or cookie DB path for cookie extraction.
  • --firefox-profile <name>: Firefox profile for cookie extraction.
  • --cookie-timeout <ms>: cookie extraction timeout for keychain/OS helpers (milliseconds).
  • --timeout <ms>: abort requests after the given timeout (milliseconds).
  • --quote-depth <n>: max quoted tweet depth in JSON output (default: 1; 0 disables).
  • --plain: stable output (no emoji, no color).
  • --no-emoji: disable emoji output.
  • --no-color: disable ANSI colors (or set NO_COLOR=1).
  • --media <path>: attach media file (repeatable, up to 4 images or 1 video).
  • --alt <text>: alt text for the corresponding --media (repeatable).

Authentication (GraphQL)

GraphQL mode uses your existing X/Twitter web session (no password prompt). It sends requests to internal X endpoints and authenticates via cookies (auth_token, ct0).

Write operations:

  • tweet/reply primarily use GraphQL (CreateTweet).
  • If GraphQL returns error 226 (“automated request”), bird falls back to the legacy statuses/update.json endpoint.

bird resolves credentials in this order:

  1. CLI flags: --auth-token, --ct0
  2. Environment variables: AUTH_TOKEN, CT0 (fallback: TWITTER_AUTH_TOKEN, TWITTER_CT0)
  3. Browser cookies via @steipete/sweet-cookie (override via --cookie-source order)

Browser cookie sources:

  • Safari: ~/Library/Cookies/Cookies.binarycookies (fallback: ~/Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies)
  • Chrome: ~/Library/Application Support/Google/Chrome/<Profile>/Cookies
  • Firefox: ~/Library/Application Support/Firefox/Profiles/<profile>/cookies.sqlite
    • For Chromium variants (Arc/Brave/etc), pass a profile directory or cookie DB via --chrome-profile-dir.

Config (JSON5)

Config precedence: CLI flags > env vars > project config > global config.

  • Global: ~/.config/bird/config.json5
  • Project: ./.birdrc.json5

Example ~/.config/bird/config.json5:

{// Cookie source order for browser extraction (string or array)cookieSource: ["firefox","safari"],chromeProfileDir: "/path/to/Chromium/Profile",firefoxProfile: "default-release",cookieTimeoutMs: 30000,timeoutMs: 20000,quoteDepth: 1}

Environment shortcuts:

  • BIRD_TIMEOUT_MS
  • BIRD_COOKIE_TIMEOUT_MS
  • BIRD_QUOTE_DEPTH

Output

  • --json prints raw tweet objects for read/replies/thread/search/mentions/user-tweets/bookmarks/likes.
  • When using --json with pagination (--all, --cursor, --max-pages, or for user-tweets when -n > 20), output is { tweets, nextCursor }.
  • read returns full text for Notes and Articles when present.
  • Use --plain for stable, script-friendly output (no emoji, no color).

JSON Schema

When using --json, tweet objects include:

FieldTypeDescription
idstringTweet ID
textstringFull tweet text (includes Note/Article content when present)
authorobject{ username, name }
authorIdstring?Author's user ID
createdAtstringTimestamp
replyCountnumberNumber of replies
retweetCountnumberNumber of retweets
likeCountnumberNumber of likes
conversationIdstringThread conversation ID
inReplyToStatusIdstring?Parent tweet ID (present if this is a reply)
quotedTweetobject?Embedded quote tweet (same schema; depth controlled by --quote-depth)

When using --json with following/followers, user objects include:

FieldTypeDescription
idstringUser ID
usernamestringUsername/handle
namestringDisplay name
descriptionstring?User bio
followersCountnumber?Followers count
followingCountnumber?Following count
isBlueVerifiedboolean?Blue verified flag
profileImageUrlstring?Profile image URL
createdAtstring?Account creation timestamp

When using --json with news/trending, news objects include:

FieldTypeDescription
idstringUnique identifier for the news item
headlinestringNews headline or trend title
categorystring?Category (e.g., "AI · Technology", "Trending", "News")
timeAgostring?Relative time (e.g., "2h ago")
postCountnumber?Number of posts
descriptionstring?Item description
urlstring?URL to the trend or news article
tweetsarray?Related tweets (only when --with-tweets is used)
_rawobject?Raw API response (only when --json-full is used)

Query IDs (GraphQL)

X rotates GraphQL “query IDs” frequently. Each GraphQL operation is addressed as:

  • operationName (e.g. TweetDetail, CreateTweet)
  • queryId (rotating ID baked into X’s web client bundles)

bird ships with a baseline mapping in src/lib/query-ids.json (copied into dist/ on build). At runtime, it can refresh that mapping by scraping X’s public web client bundles and caching the result on disk.

Runtime cache:

  • Default path: ~/.config/bird/query-ids-cache.json
  • Override path: BIRD_QUERY_IDS_CACHE=/path/to/file.json
  • TTL: 24h (stale cache is still used, but marked “not fresh”)

Auto-recovery:

  • On GraphQL 404 (query ID invalid), bird forces a refresh once and retries.
  • For TweetDetail/SearchTimeline, bird also rotates through a small set of known fallback IDs to reduce breakage while refreshing.

Refresh on demand:

bird query-ids --fresh

Exit codes:

  • 0: success
  • 1: runtime error (network/auth/etc)
  • 2: invalid usage/validation (e.g. bad --user handle)

Version

bird --version prints package.json version plus current git sha when available, e.g. 0.3.0 (3df7969b).

Media uploads

  • Attach media with --media (repeatable) and optional --alt per item.
  • Up to 4 images/GIFs, or 1 video (no mixing). Supported: jpg, jpeg, png, webp, gif, mp4, mov.
  • Images/GIFs + 1 video supported (uploads via Twitter legacy upload endpoint + cookies; video may take longer to process).

Example:

bird tweet "hi" --media img.png --alt "desc"

Development

cd~/Projects/bird
pnpm install
pnpm run build # dist/ + bun binary
pnpm run build:dist # dist/ only
pnpm run build:binary
pnpm run dev tweet "Test"
pnpm run dev -- --plain check
pnpm test
pnpm run lint

Notes

  • GraphQL uses internal X endpoints and can be rate limited (429).
  • Query IDs rotate; refresh at runtime with bird query-ids --fresh (or update the baked baseline via pnpm run graphql:update).

About

CLI tool for X/Twitter - rescued from @steipete/bird v0.8.0

Resources

Stars

21 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Latest commit

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

bird 🐦 — fast X CLI for tweeting, replying, and reading

bird is a fast X CLI for tweeting, replying, and reading via X/Twitter GraphQL (cookie auth).

Disclaimer

This project uses X/Twitter’s undocumented web GraphQL API (and cookie auth). X can change endpoints, query IDs, and anti-bot behavior at any time — expect this to break without notice.

Install

npm install -g @steipete/bird
# or
pnpm add -g @steipete/bird
# or
bun add -g @steipete/bird
# one-shot (no install)
bunx @steipete/bird whoami

Homebrew (macOS, prebuilt Bun binary):

brew install steipete/tap/bird

Quickstart

# Show the logged-in account
bird whoami
# Discover command help
bird help whoami
# Read a tweet (URL or ID)
bird read https://x.com/user/status/1234567890123456789
bird 1234567890123456789 --json
# Thread + replies
bird thread https://x.com/user/status/1234567890123456789
bird replies 1234567890123456789
bird replies 1234567890123456789 --max-pages 3 --json
bird thread 1234567890123456789 --max-pages 3 --json
# Search + mentions
bird search "from:steipete" -n 5
bird mentions -n 5
bird mentions --user @steipete -n 5
# User tweets (profile timeline)
bird user-tweets @steipete -n 20
bird user-tweets @steipete -n 50 --json
# Bookmarks
bird bookmarks -n 5
bird bookmarks --folder-id 123456789123456789 -n 5 # https://x.com/i/bookmarks/<folder-id>
bird bookmarks --all --json
bird bookmarks --all --max-pages 2 --json
bird bookmarks --include-parent --json
bird unbookmark 1234567890123456789
bird unbookmark https://x.com/user/status/1234567890123456789
# Likes
bird likes -n 5
# News and trending topics (AI-curated from Explore tabs)
bird news --ai-only -n 10
bird news --sports -n 5
# Lists
bird list-timeline 1234567890 -n 20
bird list-timeline https://x.com/i/lists/1234567890 --all --json
bird list-timeline 1234567890 --max-pages 3 --json
# Following (who you follow)
bird following -n 20
bird following --user 12345678 -n 10 # by user ID# Followers (who follows you)
bird followers -n 20
bird followers --user 12345678 -n 10 # by user ID# Refresh GraphQL query IDs cache (no rebuild)
bird query-ids --fresh

News & Trending

Fetch AI-curated news and trending topics from X's Explore page tabs:

# Fetch 10 news items from all tabs (default: For You, News, Sports, Entertainment)
bird news -n 10
# Fetch only AI-curated news (filters out regular trends)
bird news --ai-only -n 20
# Fetch from specific tabs
bird news --news-only --ai-only -n 10
bird news --sports -n 15
bird news --entertainment --ai-only -n 5
# Include related tweets for each news item
bird news --with-tweets --tweets-per-item 3 -n 10
# Combine multiple tab filters
bird news --sports --entertainment -n 20
# JSON output
bird news --json -n 5
bird news --json-full --ai-only -n 10 # includes raw API response

Tab options (can be combined):

  • --for-you — Fetch from For You tab only
  • --news-only — Fetch from News tab only
  • --sports — Fetch from Sports tab only
  • --entertainment — Fetch from Entertainment tab only
  • --trending-only — Fetch from Trending tab only

By default, the command fetches from For You, News, Sports, and Entertainment tabs (Trending excluded to reduce noise). Headlines are automatically deduplicated across tabs.

Library

bird can be used as a library (same GraphQL client as the CLI):

import{TwitterClient,resolveCredentials}from'@steipete/bird';const{ cookies }=awaitresolveCredentials({cookieSource: 'safari'});constclient=newTwitterClient({ cookies });// Search for tweetsconstsearchResult=awaitclient.search('from:steipete',50);// Fetch news and trending topics from all tabs (default: For You, News, Sports, Entertainment)constnewsResult=awaitclient.getNews(10,{aiOnly: true});// Fetch from specific tabs with related tweetsconstsportsNews=awaitclient.getNews(10,{aiOnly: true,withTweets: true,tabs: ['sports','entertainment']});

Account details (About profile):

constaboutResult=awaitclient.getUserAboutAccount('steipete');if(aboutResult.success&&aboutResult.aboutProfile){console.log(aboutResult.aboutProfile.accountBasedIn);}

Fields:

  • accountBasedIn
  • source
  • createdCountryAccurate
  • locationAccurate
  • learnMoreUrl

Commands

  • bird tweet "<text>" — post a new tweet.
  • bird reply <tweet-id-or-url> "<text>" — reply to a tweet using its ID or URL.
  • bird help [command] — show help (or help for a subcommand).
  • bird query-ids [--fresh] [--json] — inspect or refresh cached GraphQL query IDs.
  • bird home [-n count] [--following] [--json] [--json-full] — fetch your home timeline (For You) or Following feed.
  • bird read <tweet-id-or-url> [--json] — fetch tweet content as text or JSON.
  • bird <tweet-id-or-url> [--json] — shorthand for read when only a URL or ID is provided.
  • bird replies <tweet-id-or-url> [--all] [--max-pages n] [--cursor string] [--delay ms] [--json] — list replies to a tweet.
  • bird thread <tweet-id-or-url> [--all] [--max-pages n] [--cursor string] [--delay ms] [--json] — show the full conversation thread.
  • bird search "<query>" [-n count] [--all] [--max-pages n] [--cursor string] [--json] — search for tweets matching a query; --max-pages requires --all or --cursor.
  • bird mentions [-n count] [--user @handle] [--json] — find tweets mentioning a user (defaults to the authenticated user).
  • bird user-tweets <@handle> [-n count] [--cursor string] [--max-pages n] [--delay ms] [--json] — get tweets from a user's profile timeline.
  • bird bookmarks [-n count] [--folder-id id] [--all] [--max-pages n] [--cursor string] [--expand-root-only] [--author-chain] [--author-only] [--full-chain-only] [--include-ancestor-branches] [--include-parent] [--thread-meta] [--sort-chronological] [--json] — list your bookmarked tweets (or a specific bookmark folder); expansion flags control thread context; --max-pages requires --all or --cursor.
  • bird unbookmark <tweet-id-or-url...> — remove one or more bookmarks by tweet ID or URL.
  • bird likes [-n count] [--all] [--max-pages n] [--cursor string] [--json] [--json-full] — list your liked tweets; --max-pages requires --all or --cursor.
  • bird news [-n count] [--ai-only] [--with-tweets] [--tweets-per-item n] [--for-you] [--news-only] [--sports] [--entertainment] [--trending-only] [--json] — fetch news and trending topics from X's Explore tabs.
  • bird trending — alias for news command.
  • bird lists [--member-of] [-n count] [--json] — list your lists (owned or memberships).
  • bird list-timeline <list-id-or-url> [-n count] [--all] [--max-pages n] [--cursor string] [--json] — get tweets from a list timeline; --max-pages implies --all.
  • bird following [--user <userId>] [-n count] [--cursor string] [--all] [--max-pages n] [--json] — list users that you (or another user) follow; --max-pages requires --all.
  • bird followers [--user <userId>] [-n count] [--cursor string] [--all] [--max-pages n] [--json] — list users that follow you (or another user); --max-pages requires --all.
  • bird about <@handle> [--json] — get account origin and location information for a user.
  • bird whoami — print which Twitter account your cookies belong to.
  • bird check — show which credentials are available and where they were sourced from.

Bookmarks flags:

  • --expand-root-only: expand threads only when the bookmark is a root tweet.
  • --author-chain: keep only the bookmarked author's connected self-reply chain.
  • --author-only: include all tweets from the bookmarked author within the thread.
  • --full-chain-only: keep the entire reply chain connected to the bookmarked tweet (all authors).
  • --include-ancestor-branches: include sibling branches for ancestors when using --full-chain-only.
  • --include-parent: include the direct parent tweet for non-root bookmarks.
  • --thread-meta: add thread metadata fields to each tweet.
  • --sort-chronological: sort output globally oldest to newest (default preserves bookmark order).

Global options:

  • --auth-token <token>: set the auth_token cookie manually.
  • --ct0 <token>: set the ct0 cookie manually.
  • --cookie-source <safari|chrome|firefox>: choose browser cookie source (repeatable; order matters).
  • --chrome-profile <name>: Chrome profile name for cookie extraction (e.g., Default, Profile 2).
  • --chrome-profile-dir <path>: Chrome/Chromium profile directory or cookie DB path for cookie extraction.
  • --firefox-profile <name>: Firefox profile for cookie extraction.
  • --cookie-timeout <ms>: cookie extraction timeout for keychain/OS helpers (milliseconds).
  • --timeout <ms>: abort requests after the given timeout (milliseconds).
  • --quote-depth <n>: max quoted tweet depth in JSON output (default: 1; 0 disables).
  • --plain: stable output (no emoji, no color).
  • --no-emoji: disable emoji output.
  • --no-color: disable ANSI colors (or set NO_COLOR=1).
  • --media <path>: attach media file (repeatable, up to 4 images or 1 video).
  • --alt <text>: alt text for the corresponding --media (repeatable).

Authentication (GraphQL)

GraphQL mode uses your existing X/Twitter web session (no password prompt). It sends requests to internal X endpoints and authenticates via cookies (auth_token, ct0).

Write operations:

  • tweet/reply primarily use GraphQL (CreateTweet).
  • If GraphQL returns error 226 (“automated request”), bird falls back to the legacy statuses/update.json endpoint.

bird resolves credentials in this order:

  1. CLI flags: --auth-token, --ct0
  2. Environment variables: AUTH_TOKEN, CT0 (fallback: TWITTER_AUTH_TOKEN, TWITTER_CT0)
  3. Browser cookies via @steipete/sweet-cookie (override via --cookie-source order)

Browser cookie sources:

  • Safari: ~/Library/Cookies/Cookies.binarycookies (fallback: ~/Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies)
  • Chrome: ~/Library/Application Support/Google/Chrome/<Profile>/Cookies
  • Firefox: ~/Library/Application Support/Firefox/Profiles/<profile>/cookies.sqlite
    • For Chromium variants (Arc/Brave/etc), pass a profile directory or cookie DB via --chrome-profile-dir.

Config (JSON5)

Config precedence: CLI flags > env vars > project config > global config.

  • Global: ~/.config/bird/config.json5
  • Project: ./.birdrc.json5

Example ~/.config/bird/config.json5:

{// Cookie source order for browser extraction (string or array)cookieSource: ["firefox","safari"],chromeProfileDir: "/path/to/Chromium/Profile",firefoxProfile: "default-release",cookieTimeoutMs: 30000,timeoutMs: 20000,quoteDepth: 1}

Environment shortcuts:

  • BIRD_TIMEOUT_MS
  • BIRD_COOKIE_TIMEOUT_MS
  • BIRD_QUOTE_DEPTH

Output

  • --json prints raw tweet objects for read/replies/thread/search/mentions/user-tweets/bookmarks/likes.
  • When using --json with pagination (--all, --cursor, --max-pages, or for user-tweets when -n > 20), output is { tweets, nextCursor }.
  • read returns full text for Notes and Articles when present.
  • Use --plain for stable, script-friendly output (no emoji, no color).

JSON Schema

When using --json, tweet objects include:

FieldTypeDescription
idstringTweet ID
textstringFull tweet text (includes Note/Article content when present)
authorobject{ username, name }
authorIdstring?Author's user ID
createdAtstringTimestamp
replyCountnumberNumber of replies
retweetCountnumberNumber of retweets
likeCountnumberNumber of likes
conversationIdstringThread conversation ID
inReplyToStatusIdstring?Parent tweet ID (present if this is a reply)
quotedTweetobject?Embedded quote tweet (same schema; depth controlled by --quote-depth)

When using --json with following/followers, user objects include:

FieldTypeDescription
idstringUser ID
usernamestringUsername/handle
namestringDisplay name
descriptionstring?User bio
followersCountnumber?Followers count
followingCountnumber?Following count
isBlueVerifiedboolean?Blue verified flag
profileImageUrlstring?Profile image URL
createdAtstring?Account creation timestamp

When using --json with news/trending, news objects include:

FieldTypeDescription
idstringUnique identifier for the news item
headlinestringNews headline or trend title
categorystring?Category (e.g., "AI · Technology", "Trending", "News")
timeAgostring?Relative time (e.g., "2h ago")
postCountnumber?Number of posts
descriptionstring?Item description
urlstring?URL to the trend or news article
tweetsarray?Related tweets (only when --with-tweets is used)
_rawobject?Raw API response (only when --json-full is used)

Query IDs (GraphQL)

X rotates GraphQL “query IDs” frequently. Each GraphQL operation is addressed as:

  • operationName (e.g. TweetDetail, CreateTweet)
  • queryId (rotating ID baked into X’s web client bundles)

bird ships with a baseline mapping in src/lib/query-ids.json (copied into dist/ on build). At runtime, it can refresh that mapping by scraping X’s public web client bundles and caching the result on disk.

Runtime cache:

  • Default path: ~/.config/bird/query-ids-cache.json
  • Override path: BIRD_QUERY_IDS_CACHE=/path/to/file.json
  • TTL: 24h (stale cache is still used, but marked “not fresh”)

Auto-recovery:

  • On GraphQL 404 (query ID invalid), bird forces a refresh once and retries.
  • For TweetDetail/SearchTimeline, bird also rotates through a small set of known fallback IDs to reduce breakage while refreshing.

Refresh on demand:

bird query-ids --fresh

Exit codes:

  • 0: success
  • 1: runtime error (network/auth/etc)
  • 2: invalid usage/validation (e.g. bad --user handle)

Version

bird --version prints package.json version plus current git sha when available, e.g. 0.3.0 (3df7969b).

Media uploads

  • Attach media with --media (repeatable) and optional --alt per item.
  • Up to 4 images/GIFs, or 1 video (no mixing). Supported: jpg, jpeg, png, webp, gif, mp4, mov.
  • Images/GIFs + 1 video supported (uploads via Twitter legacy upload endpoint + cookies; video may take longer to process).

Example:

bird tweet "hi" --media img.png --alt "desc"

Development

cd~/Projects/bird
pnpm install
pnpm run build # dist/ + bun binary
pnpm run build:dist # dist/ only
pnpm run build:binary
pnpm run dev tweet "Test"
pnpm run dev -- --plain check
pnpm test
pnpm run lint

Notes

  • GraphQL uses internal X endpoints and can be rate limited (429).
  • Query IDs rotate; refresh at runtime with bird query-ids --fresh (or update the baked baseline via pnpm run graphql:update).

About

CLI tool for X/Twitter - rescued from @steipete/bird v0.8.0

Resources

Stars

21 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

bird 🐦 — fast X CLI for tweeting, replying, and reading

bird is a fast X CLI for tweeting, replying, and reading via X/Twitter GraphQL (cookie auth).

Disclaimer

This project uses X/Twitter’s undocumented web GraphQL API (and cookie auth). X can change endpoints, query IDs, and anti-bot behavior at any time — expect this to break without notice.

Install

npm install -g @steipete/bird
# or
pnpm add -g @steipete/bird
# or
bun add -g @steipete/bird
# one-shot (no install)
bunx @steipete/bird whoami

Homebrew (macOS, prebuilt Bun binary):

brew install steipete/tap/bird

Quickstart

# Show the logged-in account
bird whoami
# Discover command help
bird help whoami
# Read a tweet (URL or ID)
bird read https://x.com/user/status/1234567890123456789
bird 1234567890123456789 --json
# Thread + replies
bird thread https://x.com/user/status/1234567890123456789
bird replies 1234567890123456789
bird replies 1234567890123456789 --max-pages 3 --json
bird thread 1234567890123456789 --max-pages 3 --json
# Search + mentions
bird search "from:steipete" -n 5
bird mentions -n 5
bird mentions --user @steipete -n 5
# User tweets (profile timeline)
bird user-tweets @steipete -n 20
bird user-tweets @steipete -n 50 --json
# Bookmarks
bird bookmarks -n 5
bird bookmarks --folder-id 123456789123456789 -n 5 # https://x.com/i/bookmarks/<folder-id>
bird bookmarks --all --json
bird bookmarks --all --max-pages 2 --json
bird bookmarks --include-parent --json
bird unbookmark 1234567890123456789
bird unbookmark https://x.com/user/status/1234567890123456789
# Likes
bird likes -n 5
# News and trending topics (AI-curated from Explore tabs)
bird news --ai-only -n 10
bird news --sports -n 5
# Lists
bird list-timeline 1234567890 -n 20
bird list-timeline https://x.com/i/lists/1234567890 --all --json
bird list-timeline 1234567890 --max-pages 3 --json
# Following (who you follow)
bird following -n 20
bird following --user 12345678 -n 10 # by user ID# Followers (who follows you)
bird followers -n 20
bird followers --user 12345678 -n 10 # by user ID# Refresh GraphQL query IDs cache (no rebuild)
bird query-ids --fresh

News & Trending

Fetch AI-curated news and trending topics from X's Explore page tabs:

# Fetch 10 news items from all tabs (default: For You, News, Sports, Entertainment)
bird news -n 10
# Fetch only AI-curated news (filters out regular trends)
bird news --ai-only -n 20
# Fetch from specific tabs
bird news --news-only --ai-only -n 10
bird news --sports -n 15
bird news --entertainment --ai-only -n 5
# Include related tweets for each news item
bird news --with-tweets --tweets-per-item 3 -n 10
# Combine multiple tab filters
bird news --sports --entertainment -n 20
# JSON output
bird news --json -n 5
bird news --json-full --ai-only -n 10 # includes raw API response

Tab options (can be combined):

  • --for-you — Fetch from For You tab only
  • --news-only — Fetch from News tab only
  • --sports — Fetch from Sports tab only
  • --entertainment — Fetch from Entertainment tab only
  • --trending-only — Fetch from Trending tab only

By default, the command fetches from For You, News, Sports, and Entertainment tabs (Trending excluded to reduce noise). Headlines are automatically deduplicated across tabs.

Library

bird can be used as a library (same GraphQL client as the CLI):

import{TwitterClient,resolveCredentials}from'@steipete/bird';const{ cookies }=awaitresolveCredentials({cookieSource: 'safari'});constclient=newTwitterClient({ cookies });// Search for tweetsconstsearchResult=awaitclient.search('from:steipete',50);// Fetch news and trending topics from all tabs (default: For You, News, Sports, Entertainment)constnewsResult=awaitclient.getNews(10,{aiOnly: true});// Fetch from specific tabs with related tweetsconstsportsNews=awaitclient.getNews(10,{aiOnly: true,withTweets: true,tabs: ['sports','entertainment']});

Account details (About profile):

constaboutResult=awaitclient.getUserAboutAccount('steipete');if(aboutResult.success&&aboutResult.aboutProfile){console.log(aboutResult.aboutProfile.accountBasedIn);}

Fields:

  • accountBasedIn
  • source
  • createdCountryAccurate
  • locationAccurate
  • learnMoreUrl

Commands

  • bird tweet "<text>" — post a new tweet.
  • bird reply <tweet-id-or-url> "<text>" — reply to a tweet using its ID or URL.
  • bird help [command] — show help (or help for a subcommand).
  • bird query-ids [--fresh] [--json] — inspect or refresh cached GraphQL query IDs.
  • bird home [-n count] [--following] [--json] [--json-full] — fetch your home timeline (For You) or Following feed.
  • bird read <tweet-id-or-url> [--json] — fetch tweet content as text or JSON.
  • bird <tweet-id-or-url> [--json] — shorthand for read when only a URL or ID is provided.
  • bird replies <tweet-id-or-url> [--all] [--max-pages n] [--cursor string] [--delay ms] [--json] — list replies to a tweet.
  • bird thread <tweet-id-or-url> [--all] [--max-pages n] [--cursor string] [--delay ms] [--json] — show the full conversation thread.
  • bird search "<query>" [-n count] [--all] [--max-pages n] [--cursor string] [--json] — search for tweets matching a query; --max-pages requires --all or --cursor.
  • bird mentions [-n count] [--user @handle] [--json] — find tweets mentioning a user (defaults to the authenticated user).
  • bird user-tweets <@handle> [-n count] [--cursor string] [--max-pages n] [--delay ms] [--json] — get tweets from a user's profile timeline.
  • bird bookmarks [-n count] [--folder-id id] [--all] [--max-pages n] [--cursor string] [--expand-root-only] [--author-chain] [--author-only] [--full-chain-only] [--include-ancestor-branches] [--include-parent] [--thread-meta] [--sort-chronological] [--json] — list your bookmarked tweets (or a specific bookmark folder); expansion flags control thread context; --max-pages requires --all or --cursor.
  • bird unbookmark <tweet-id-or-url...> — remove one or more bookmarks by tweet ID or URL.
  • bird likes [-n count] [--all] [--max-pages n] [--cursor string] [--json] [--json-full] — list your liked tweets; --max-pages requires --all or --cursor.
  • bird news [-n count] [--ai-only] [--with-tweets] [--tweets-per-item n] [--for-you] [--news-only] [--sports] [--entertainment] [--trending-only] [--json] — fetch news and trending topics from X's Explore tabs.
  • bird trending — alias for news command.
  • bird lists [--member-of] [-n count] [--json] — list your lists (owned or memberships).
  • bird list-timeline <list-id-or-url> [-n count] [--all] [--max-pages n] [--cursor string] [--json] — get tweets from a list timeline; --max-pages implies --all.
  • bird following [--user <userId>] [-n count] [--cursor string] [--all] [--max-pages n] [--json] — list users that you (or another user) follow; --max-pages requires --all.
  • bird followers [--user <userId>] [-n count] [--cursor string] [--all] [--max-pages n] [--json] — list users that follow you (or another user); --max-pages requires --all.
  • bird about <@handle> [--json] — get account origin and location information for a user.
  • bird whoami — print which Twitter account your cookies belong to.
  • bird check — show which credentials are available and where they were sourced from.

Bookmarks flags:

  • --expand-root-only: expand threads only when the bookmark is a root tweet.
  • --author-chain: keep only the bookmarked author's connected self-reply chain.
  • --author-only: include all tweets from the bookmarked author within the thread.
  • --full-chain-only: keep the entire reply chain connected to the bookmarked tweet (all authors).
  • --include-ancestor-branches: include sibling branches for ancestors when using --full-chain-only.
  • --include-parent: include the direct parent tweet for non-root bookmarks.
  • --thread-meta: add thread metadata fields to each tweet.
  • --sort-chronological: sort output globally oldest to newest (default preserves bookmark order).

Global options:

  • --auth-token <token>: set the auth_token cookie manually.
  • --ct0 <token>: set the ct0 cookie manually.
  • --cookie-source <safari|chrome|firefox>: choose browser cookie source (repeatable; order matters).
  • --chrome-profile <name>: Chrome profile name for cookie extraction (e.g., Default, Profile 2).
  • --chrome-profile-dir <path>: Chrome/Chromium profile directory or cookie DB path for cookie extraction.
  • --firefox-profile <name>: Firefox profile for cookie extraction.
  • --cookie-timeout <ms>: cookie extraction timeout for keychain/OS helpers (milliseconds).
  • --timeout <ms>: abort requests after the given timeout (milliseconds).
  • --quote-depth <n>: max quoted tweet depth in JSON output (default: 1; 0 disables).
  • --plain: stable output (no emoji, no color).
  • --no-emoji: disable emoji output.
  • --no-color: disable ANSI colors (or set NO_COLOR=1).
  • --media <path>: attach media file (repeatable, up to 4 images or 1 video).
  • --alt <text>: alt text for the corresponding --media (repeatable).

Authentication (GraphQL)

GraphQL mode uses your existing X/Twitter web session (no password prompt). It sends requests to internal X endpoints and authenticates via cookies (auth_token, ct0).

Write operations:

  • tweet/reply primarily use GraphQL (CreateTweet).
  • If GraphQL returns error 226 (“automated request”), bird falls back to the legacy statuses/update.json endpoint.

bird resolves credentials in this order:

  1. CLI flags: --auth-token, --ct0
  2. Environment variables: AUTH_TOKEN, CT0 (fallback: TWITTER_AUTH_TOKEN, TWITTER_CT0)
  3. Browser cookies via @steipete/sweet-cookie (override via --cookie-source order)

Browser cookie sources:

  • Safari: ~/Library/Cookies/Cookies.binarycookies (fallback: ~/Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies)
  • Chrome: ~/Library/Application Support/Google/Chrome/<Profile>/Cookies
  • Firefox: ~/Library/Application Support/Firefox/Profiles/<profile>/cookies.sqlite
    • For Chromium variants (Arc/Brave/etc), pass a profile directory or cookie DB via --chrome-profile-dir.

Config (JSON5)

Config precedence: CLI flags > env vars > project config > global config.

  • Global: ~/.config/bird/config.json5
  • Project: ./.birdrc.json5

Example ~/.config/bird/config.json5:

{// Cookie source order for browser extraction (string or array)cookieSource: ["firefox","safari"],chromeProfileDir: "/path/to/Chromium/Profile",firefoxProfile: "default-release",cookieTimeoutMs: 30000,timeoutMs: 20000,quoteDepth: 1}

Environment shortcuts:

  • BIRD_TIMEOUT_MS
  • BIRD_COOKIE_TIMEOUT_MS
  • BIRD_QUOTE_DEPTH

Output

  • --json prints raw tweet objects for read/replies/thread/search/mentions/user-tweets/bookmarks/likes.
  • When using --json with pagination (--all, --cursor, --max-pages, or for user-tweets when -n > 20), output is { tweets, nextCursor }.
  • read returns full text for Notes and Articles when present.
  • Use --plain for stable, script-friendly output (no emoji, no color).

JSON Schema

When using --json, tweet objects include:

FieldTypeDescription
idstringTweet ID
textstringFull tweet text (includes Note/Article content when present)
authorobject{ username, name }
authorIdstring?Author's user ID
createdAtstringTimestamp
replyCountnumberNumber of replies
retweetCountnumberNumber of retweets
likeCountnumberNumber of likes
conversationIdstringThread conversation ID
inReplyToStatusIdstring?Parent tweet ID (present if this is a reply)
quotedTweetobject?Embedded quote tweet (same schema; depth controlled by --quote-depth)

When using --json with following/followers, user objects include:

FieldTypeDescription
idstringUser ID
usernamestringUsername/handle
namestringDisplay name
descriptionstring?User bio
followersCountnumber?Followers count
followingCountnumber?Following count
isBlueVerifiedboolean?Blue verified flag
profileImageUrlstring?Profile image URL
createdAtstring?Account creation timestamp

When using --json with news/trending, news objects include:

FieldTypeDescription
idstringUnique identifier for the news item
headlinestringNews headline or trend title
categorystring?Category (e.g., "AI · Technology", "Trending", "News")
timeAgostring?Relative time (e.g., "2h ago")
postCountnumber?Number of posts
descriptionstring?Item description
urlstring?URL to the trend or news article
tweetsarray?Related tweets (only when --with-tweets is used)
_rawobject?Raw API response (only when --json-full is used)

Query IDs (GraphQL)

X rotates GraphQL “query IDs” frequently. Each GraphQL operation is addressed as:

  • operationName (e.g. TweetDetail, CreateTweet)
  • queryId (rotating ID baked into X’s web client bundles)

bird ships with a baseline mapping in src/lib/query-ids.json (copied into dist/ on build). At runtime, it can refresh that mapping by scraping X’s public web client bundles and caching the result on disk.

Runtime cache:

  • Default path: ~/.config/bird/query-ids-cache.json
  • Override path: BIRD_QUERY_IDS_CACHE=/path/to/file.json
  • TTL: 24h (stale cache is still used, but marked “not fresh”)

Auto-recovery:

  • On GraphQL 404 (query ID invalid), bird forces a refresh once and retries.
  • For TweetDetail/SearchTimeline, bird also rotates through a small set of known fallback IDs to reduce breakage while refreshing.

Refresh on demand:

bird query-ids --fresh

Exit codes:

  • 0: success
  • 1: runtime error (network/auth/etc)
  • 2: invalid usage/validation (e.g. bad --user handle)

Version

bird --version prints package.json version plus current git sha when available, e.g. 0.3.0 (3df7969b).

Media uploads

  • Attach media with --media (repeatable) and optional --alt per item.
  • Up to 4 images/GIFs, or 1 video (no mixing). Supported: jpg, jpeg, png, webp, gif, mp4, mov.
  • Images/GIFs + 1 video supported (uploads via Twitter legacy upload endpoint + cookies; video may take longer to process).

Example:

bird tweet "hi" --media img.png --alt "desc"

Development

cd~/Projects/bird
pnpm install
pnpm run build # dist/ + bun binary
pnpm run build:dist # dist/ only
pnpm run build:binary
pnpm run dev tweet "Test"
pnpm run dev -- --plain check
pnpm test
pnpm run lint

Notes

  • GraphQL uses internal X endpoints and can be rate limited (429).
  • Query IDs rotate; refresh at runtime with bird query-ids --fresh (or update the baked baseline via pnpm run graphql:update).

About

CLI tool for X/Twitter - rescued from @steipete/bird v0.8.0

Resources

Stars

21 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

bird 🐦 — fast X CLI for tweeting, replying, and reading

bird is a fast X CLI for tweeting, replying, and reading via X/Twitter GraphQL (cookie auth).

Disclaimer

This project uses X/Twitter’s undocumented web GraphQL API (and cookie auth). X can change endpoints, query IDs, and anti-bot behavior at any time — expect this to break without notice.

Install

npm install -g @steipete/bird
# or
pnpm add -g @steipete/bird
# or
bun add -g @steipete/bird
# one-shot (no install)
bunx @steipete/bird whoami

Homebrew (macOS, prebuilt Bun binary):

brew install steipete/tap/bird

Quickstart

# Show the logged-in account
bird whoami
# Discover command help
bird help whoami
# Read a tweet (URL or ID)
bird read https://x.com/user/status/1234567890123456789
bird 1234567890123456789 --json
# Thread + replies
bird thread https://x.com/user/status/1234567890123456789
bird replies 1234567890123456789
bird replies 1234567890123456789 --max-pages 3 --json
bird thread 1234567890123456789 --max-pages 3 --json
# Search + mentions
bird search "from:steipete" -n 5
bird mentions -n 5
bird mentions --user @steipete -n 5
# User tweets (profile timeline)
bird user-tweets @steipete -n 20
bird user-tweets @steipete -n 50 --json
# Bookmarks
bird bookmarks -n 5
bird bookmarks --folder-id 123456789123456789 -n 5 # https://x.com/i/bookmarks/<folder-id>
bird bookmarks --all --json
bird bookmarks --all --max-pages 2 --json
bird bookmarks --include-parent --json
bird unbookmark 1234567890123456789
bird unbookmark https://x.com/user/status/1234567890123456789
# Likes
bird likes -n 5
# News and trending topics (AI-curated from Explore tabs)
bird news --ai-only -n 10
bird news --sports -n 5
# Lists
bird list-timeline 1234567890 -n 20
bird list-timeline https://x.com/i/lists/1234567890 --all --json
bird list-timeline 1234567890 --max-pages 3 --json
# Following (who you follow)
bird following -n 20
bird following --user 12345678 -n 10 # by user ID# Followers (who follows you)
bird followers -n 20
bird followers --user 12345678 -n 10 # by user ID# Refresh GraphQL query IDs cache (no rebuild)
bird query-ids --fresh

News & Trending

Fetch AI-curated news and trending topics from X's Explore page tabs:

# Fetch 10 news items from all tabs (default: For You, News, Sports, Entertainment)
bird news -n 10
# Fetch only AI-curated news (filters out regular trends)
bird news --ai-only -n 20
# Fetch from specific tabs
bird news --news-only --ai-only -n 10
bird news --sports -n 15
bird news --entertainment --ai-only -n 5
# Include related tweets for each news item
bird news --with-tweets --tweets-per-item 3 -n 10
# Combine multiple tab filters
bird news --sports --entertainment -n 20
# JSON output
bird news --json -n 5
bird news --json-full --ai-only -n 10 # includes raw API response

Tab options (can be combined):

  • --for-you — Fetch from For You tab only
  • --news-only — Fetch from News tab only
  • --sports — Fetch from Sports tab only
  • --entertainment — Fetch from Entertainment tab only
  • --trending-only — Fetch from Trending tab only

By default, the command fetches from For You, News, Sports, and Entertainment tabs (Trending excluded to reduce noise). Headlines are automatically deduplicated across tabs.

Library

bird can be used as a library (same GraphQL client as the CLI):

import{TwitterClient,resolveCredentials}from'@steipete/bird';const{ cookies }=awaitresolveCredentials({cookieSource: 'safari'});constclient=newTwitterClient({ cookies });// Search for tweetsconstsearchResult=awaitclient.search('from:steipete',50);// Fetch news and trending topics from all tabs (default: For You, News, Sports, Entertainment)constnewsResult=awaitclient.getNews(10,{aiOnly: true});// Fetch from specific tabs with related tweetsconstsportsNews=awaitclient.getNews(10,{aiOnly: true,withTweets: true,tabs: ['sports','entertainment']});

Account details (About profile):

constaboutResult=awaitclient.getUserAboutAccount('steipete');if(aboutResult.success&&aboutResult.aboutProfile){console.log(aboutResult.aboutProfile.accountBasedIn);}

Fields:

  • accountBasedIn
  • source
  • createdCountryAccurate
  • locationAccurate
  • learnMoreUrl

Commands

  • bird tweet "<text>" — post a new tweet.
  • bird reply <tweet-id-or-url> "<text>" — reply to a tweet using its ID or URL.
  • bird help [command] — show help (or help for a subcommand).
  • bird query-ids [--fresh] [--json] — inspect or refresh cached GraphQL query IDs.
  • bird home [-n count] [--following] [--json] [--json-full] — fetch your home timeline (For You) or Following feed.
  • bird read <tweet-id-or-url> [--json] — fetch tweet content as text or JSON.
  • bird <tweet-id-or-url> [--json] — shorthand for read when only a URL or ID is provided.
  • bird replies <tweet-id-or-url> [--all] [--max-pages n] [--cursor string] [--delay ms] [--json] — list replies to a tweet.
  • bird thread <tweet-id-or-url> [--all] [--max-pages n] [--cursor string] [--delay ms] [--json] — show the full conversation thread.
  • bird search "<query>" [-n count] [--all] [--max-pages n] [--cursor string] [--json] — search for tweets matching a query; --max-pages requires --all or --cursor.
  • bird mentions [-n count] [--user @handle] [--json] — find tweets mentioning a user (defaults to the authenticated user).
  • bird user-tweets <@handle> [-n count] [--cursor string] [--max-pages n] [--delay ms] [--json] — get tweets from a user's profile timeline.
  • bird bookmarks [-n count] [--folder-id id] [--all] [--max-pages n] [--cursor string] [--expand-root-only] [--author-chain] [--author-only] [--full-chain-only] [--include-ancestor-branches] [--include-parent] [--thread-meta] [--sort-chronological] [--json] — list your bookmarked tweets (or a specific bookmark folder); expansion flags control thread context; --max-pages requires --all or --cursor.
  • bird unbookmark <tweet-id-or-url...> — remove one or more bookmarks by tweet ID or URL.
  • bird likes [-n count] [--all] [--max-pages n] [--cursor string] [--json] [--json-full] — list your liked tweets; --max-pages requires --all or --cursor.
  • bird news [-n count] [--ai-only] [--with-tweets] [--tweets-per-item n] [--for-you] [--news-only] [--sports] [--entertainment] [--trending-only] [--json] — fetch news and trending topics from X's Explore tabs.
  • bird trending — alias for news command.
  • bird lists [--member-of] [-n count] [--json] — list your lists (owned or memberships).
  • bird list-timeline <list-id-or-url> [-n count] [--all] [--max-pages n] [--cursor string] [--json] — get tweets from a list timeline; --max-pages implies --all.
  • bird following [--user <userId>] [-n count] [--cursor string] [--all] [--max-pages n] [--json] — list users that you (or another user) follow; --max-pages requires --all.
  • bird followers [--user <userId>] [-n count] [--cursor string] [--all] [--max-pages n] [--json] — list users that follow you (or another user); --max-pages requires --all.
  • bird about <@handle> [--json] — get account origin and location information for a user.
  • bird whoami — print which Twitter account your cookies belong to.
  • bird check — show which credentials are available and where they were sourced from.

Bookmarks flags:

  • --expand-root-only: expand threads only when the bookmark is a root tweet.
  • --author-chain: keep only the bookmarked author's connected self-reply chain.
  • --author-only: include all tweets from the bookmarked author within the thread.
  • --full-chain-only: keep the entire reply chain connected to the bookmarked tweet (all authors).
  • --include-ancestor-branches: include sibling branches for ancestors when using --full-chain-only.
  • --include-parent: include the direct parent tweet for non-root bookmarks.
  • --thread-meta: add thread metadata fields to each tweet.
  • --sort-chronological: sort output globally oldest to newest (default preserves bookmark order).

Global options:

  • --auth-token <token>: set the auth_token cookie manually.
  • --ct0 <token>: set the ct0 cookie manually.
  • --cookie-source <safari|chrome|firefox>: choose browser cookie source (repeatable; order matters).
  • --chrome-profile <name>: Chrome profile name for cookie extraction (e.g., Default, Profile 2).
  • --chrome-profile-dir <path>: Chrome/Chromium profile directory or cookie DB path for cookie extraction.
  • --firefox-profile <name>: Firefox profile for cookie extraction.
  • --cookie-timeout <ms>: cookie extraction timeout for keychain/OS helpers (milliseconds).
  • --timeout <ms>: abort requests after the given timeout (milliseconds).
  • --quote-depth <n>: max quoted tweet depth in JSON output (default: 1; 0 disables).
  • --plain: stable output (no emoji, no color).
  • --no-emoji: disable emoji output.
  • --no-color: disable ANSI colors (or set NO_COLOR=1).
  • --media <path>: attach media file (repeatable, up to 4 images or 1 video).
  • --alt <text>: alt text for the corresponding --media (repeatable).

Authentication (GraphQL)

GraphQL mode uses your existing X/Twitter web session (no password prompt). It sends requests to internal X endpoints and authenticates via cookies (auth_token, ct0).

Write operations:

  • tweet/reply primarily use GraphQL (CreateTweet).
  • If GraphQL returns error 226 (“automated request”), bird falls back to the legacy statuses/update.json endpoint.

bird resolves credentials in this order:

  1. CLI flags: --auth-token, --ct0
  2. Environment variables: AUTH_TOKEN, CT0 (fallback: TWITTER_AUTH_TOKEN, TWITTER_CT0)
  3. Browser cookies via @steipete/sweet-cookie (override via --cookie-source order)

Browser cookie sources:

  • Safari: ~/Library/Cookies/Cookies.binarycookies (fallback: ~/Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies)
  • Chrome: ~/Library/Application Support/Google/Chrome/<Profile>/Cookies
  • Firefox: ~/Library/Application Support/Firefox/Profiles/<profile>/cookies.sqlite
    • For Chromium variants (Arc/Brave/etc), pass a profile directory or cookie DB via --chrome-profile-dir.

Config (JSON5)

Config precedence: CLI flags > env vars > project config > global config.

  • Global: ~/.config/bird/config.json5
  • Project: ./.birdrc.json5

Example ~/.config/bird/config.json5:

{// Cookie source order for browser extraction (string or array)cookieSource: ["firefox","safari"],chromeProfileDir: "/path/to/Chromium/Profile",firefoxProfile: "default-release",cookieTimeoutMs: 30000,timeoutMs: 20000,quoteDepth: 1}

Environment shortcuts:

  • BIRD_TIMEOUT_MS
  • BIRD_COOKIE_TIMEOUT_MS
  • BIRD_QUOTE_DEPTH

Output

  • --json prints raw tweet objects for read/replies/thread/search/mentions/user-tweets/bookmarks/likes.
  • When using --json with pagination (--all, --cursor, --max-pages, or for user-tweets when -n > 20), output is { tweets, nextCursor }.
  • read returns full text for Notes and Articles when present.
  • Use --plain for stable, script-friendly output (no emoji, no color).

JSON Schema

When using --json, tweet objects include:

FieldTypeDescription
idstringTweet ID
textstringFull tweet text (includes Note/Article content when present)
authorobject{ username, name }
authorIdstring?Author's user ID
createdAtstringTimestamp
replyCountnumberNumber of replies
retweetCountnumberNumber of retweets
likeCountnumberNumber of likes
conversationIdstringThread conversation ID
inReplyToStatusIdstring?Parent tweet ID (present if this is a reply)
quotedTweetobject?Embedded quote tweet (same schema; depth controlled by --quote-depth)

When using --json with following/followers, user objects include:

FieldTypeDescription
idstringUser ID
usernamestringUsername/handle
namestringDisplay name
descriptionstring?User bio
followersCountnumber?Followers count
followingCountnumber?Following count
isBlueVerifiedboolean?Blue verified flag
profileImageUrlstring?Profile image URL
createdAtstring?Account creation timestamp

When using --json with news/trending, news objects include:

FieldTypeDescription
idstringUnique identifier for the news item
headlinestringNews headline or trend title
categorystring?Category (e.g., "AI · Technology", "Trending", "News")
timeAgostring?Relative time (e.g., "2h ago")
postCountnumber?Number of posts
descriptionstring?Item description
urlstring?URL to the trend or news article
tweetsarray?Related tweets (only when --with-tweets is used)
_rawobject?Raw API response (only when --json-full is used)

Query IDs (GraphQL)

X rotates GraphQL “query IDs” frequently. Each GraphQL operation is addressed as:

  • operationName (e.g. TweetDetail, CreateTweet)
  • queryId (rotating ID baked into X’s web client bundles)

bird ships with a baseline mapping in src/lib/query-ids.json (copied into dist/ on build). At runtime, it can refresh that mapping by scraping X’s public web client bundles and caching the result on disk.

Runtime cache:

  • Default path: ~/.config/bird/query-ids-cache.json
  • Override path: BIRD_QUERY_IDS_CACHE=/path/to/file.json
  • TTL: 24h (stale cache is still used, but marked “not fresh”)

Auto-recovery:

  • On GraphQL 404 (query ID invalid), bird forces a refresh once and retries.
  • For TweetDetail/SearchTimeline, bird also rotates through a small set of known fallback IDs to reduce breakage while refreshing.

Refresh on demand:

bird query-ids --fresh

Exit codes:

  • 0: success
  • 1: runtime error (network/auth/etc)
  • 2: invalid usage/validation (e.g. bad --user handle)

Version

bird --version prints package.json version plus current git sha when available, e.g. 0.3.0 (3df7969b).

Media uploads

  • Attach media with --media (repeatable) and optional --alt per item.
  • Up to 4 images/GIFs, or 1 video (no mixing). Supported: jpg, jpeg, png, webp, gif, mp4, mov.
  • Images/GIFs + 1 video supported (uploads via Twitter legacy upload endpoint + cookies; video may take longer to process).

Example:

bird tweet "hi" --media img.png --alt "desc"

Development

cd~/Projects/bird
pnpm install
pnpm run build # dist/ + bun binary
pnpm run build:dist # dist/ only
pnpm run build:binary
pnpm run dev tweet "Test"
pnpm run dev -- --plain check
pnpm test
pnpm run lint

Notes

  • GraphQL uses internal X endpoints and can be rate limited (429).
  • Query IDs rotate; refresh at runtime with bird query-ids --fresh (or update the baked baseline via pnpm run graphql:update).

About

CLI tool for X/Twitter - rescued from @steipete/bird v0.8.0

Resources

Stars

21 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Latest commit

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

bird 🐦 — fast X CLI for tweeting, replying, and reading

bird is a fast X CLI for tweeting, replying, and reading via X/Twitter GraphQL (cookie auth).

Disclaimer

This project uses X/Twitter’s undocumented web GraphQL API (and cookie auth). X can change endpoints, query IDs, and anti-bot behavior at any time — expect this to break without notice.

Install

npm install -g @steipete/bird
# or
pnpm add -g @steipete/bird
# or
bun add -g @steipete/bird
# one-shot (no install)
bunx @steipete/bird whoami

Homebrew (macOS, prebuilt Bun binary):

brew install steipete/tap/bird

Quickstart

# Show the logged-in account
bird whoami
# Discover command help
bird help whoami
# Read a tweet (URL or ID)
bird read https://x.com/user/status/1234567890123456789
bird 1234567890123456789 --json
# Thread + replies
bird thread https://x.com/user/status/1234567890123456789
bird replies 1234567890123456789
bird replies 1234567890123456789 --max-pages 3 --json
bird thread 1234567890123456789 --max-pages 3 --json
# Search + mentions
bird search "from:steipete" -n 5
bird mentions -n 5
bird mentions --user @steipete -n 5
# User tweets (profile timeline)
bird user-tweets @steipete -n 20
bird user-tweets @steipete -n 50 --json
# Bookmarks
bird bookmarks -n 5
bird bookmarks --folder-id 123456789123456789 -n 5 # https://x.com/i/bookmarks/<folder-id>
bird bookmarks --all --json
bird bookmarks --all --max-pages 2 --json
bird bookmarks --include-parent --json
bird unbookmark 1234567890123456789
bird unbookmark https://x.com/user/status/1234567890123456789
# Likes
bird likes -n 5
# News and trending topics (AI-curated from Explore tabs)
bird news --ai-only -n 10
bird news --sports -n 5
# Lists
bird list-timeline 1234567890 -n 20
bird list-timeline https://x.com/i/lists/1234567890 --all --json
bird list-timeline 1234567890 --max-pages 3 --json
# Following (who you follow)
bird following -n 20
bird following --user 12345678 -n 10 # by user ID# Followers (who follows you)
bird followers -n 20
bird followers --user 12345678 -n 10 # by user ID# Refresh GraphQL query IDs cache (no rebuild)
bird query-ids --fresh

News & Trending

Fetch AI-curated news and trending topics from X's Explore page tabs:

# Fetch 10 news items from all tabs (default: For You, News, Sports, Entertainment)
bird news -n 10
# Fetch only AI-curated news (filters out regular trends)
bird news --ai-only -n 20
# Fetch from specific tabs
bird news --news-only --ai-only -n 10
bird news --sports -n 15
bird news --entertainment --ai-only -n 5
# Include related tweets for each news item
bird news --with-tweets --tweets-per-item 3 -n 10
# Combine multiple tab filters
bird news --sports --entertainment -n 20
# JSON output
bird news --json -n 5
bird news --json-full --ai-only -n 10 # includes raw API response

Tab options (can be combined):

  • --for-you — Fetch from For You tab only
  • --news-only — Fetch from News tab only
  • --sports — Fetch from Sports tab only
  • --entertainment — Fetch from Entertainment tab only
  • --trending-only — Fetch from Trending tab only

By default, the command fetches from For You, News, Sports, and Entertainment tabs (Trending excluded to reduce noise). Headlines are automatically deduplicated across tabs.

Library

bird can be used as a library (same GraphQL client as the CLI):

import{TwitterClient,resolveCredentials}from'@steipete/bird';const{ cookies }=awaitresolveCredentials({cookieSource: 'safari'});constclient=newTwitterClient({ cookies });// Search for tweetsconstsearchResult=awaitclient.search('from:steipete',50);// Fetch news and trending topics from all tabs (default: For You, News, Sports, Entertainment)constnewsResult=awaitclient.getNews(10,{aiOnly: true});// Fetch from specific tabs with related tweetsconstsportsNews=awaitclient.getNews(10,{aiOnly: true,withTweets: true,tabs: ['sports','entertainment']});

Account details (About profile):

constaboutResult=awaitclient.getUserAboutAccount('steipete');if(aboutResult.success&&aboutResult.aboutProfile){console.log(aboutResult.aboutProfile.accountBasedIn);}

Fields:

  • accountBasedIn
  • source
  • createdCountryAccurate
  • locationAccurate
  • learnMoreUrl

Commands

  • bird tweet "<text>" — post a new tweet.
  • bird reply <tweet-id-or-url> "<text>" — reply to a tweet using its ID or URL.
  • bird help [command] — show help (or help for a subcommand).
  • bird query-ids [--fresh] [--json] — inspect or refresh cached GraphQL query IDs.
  • bird home [-n count] [--following] [--json] [--json-full] — fetch your home timeline (For You) or Following feed.
  • bird read <tweet-id-or-url> [--json] — fetch tweet content as text or JSON.
  • bird <tweet-id-or-url> [--json] — shorthand for read when only a URL or ID is provided.
  • bird replies <tweet-id-or-url> [--all] [--max-pages n] [--cursor string] [--delay ms] [--json] — list replies to a tweet.
  • bird thread <tweet-id-or-url> [--all] [--max-pages n] [--cursor string] [--delay ms] [--json] — show the full conversation thread.
  • bird search "<query>" [-n count] [--all] [--max-pages n] [--cursor string] [--json] — search for tweets matching a query; --max-pages requires --all or --cursor.
  • bird mentions [-n count] [--user @handle] [--json] — find tweets mentioning a user (defaults to the authenticated user).
  • bird user-tweets <@handle> [-n count] [--cursor string] [--max-pages n] [--delay ms] [--json] — get tweets from a user's profile timeline.
  • bird bookmarks [-n count] [--folder-id id] [--all] [--max-pages n] [--cursor string] [--expand-root-only] [--author-chain] [--author-only] [--full-chain-only] [--include-ancestor-branches] [--include-parent] [--thread-meta] [--sort-chronological] [--json] — list your bookmarked tweets (or a specific bookmark folder); expansion flags control thread context; --max-pages requires --all or --cursor.
  • bird unbookmark <tweet-id-or-url...> — remove one or more bookmarks by tweet ID or URL.
  • bird likes [-n count] [--all] [--max-pages n] [--cursor string] [--json] [--json-full] — list your liked tweets; --max-pages requires --all or --cursor.
  • bird news [-n count] [--ai-only] [--with-tweets] [--tweets-per-item n] [--for-you] [--news-only] [--sports] [--entertainment] [--trending-only] [--json] — fetch news and trending topics from X's Explore tabs.
  • bird trending — alias for news command.
  • bird lists [--member-of] [-n count] [--json] — list your lists (owned or memberships).
  • bird list-timeline <list-id-or-url> [-n count] [--all] [--max-pages n] [--cursor string] [--json] — get tweets from a list timeline; --max-pages implies --all.
  • bird following [--user <userId>] [-n count] [--cursor string] [--all] [--max-pages n] [--json] — list users that you (or another user) follow; --max-pages requires --all.
  • bird followers [--user <userId>] [-n count] [--cursor string] [--all] [--max-pages n] [--json] — list users that follow you (or another user); --max-pages requires --all.
  • bird about <@handle> [--json] — get account origin and location information for a user.
  • bird whoami — print which Twitter account your cookies belong to.
  • bird check — show which credentials are available and where they were sourced from.

Bookmarks flags:

  • --expand-root-only: expand threads only when the bookmark is a root tweet.
  • --author-chain: keep only the bookmarked author's connected self-reply chain.
  • --author-only: include all tweets from the bookmarked author within the thread.
  • --full-chain-only: keep the entire reply chain connected to the bookmarked tweet (all authors).
  • --include-ancestor-branches: include sibling branches for ancestors when using --full-chain-only.
  • --include-parent: include the direct parent tweet for non-root bookmarks.
  • --thread-meta: add thread metadata fields to each tweet.
  • --sort-chronological: sort output globally oldest to newest (default preserves bookmark order).

Global options:

  • --auth-token <token>: set the auth_token cookie manually.
  • --ct0 <token>: set the ct0 cookie manually.
  • --cookie-source <safari|chrome|firefox>: choose browser cookie source (repeatable; order matters).
  • --chrome-profile <name>: Chrome profile name for cookie extraction (e.g., Default, Profile 2).
  • --chrome-profile-dir <path>: Chrome/Chromium profile directory or cookie DB path for cookie extraction.
  • --firefox-profile <name>: Firefox profile for cookie extraction.
  • --cookie-timeout <ms>: cookie extraction timeout for keychain/OS helpers (milliseconds).
  • --timeout <ms>: abort requests after the given timeout (milliseconds).
  • --quote-depth <n>: max quoted tweet depth in JSON output (default: 1; 0 disables).
  • --plain: stable output (no emoji, no color).
  • --no-emoji: disable emoji output.
  • --no-color: disable ANSI colors (or set NO_COLOR=1).
  • --media <path>: attach media file (repeatable, up to 4 images or 1 video).
  • --alt <text>: alt text for the corresponding --media (repeatable).

Authentication (GraphQL)

GraphQL mode uses your existing X/Twitter web session (no password prompt). It sends requests to internal X endpoints and authenticates via cookies (auth_token, ct0).

Write operations:

  • tweet/reply primarily use GraphQL (CreateTweet).
  • If GraphQL returns error 226 (“automated request”), bird falls back to the legacy statuses/update.json endpoint.

bird resolves credentials in this order:

  1. CLI flags: --auth-token, --ct0
  2. Environment variables: AUTH_TOKEN, CT0 (fallback: TWITTER_AUTH_TOKEN, TWITTER_CT0)
  3. Browser cookies via @steipete/sweet-cookie (override via --cookie-source order)

Browser cookie sources:

  • Safari: ~/Library/Cookies/Cookies.binarycookies (fallback: ~/Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies)
  • Chrome: ~/Library/Application Support/Google/Chrome/<Profile>/Cookies
  • Firefox: ~/Library/Application Support/Firefox/Profiles/<profile>/cookies.sqlite
    • For Chromium variants (Arc/Brave/etc), pass a profile directory or cookie DB via --chrome-profile-dir.

Config (JSON5)

Config precedence: CLI flags > env vars > project config > global config.

  • Global: ~/.config/bird/config.json5
  • Project: ./.birdrc.json5

Example ~/.config/bird/config.json5:

{// Cookie source order for browser extraction (string or array)cookieSource: ["firefox","safari"],chromeProfileDir: "/path/to/Chromium/Profile",firefoxProfile: "default-release",cookieTimeoutMs: 30000,timeoutMs: 20000,quoteDepth: 1}

Environment shortcuts:

  • BIRD_TIMEOUT_MS
  • BIRD_COOKIE_TIMEOUT_MS
  • BIRD_QUOTE_DEPTH

Output

  • --json prints raw tweet objects for read/replies/thread/search/mentions/user-tweets/bookmarks/likes.
  • When using --json with pagination (--all, --cursor, --max-pages, or for user-tweets when -n > 20), output is { tweets, nextCursor }.
  • read returns full text for Notes and Articles when present.
  • Use --plain for stable, script-friendly output (no emoji, no color).

JSON Schema

When using --json, tweet objects include:

FieldTypeDescription
idstringTweet ID
textstringFull tweet text (includes Note/Article content when present)
authorobject{ username, name }
authorIdstring?Author's user ID
createdAtstringTimestamp
replyCountnumberNumber of replies
retweetCountnumberNumber of retweets
likeCountnumberNumber of likes
conversationIdstringThread conversation ID
inReplyToStatusIdstring?Parent tweet ID (present if this is a reply)
quotedTweetobject?Embedded quote tweet (same schema; depth controlled by --quote-depth)

When using --json with following/followers, user objects include:

FieldTypeDescription
idstringUser ID
usernamestringUsername/handle
namestringDisplay name
descriptionstring?User bio
followersCountnumber?Followers count
followingCountnumber?Following count
isBlueVerifiedboolean?Blue verified flag
profileImageUrlstring?Profile image URL
createdAtstring?Account creation timestamp

When using --json with news/trending, news objects include:

FieldTypeDescription
idstringUnique identifier for the news item
headlinestringNews headline or trend title
categorystring?Category (e.g., "AI · Technology", "Trending", "News")
timeAgostring?Relative time (e.g., "2h ago")
postCountnumber?Number of posts
descriptionstring?Item description
urlstring?URL to the trend or news article
tweetsarray?Related tweets (only when --with-tweets is used)
_rawobject?Raw API response (only when --json-full is used)

Query IDs (GraphQL)

X rotates GraphQL “query IDs” frequently. Each GraphQL operation is addressed as:

  • operationName (e.g. TweetDetail, CreateTweet)
  • queryId (rotating ID baked into X’s web client bundles)

bird ships with a baseline mapping in src/lib/query-ids.json (copied into dist/ on build). At runtime, it can refresh that mapping by scraping X’s public web client bundles and caching the result on disk.

Runtime cache:

  • Default path: ~/.config/bird/query-ids-cache.json
  • Override path: BIRD_QUERY_IDS_CACHE=/path/to/file.json
  • TTL: 24h (stale cache is still used, but marked “not fresh”)

Auto-recovery:

  • On GraphQL 404 (query ID invalid), bird forces a refresh once and retries.
  • For TweetDetail/SearchTimeline, bird also rotates through a small set of known fallback IDs to reduce breakage while refreshing.

Refresh on demand:

bird query-ids --fresh

Exit codes:

  • 0: success
  • 1: runtime error (network/auth/etc)
  • 2: invalid usage/validation (e.g. bad --user handle)

Version

bird --version prints package.json version plus current git sha when available, e.g. 0.3.0 (3df7969b).

Media uploads

  • Attach media with --media (repeatable) and optional --alt per item.
  • Up to 4 images/GIFs, or 1 video (no mixing). Supported: jpg, jpeg, png, webp, gif, mp4, mov.
  • Images/GIFs + 1 video supported (uploads via Twitter legacy upload endpoint + cookies; video may take longer to process).

Example:

bird tweet "hi" --media img.png --alt "desc"

Development

cd~/Projects/bird
pnpm install
pnpm run build # dist/ + bun binary
pnpm run build:dist # dist/ only
pnpm run build:binary
pnpm run dev tweet "Test"
pnpm run dev -- --plain check
pnpm test
pnpm run lint

Notes

  • GraphQL uses internal X endpoints and can be rate limited (429).
  • Query IDs rotate; refresh at runtime with bird query-ids --fresh (or update the baked baseline via pnpm run graphql:update).

About

CLI tool for X/Twitter - rescued from @steipete/bird v0.8.0

Resources

Stars

21 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

bird 🐦 — fast X CLI for tweeting, replying, and reading

bird is a fast X CLI for tweeting, replying, and reading via X/Twitter GraphQL (cookie auth).

Disclaimer

This project uses X/Twitter’s undocumented web GraphQL API (and cookie auth). X can change endpoints, query IDs, and anti-bot behavior at any time — expect this to break without notice.

Install

npm install -g @steipete/bird
# or
pnpm add -g @steipete/bird
# or
bun add -g @steipete/bird
# one-shot (no install)
bunx @steipete/bird whoami

Homebrew (macOS, prebuilt Bun binary):

brew install steipete/tap/bird

Quickstart

# Show the logged-in account
bird whoami
# Discover command help
bird help whoami
# Read a tweet (URL or ID)
bird read https://x.com/user/status/1234567890123456789
bird 1234567890123456789 --json
# Thread + replies
bird thread https://x.com/user/status/1234567890123456789
bird replies 1234567890123456789
bird replies 1234567890123456789 --max-pages 3 --json
bird thread 1234567890123456789 --max-pages 3 --json
# Search + mentions
bird search "from:steipete" -n 5
bird mentions -n 5
bird mentions --user @steipete -n 5
# User tweets (profile timeline)
bird user-tweets @steipete -n 20
bird user-tweets @steipete -n 50 --json
# Bookmarks
bird bookmarks -n 5
bird bookmarks --folder-id 123456789123456789 -n 5 # https://x.com/i/bookmarks/<folder-id>
bird bookmarks --all --json
bird bookmarks --all --max-pages 2 --json
bird bookmarks --include-parent --json
bird unbookmark 1234567890123456789
bird unbookmark https://x.com/user/status/1234567890123456789
# Likes
bird likes -n 5
# News and trending topics (AI-curated from Explore tabs)
bird news --ai-only -n 10
bird news --sports -n 5
# Lists
bird list-timeline 1234567890 -n 20
bird list-timeline https://x.com/i/lists/1234567890 --all --json
bird list-timeline 1234567890 --max-pages 3 --json
# Following (who you follow)
bird following -n 20
bird following --user 12345678 -n 10 # by user ID# Followers (who follows you)
bird followers -n 20
bird followers --user 12345678 -n 10 # by user ID# Refresh GraphQL query IDs cache (no rebuild)
bird query-ids --fresh

News & Trending

Fetch AI-curated news and trending topics from X's Explore page tabs:

# Fetch 10 news items from all tabs (default: For You, News, Sports, Entertainment)
bird news -n 10
# Fetch only AI-curated news (filters out regular trends)
bird news --ai-only -n 20
# Fetch from specific tabs
bird news --news-only --ai-only -n 10
bird news --sports -n 15
bird news --entertainment --ai-only -n 5
# Include related tweets for each news item
bird news --with-tweets --tweets-per-item 3 -n 10
# Combine multiple tab filters
bird news --sports --entertainment -n 20
# JSON output
bird news --json -n 5
bird news --json-full --ai-only -n 10 # includes raw API response

Tab options (can be combined):

  • --for-you — Fetch from For You tab only
  • --news-only — Fetch from News tab only
  • --sports — Fetch from Sports tab only
  • --entertainment — Fetch from Entertainment tab only
  • --trending-only — Fetch from Trending tab only

By default, the command fetches from For You, News, Sports, and Entertainment tabs (Trending excluded to reduce noise). Headlines are automatically deduplicated across tabs.

Library

bird can be used as a library (same GraphQL client as the CLI):

import{TwitterClient,resolveCredentials}from'@steipete/bird';const{ cookies }=awaitresolveCredentials({cookieSource: 'safari'});constclient=newTwitterClient({ cookies });// Search for tweetsconstsearchResult=awaitclient.search('from:steipete',50);// Fetch news and trending topics from all tabs (default: For You, News, Sports, Entertainment)constnewsResult=awaitclient.getNews(10,{aiOnly: true});// Fetch from specific tabs with related tweetsconstsportsNews=awaitclient.getNews(10,{aiOnly: true,withTweets: true,tabs: ['sports','entertainment']});

Account details (About profile):

constaboutResult=awaitclient.getUserAboutAccount('steipete');if(aboutResult.success&&aboutResult.aboutProfile){console.log(aboutResult.aboutProfile.accountBasedIn);}

Fields:

  • accountBasedIn
  • source
  • createdCountryAccurate
  • locationAccurate
  • learnMoreUrl

Commands

  • bird tweet "<text>" — post a new tweet.
  • bird reply <tweet-id-or-url> "<text>" — reply to a tweet using its ID or URL.
  • bird help [command] — show help (or help for a subcommand).
  • bird query-ids [--fresh] [--json] — inspect or refresh cached GraphQL query IDs.
  • bird home [-n count] [--following] [--json] [--json-full] — fetch your home timeline (For You) or Following feed.
  • bird read <tweet-id-or-url> [--json] — fetch tweet content as text or JSON.
  • bird <tweet-id-or-url> [--json] — shorthand for read when only a URL or ID is provided.
  • bird replies <tweet-id-or-url> [--all] [--max-pages n] [--cursor string] [--delay ms] [--json] — list replies to a tweet.
  • bird thread <tweet-id-or-url> [--all] [--max-pages n] [--cursor string] [--delay ms] [--json] — show the full conversation thread.
  • bird search "<query>" [-n count] [--all] [--max-pages n] [--cursor string] [--json] — search for tweets matching a query; --max-pages requires --all or --cursor.
  • bird mentions [-n count] [--user @handle] [--json] — find tweets mentioning a user (defaults to the authenticated user).
  • bird user-tweets <@handle> [-n count] [--cursor string] [--max-pages n] [--delay ms] [--json] — get tweets from a user's profile timeline.
  • bird bookmarks [-n count] [--folder-id id] [--all] [--max-pages n] [--cursor string] [--expand-root-only] [--author-chain] [--author-only] [--full-chain-only] [--include-ancestor-branches] [--include-parent] [--thread-meta] [--sort-chronological] [--json] — list your bookmarked tweets (or a specific bookmark folder); expansion flags control thread context; --max-pages requires --all or --cursor.
  • bird unbookmark <tweet-id-or-url...> — remove one or more bookmarks by tweet ID or URL.
  • bird likes [-n count] [--all] [--max-pages n] [--cursor string] [--json] [--json-full] — list your liked tweets; --max-pages requires --all or --cursor.
  • bird news [-n count] [--ai-only] [--with-tweets] [--tweets-per-item n] [--for-you] [--news-only] [--sports] [--entertainment] [--trending-only] [--json] — fetch news and trending topics from X's Explore tabs.
  • bird trending — alias for news command.
  • bird lists [--member-of] [-n count] [--json] — list your lists (owned or memberships).
  • bird list-timeline <list-id-or-url> [-n count] [--all] [--max-pages n] [--cursor string] [--json] — get tweets from a list timeline; --max-pages implies --all.
  • bird following [--user <userId>] [-n count] [--cursor string] [--all] [--max-pages n] [--json] — list users that you (or another user) follow; --max-pages requires --all.
  • bird followers [--user <userId>] [-n count] [--cursor string] [--all] [--max-pages n] [--json] — list users that follow you (or another user); --max-pages requires --all.
  • bird about <@handle> [--json] — get account origin and location information for a user.
  • bird whoami — print which Twitter account your cookies belong to.
  • bird check — show which credentials are available and where they were sourced from.

Bookmarks flags:

  • --expand-root-only: expand threads only when the bookmark is a root tweet.
  • --author-chain: keep only the bookmarked author's connected self-reply chain.
  • --author-only: include all tweets from the bookmarked author within the thread.
  • --full-chain-only: keep the entire reply chain connected to the bookmarked tweet (all authors).
  • --include-ancestor-branches: include sibling branches for ancestors when using --full-chain-only.
  • --include-parent: include the direct parent tweet for non-root bookmarks.
  • --thread-meta: add thread metadata fields to each tweet.
  • --sort-chronological: sort output globally oldest to newest (default preserves bookmark order).

Global options:

  • --auth-token <token>: set the auth_token cookie manually.
  • --ct0 <token>: set the ct0 cookie manually.
  • --cookie-source <safari|chrome|firefox>: choose browser cookie source (repeatable; order matters).
  • --chrome-profile <name>: Chrome profile name for cookie extraction (e.g., Default, Profile 2).
  • --chrome-profile-dir <path>: Chrome/Chromium profile directory or cookie DB path for cookie extraction.
  • --firefox-profile <name>: Firefox profile for cookie extraction.
  • --cookie-timeout <ms>: cookie extraction timeout for keychain/OS helpers (milliseconds).
  • --timeout <ms>: abort requests after the given timeout (milliseconds).
  • --quote-depth <n>: max quoted tweet depth in JSON output (default: 1; 0 disables).
  • --plain: stable output (no emoji, no color).
  • --no-emoji: disable emoji output.
  • --no-color: disable ANSI colors (or set NO_COLOR=1).
  • --media <path>: attach media file (repeatable, up to 4 images or 1 video).
  • --alt <text>: alt text for the corresponding --media (repeatable).

Authentication (GraphQL)

GraphQL mode uses your existing X/Twitter web session (no password prompt). It sends requests to internal X endpoints and authenticates via cookies (auth_token, ct0).

Write operations:

  • tweet/reply primarily use GraphQL (CreateTweet).
  • If GraphQL returns error 226 (“automated request”), bird falls back to the legacy statuses/update.json endpoint.

bird resolves credentials in this order:

  1. CLI flags: --auth-token, --ct0
  2. Environment variables: AUTH_TOKEN, CT0 (fallback: TWITTER_AUTH_TOKEN, TWITTER_CT0)
  3. Browser cookies via @steipete/sweet-cookie (override via --cookie-source order)

Browser cookie sources:

  • Safari: ~/Library/Cookies/Cookies.binarycookies (fallback: ~/Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies)
  • Chrome: ~/Library/Application Support/Google/Chrome/<Profile>/Cookies
  • Firefox: ~/Library/Application Support/Firefox/Profiles/<profile>/cookies.sqlite
    • For Chromium variants (Arc/Brave/etc), pass a profile directory or cookie DB via --chrome-profile-dir.

Config (JSON5)

Config precedence: CLI flags > env vars > project config > global config.

  • Global: ~/.config/bird/config.json5
  • Project: ./.birdrc.json5

Example ~/.config/bird/config.json5:

{// Cookie source order for browser extraction (string or array)cookieSource: ["firefox","safari"],chromeProfileDir: "/path/to/Chromium/Profile",firefoxProfile: "default-release",cookieTimeoutMs: 30000,timeoutMs: 20000,quoteDepth: 1}

Environment shortcuts:

  • BIRD_TIMEOUT_MS
  • BIRD_COOKIE_TIMEOUT_MS
  • BIRD_QUOTE_DEPTH

Output

  • --json prints raw tweet objects for read/replies/thread/search/mentions/user-tweets/bookmarks/likes.
  • When using --json with pagination (--all, --cursor, --max-pages, or for user-tweets when -n > 20), output is { tweets, nextCursor }.
  • read returns full text for Notes and Articles when present.
  • Use --plain for stable, script-friendly output (no emoji, no color).

JSON Schema

When using --json, tweet objects include:

FieldTypeDescription
idstringTweet ID
textstringFull tweet text (includes Note/Article content when present)
authorobject{ username, name }
authorIdstring?Author's user ID
createdAtstringTimestamp
replyCountnumberNumber of replies
retweetCountnumberNumber of retweets
likeCountnumberNumber of likes
conversationIdstringThread conversation ID
inReplyToStatusIdstring?Parent tweet ID (present if this is a reply)
quotedTweetobject?Embedded quote tweet (same schema; depth controlled by --quote-depth)

When using --json with following/followers, user objects include:

FieldTypeDescription
idstringUser ID
usernamestringUsername/handle
namestringDisplay name
descriptionstring?User bio
followersCountnumber?Followers count
followingCountnumber?Following count
isBlueVerifiedboolean?Blue verified flag
profileImageUrlstring?Profile image URL
createdAtstring?Account creation timestamp

When using --json with news/trending, news objects include:

FieldTypeDescription
idstringUnique identifier for the news item
headlinestringNews headline or trend title
categorystring?Category (e.g., "AI · Technology", "Trending", "News")
timeAgostring?Relative time (e.g., "2h ago")
postCountnumber?Number of posts
descriptionstring?Item description
urlstring?URL to the trend or news article
tweetsarray?Related tweets (only when --with-tweets is used)
_rawobject?Raw API response (only when --json-full is used)

Query IDs (GraphQL)

X rotates GraphQL “query IDs” frequently. Each GraphQL operation is addressed as:

  • operationName (e.g. TweetDetail, CreateTweet)
  • queryId (rotating ID baked into X’s web client bundles)

bird ships with a baseline mapping in src/lib/query-ids.json (copied into dist/ on build). At runtime, it can refresh that mapping by scraping X’s public web client bundles and caching the result on disk.

Runtime cache:

  • Default path: ~/.config/bird/query-ids-cache.json
  • Override path: BIRD_QUERY_IDS_CACHE=/path/to/file.json
  • TTL: 24h (stale cache is still used, but marked “not fresh”)

Auto-recovery:

  • On GraphQL 404 (query ID invalid), bird forces a refresh once and retries.
  • For TweetDetail/SearchTimeline, bird also rotates through a small set of known fallback IDs to reduce breakage while refreshing.

Refresh on demand:

bird query-ids --fresh

Exit codes:

  • 0: success
  • 1: runtime error (network/auth/etc)
  • 2: invalid usage/validation (e.g. bad --user handle)

Version

bird --version prints package.json version plus current git sha when available, e.g. 0.3.0 (3df7969b).

Media uploads

  • Attach media with --media (repeatable) and optional --alt per item.
  • Up to 4 images/GIFs, or 1 video (no mixing). Supported: jpg, jpeg, png, webp, gif, mp4, mov.
  • Images/GIFs + 1 video supported (uploads via Twitter legacy upload endpoint + cookies; video may take longer to process).

Example:

bird tweet "hi" --media img.png --alt "desc"

Development

cd~/Projects/bird
pnpm install
pnpm run build # dist/ + bun binary
pnpm run build:dist # dist/ only
pnpm run build:binary
pnpm run dev tweet "Test"
pnpm run dev -- --plain check
pnpm test
pnpm run lint

Notes

  • GraphQL uses internal X endpoints and can be rate limited (429).
  • Query IDs rotate; refresh at runtime with bird query-ids --fresh (or update the baked baseline via pnpm run graphql:update).

About

CLI tool for X/Twitter - rescued from @steipete/bird v0.8.0

Resources

Stars

21 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

bird 🐦 — fast X CLI for tweeting, replying, and reading

bird is a fast X CLI for tweeting, replying, and reading via X/Twitter GraphQL (cookie auth).

Disclaimer

This project uses X/Twitter’s undocumented web GraphQL API (and cookie auth). X can change endpoints, query IDs, and anti-bot behavior at any time — expect this to break without notice.

Install

npm install -g @steipete/bird
# or
pnpm add -g @steipete/bird
# or
bun add -g @steipete/bird
# one-shot (no install)
bunx @steipete/bird whoami

Homebrew (macOS, prebuilt Bun binary):

brew install steipete/tap/bird

Quickstart

# Show the logged-in account
bird whoami
# Discover command help
bird help whoami
# Read a tweet (URL or ID)
bird read https://x.com/user/status/1234567890123456789
bird 1234567890123456789 --json
# Thread + replies
bird thread https://x.com/user/status/1234567890123456789
bird replies 1234567890123456789
bird replies 1234567890123456789 --max-pages 3 --json
bird thread 1234567890123456789 --max-pages 3 --json
# Search + mentions
bird search "from:steipete" -n 5
bird mentions -n 5
bird mentions --user @steipete -n 5
# User tweets (profile timeline)
bird user-tweets @steipete -n 20
bird user-tweets @steipete -n 50 --json
# Bookmarks
bird bookmarks -n 5
bird bookmarks --folder-id 123456789123456789 -n 5 # https://x.com/i/bookmarks/<folder-id>
bird bookmarks --all --json
bird bookmarks --all --max-pages 2 --json
bird bookmarks --include-parent --json
bird unbookmark 1234567890123456789
bird unbookmark https://x.com/user/status/1234567890123456789
# Likes
bird likes -n 5
# News and trending topics (AI-curated from Explore tabs)
bird news --ai-only -n 10
bird news --sports -n 5
# Lists
bird list-timeline 1234567890 -n 20
bird list-timeline https://x.com/i/lists/1234567890 --all --json
bird list-timeline 1234567890 --max-pages 3 --json
# Following (who you follow)
bird following -n 20
bird following --user 12345678 -n 10 # by user ID# Followers (who follows you)
bird followers -n 20
bird followers --user 12345678 -n 10 # by user ID# Refresh GraphQL query IDs cache (no rebuild)
bird query-ids --fresh

News & Trending

Fetch AI-curated news and trending topics from X's Explore page tabs:

# Fetch 10 news items from all tabs (default: For You, News, Sports, Entertainment)
bird news -n 10
# Fetch only AI-curated news (filters out regular trends)
bird news --ai-only -n 20
# Fetch from specific tabs
bird news --news-only --ai-only -n 10
bird news --sports -n 15
bird news --entertainment --ai-only -n 5
# Include related tweets for each news item
bird news --with-tweets --tweets-per-item 3 -n 10
# Combine multiple tab filters
bird news --sports --entertainment -n 20
# JSON output
bird news --json -n 5
bird news --json-full --ai-only -n 10 # includes raw API response

Tab options (can be combined):

  • --for-you — Fetch from For You tab only
  • --news-only — Fetch from News tab only
  • --sports — Fetch from Sports tab only
  • --entertainment — Fetch from Entertainment tab only
  • --trending-only — Fetch from Trending tab only

By default, the command fetches from For You, News, Sports, and Entertainment tabs (Trending excluded to reduce noise). Headlines are automatically deduplicated across tabs.

Library

bird can be used as a library (same GraphQL client as the CLI):

import{TwitterClient,resolveCredentials}from'@steipete/bird';const{ cookies }=awaitresolveCredentials({cookieSource: 'safari'});constclient=newTwitterClient({ cookies });// Search for tweetsconstsearchResult=awaitclient.search('from:steipete',50);// Fetch news and trending topics from all tabs (default: For You, News, Sports, Entertainment)constnewsResult=awaitclient.getNews(10,{aiOnly: true});// Fetch from specific tabs with related tweetsconstsportsNews=awaitclient.getNews(10,{aiOnly: true,withTweets: true,tabs: ['sports','entertainment']});

Account details (About profile):

constaboutResult=awaitclient.getUserAboutAccount('steipete');if(aboutResult.success&&aboutResult.aboutProfile){console.log(aboutResult.aboutProfile.accountBasedIn);}

Fields:

  • accountBasedIn
  • source
  • createdCountryAccurate
  • locationAccurate
  • learnMoreUrl

Commands

  • bird tweet "<text>" — post a new tweet.
  • bird reply <tweet-id-or-url> "<text>" — reply to a tweet using its ID or URL.
  • bird help [command] — show help (or help for a subcommand).
  • bird query-ids [--fresh] [--json] — inspect or refresh cached GraphQL query IDs.
  • bird home [-n count] [--following] [--json] [--json-full] — fetch your home timeline (For You) or Following feed.
  • bird read <tweet-id-or-url> [--json] — fetch tweet content as text or JSON.
  • bird <tweet-id-or-url> [--json] — shorthand for read when only a URL or ID is provided.
  • bird replies <tweet-id-or-url> [--all] [--max-pages n] [--cursor string] [--delay ms] [--json] — list replies to a tweet.
  • bird thread <tweet-id-or-url> [--all] [--max-pages n] [--cursor string] [--delay ms] [--json] — show the full conversation thread.
  • bird search "<query>" [-n count] [--all] [--max-pages n] [--cursor string] [--json] — search for tweets matching a query; --max-pages requires --all or --cursor.
  • bird mentions [-n count] [--user @handle] [--json] — find tweets mentioning a user (defaults to the authenticated user).
  • bird user-tweets <@handle> [-n count] [--cursor string] [--max-pages n] [--delay ms] [--json] — get tweets from a user's profile timeline.
  • bird bookmarks [-n count] [--folder-id id] [--all] [--max-pages n] [--cursor string] [--expand-root-only] [--author-chain] [--author-only] [--full-chain-only] [--include-ancestor-branches] [--include-parent] [--thread-meta] [--sort-chronological] [--json] — list your bookmarked tweets (or a specific bookmark folder); expansion flags control thread context; --max-pages requires --all or --cursor.
  • bird unbookmark <tweet-id-or-url...> — remove one or more bookmarks by tweet ID or URL.
  • bird likes [-n count] [--all] [--max-pages n] [--cursor string] [--json] [--json-full] — list your liked tweets; --max-pages requires --all or --cursor.
  • bird news [-n count] [--ai-only] [--with-tweets] [--tweets-per-item n] [--for-you] [--news-only] [--sports] [--entertainment] [--trending-only] [--json] — fetch news and trending topics from X's Explore tabs.
  • bird trending — alias for news command.
  • bird lists [--member-of] [-n count] [--json] — list your lists (owned or memberships).
  • bird list-timeline <list-id-or-url> [-n count] [--all] [--max-pages n] [--cursor string] [--json] — get tweets from a list timeline; --max-pages implies --all.
  • bird following [--user <userId>] [-n count] [--cursor string] [--all] [--max-pages n] [--json] — list users that you (or another user) follow; --max-pages requires --all.
  • bird followers [--user <userId>] [-n count] [--cursor string] [--all] [--max-pages n] [--json] — list users that follow you (or another user); --max-pages requires --all.
  • bird about <@handle> [--json] — get account origin and location information for a user.
  • bird whoami — print which Twitter account your cookies belong to.
  • bird check — show which credentials are available and where they were sourced from.

Bookmarks flags:

  • --expand-root-only: expand threads only when the bookmark is a root tweet.
  • --author-chain: keep only the bookmarked author's connected self-reply chain.
  • --author-only: include all tweets from the bookmarked author within the thread.
  • --full-chain-only: keep the entire reply chain connected to the bookmarked tweet (all authors).
  • --include-ancestor-branches: include sibling branches for ancestors when using --full-chain-only.
  • --include-parent: include the direct parent tweet for non-root bookmarks.
  • --thread-meta: add thread metadata fields to each tweet.
  • --sort-chronological: sort output globally oldest to newest (default preserves bookmark order).

Global options:

  • --auth-token <token>: set the auth_token cookie manually.
  • --ct0 <token>: set the ct0 cookie manually.
  • --cookie-source <safari|chrome|firefox>: choose browser cookie source (repeatable; order matters).
  • --chrome-profile <name>: Chrome profile name for cookie extraction (e.g., Default, Profile 2).
  • --chrome-profile-dir <path>: Chrome/Chromium profile directory or cookie DB path for cookie extraction.
  • --firefox-profile <name>: Firefox profile for cookie extraction.
  • --cookie-timeout <ms>: cookie extraction timeout for keychain/OS helpers (milliseconds).
  • --timeout <ms>: abort requests after the given timeout (milliseconds).
  • --quote-depth <n>: max quoted tweet depth in JSON output (default: 1; 0 disables).
  • --plain: stable output (no emoji, no color).
  • --no-emoji: disable emoji output.
  • --no-color: disable ANSI colors (or set NO_COLOR=1).
  • --media <path>: attach media file (repeatable, up to 4 images or 1 video).
  • --alt <text>: alt text for the corresponding --media (repeatable).

Authentication (GraphQL)

GraphQL mode uses your existing X/Twitter web session (no password prompt). It sends requests to internal X endpoints and authenticates via cookies (auth_token, ct0).

Write operations:

  • tweet/reply primarily use GraphQL (CreateTweet).
  • If GraphQL returns error 226 (“automated request”), bird falls back to the legacy statuses/update.json endpoint.

bird resolves credentials in this order:

  1. CLI flags: --auth-token, --ct0
  2. Environment variables: AUTH_TOKEN, CT0 (fallback: TWITTER_AUTH_TOKEN, TWITTER_CT0)
  3. Browser cookies via @steipete/sweet-cookie (override via --cookie-source order)

Browser cookie sources:

  • Safari: ~/Library/Cookies/Cookies.binarycookies (fallback: ~/Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies)
  • Chrome: ~/Library/Application Support/Google/Chrome/<Profile>/Cookies
  • Firefox: ~/Library/Application Support/Firefox/Profiles/<profile>/cookies.sqlite
    • For Chromium variants (Arc/Brave/etc), pass a profile directory or cookie DB via --chrome-profile-dir.

Config (JSON5)

Config precedence: CLI flags > env vars > project config > global config.

  • Global: ~/.config/bird/config.json5
  • Project: ./.birdrc.json5

Example ~/.config/bird/config.json5:

{// Cookie source order for browser extraction (string or array)cookieSource: ["firefox","safari"],chromeProfileDir: "/path/to/Chromium/Profile",firefoxProfile: "default-release",cookieTimeoutMs: 30000,timeoutMs: 20000,quoteDepth: 1}

Environment shortcuts:

  • BIRD_TIMEOUT_MS
  • BIRD_COOKIE_TIMEOUT_MS
  • BIRD_QUOTE_DEPTH

Output

  • --json prints raw tweet objects for read/replies/thread/search/mentions/user-tweets/bookmarks/likes.
  • When using --json with pagination (--all, --cursor, --max-pages, or for user-tweets when -n > 20), output is { tweets, nextCursor }.
  • read returns full text for Notes and Articles when present.
  • Use --plain for stable, script-friendly output (no emoji, no color).

JSON Schema

When using --json, tweet objects include:

FieldTypeDescription
idstringTweet ID
textstringFull tweet text (includes Note/Article content when present)
authorobject{ username, name }
authorIdstring?Author's user ID
createdAtstringTimestamp
replyCountnumberNumber of replies
retweetCountnumberNumber of retweets
likeCountnumberNumber of likes
conversationIdstringThread conversation ID
inReplyToStatusIdstring?Parent tweet ID (present if this is a reply)
quotedTweetobject?Embedded quote tweet (same schema; depth controlled by --quote-depth)

When using --json with following/followers, user objects include:

FieldTypeDescription
idstringUser ID
usernamestringUsername/handle
namestringDisplay name
descriptionstring?User bio
followersCountnumber?Followers count
followingCountnumber?Following count
isBlueVerifiedboolean?Blue verified flag
profileImageUrlstring?Profile image URL
createdAtstring?Account creation timestamp

When using --json with news/trending, news objects include:

FieldTypeDescription
idstringUnique identifier for the news item
headlinestringNews headline or trend title
categorystring?Category (e.g., "AI · Technology", "Trending", "News")
timeAgostring?Relative time (e.g., "2h ago")
postCountnumber?Number of posts
descriptionstring?Item description
urlstring?URL to the trend or news article
tweetsarray?Related tweets (only when --with-tweets is used)
_rawobject?Raw API response (only when --json-full is used)

Query IDs (GraphQL)

X rotates GraphQL “query IDs” frequently. Each GraphQL operation is addressed as:

  • operationName (e.g. TweetDetail, CreateTweet)
  • queryId (rotating ID baked into X’s web client bundles)

bird ships with a baseline mapping in src/lib/query-ids.json (copied into dist/ on build). At runtime, it can refresh that mapping by scraping X’s public web client bundles and caching the result on disk.

Runtime cache:

  • Default path: ~/.config/bird/query-ids-cache.json
  • Override path: BIRD_QUERY_IDS_CACHE=/path/to/file.json
  • TTL: 24h (stale cache is still used, but marked “not fresh”)

Auto-recovery:

  • On GraphQL 404 (query ID invalid), bird forces a refresh once and retries.
  • For TweetDetail/SearchTimeline, bird also rotates through a small set of known fallback IDs to reduce breakage while refreshing.

Refresh on demand:

bird query-ids --fresh

Exit codes:

  • 0: success
  • 1: runtime error (network/auth/etc)
  • 2: invalid usage/validation (e.g. bad --user handle)

Version

bird --version prints package.json version plus current git sha when available, e.g. 0.3.0 (3df7969b).

Media uploads

  • Attach media with --media (repeatable) and optional --alt per item.
  • Up to 4 images/GIFs, or 1 video (no mixing). Supported: jpg, jpeg, png, webp, gif, mp4, mov.
  • Images/GIFs + 1 video supported (uploads via Twitter legacy upload endpoint + cookies; video may take longer to process).

Example:

bird tweet "hi" --media img.png --alt "desc"

Development

cd~/Projects/bird
pnpm install
pnpm run build # dist/ + bun binary
pnpm run build:dist # dist/ only
pnpm run build:binary
pnpm run dev tweet "Test"
pnpm run dev -- --plain check
pnpm test
pnpm run lint

Notes

  • GraphQL uses internal X endpoints and can be rate limited (429).
  • Query IDs rotate; refresh at runtime with bird query-ids --fresh (or update the baked baseline via pnpm run graphql:update).

About

CLI tool for X/Twitter - rescued from @steipete/bird v0.8.0

Resources

Stars

21 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Latest commit

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

bird 🐦 — fast X CLI for tweeting, replying, and reading

bird is a fast X CLI for tweeting, replying, and reading via X/Twitter GraphQL (cookie auth).

Disclaimer

This project uses X/Twitter’s undocumented web GraphQL API (and cookie auth). X can change endpoints, query IDs, and anti-bot behavior at any time — expect this to break without notice.

Install

npm install -g @steipete/bird
# or
pnpm add -g @steipete/bird
# or
bun add -g @steipete/bird
# one-shot (no install)
bunx @steipete/bird whoami

Homebrew (macOS, prebuilt Bun binary):

brew install steipete/tap/bird

Quickstart

# Show the logged-in account
bird whoami
# Discover command help
bird help whoami
# Read a tweet (URL or ID)
bird read https://x.com/user/status/1234567890123456789
bird 1234567890123456789 --json
# Thread + replies
bird thread https://x.com/user/status/1234567890123456789
bird replies 1234567890123456789
bird replies 1234567890123456789 --max-pages 3 --json
bird thread 1234567890123456789 --max-pages 3 --json
# Search + mentions
bird search "from:steipete" -n 5
bird mentions -n 5
bird mentions --user @steipete -n 5
# User tweets (profile timeline)
bird user-tweets @steipete -n 20
bird user-tweets @steipete -n 50 --json
# Bookmarks
bird bookmarks -n 5
bird bookmarks --folder-id 123456789123456789 -n 5 # https://x.com/i/bookmarks/<folder-id>
bird bookmarks --all --json
bird bookmarks --all --max-pages 2 --json
bird bookmarks --include-parent --json
bird unbookmark 1234567890123456789
bird unbookmark https://x.com/user/status/1234567890123456789
# Likes
bird likes -n 5
# News and trending topics (AI-curated from Explore tabs)
bird news --ai-only -n 10
bird news --sports -n 5
# Lists
bird list-timeline 1234567890 -n 20
bird list-timeline https://x.com/i/lists/1234567890 --all --json
bird list-timeline 1234567890 --max-pages 3 --json
# Following (who you follow)
bird following -n 20
bird following --user 12345678 -n 10 # by user ID# Followers (who follows you)
bird followers -n 20
bird followers --user 12345678 -n 10 # by user ID# Refresh GraphQL query IDs cache (no rebuild)
bird query-ids --fresh

News & Trending

Fetch AI-curated news and trending topics from X's Explore page tabs:

# Fetch 10 news items from all tabs (default: For You, News, Sports, Entertainment)
bird news -n 10
# Fetch only AI-curated news (filters out regular trends)
bird news --ai-only -n 20
# Fetch from specific tabs
bird news --news-only --ai-only -n 10
bird news --sports -n 15
bird news --entertainment --ai-only -n 5
# Include related tweets for each news item
bird news --with-tweets --tweets-per-item 3 -n 10
# Combine multiple tab filters
bird news --sports --entertainment -n 20
# JSON output
bird news --json -n 5
bird news --json-full --ai-only -n 10 # includes raw API response

Tab options (can be combined):

  • --for-you — Fetch from For You tab only
  • --news-only — Fetch from News tab only
  • --sports — Fetch from Sports tab only
  • --entertainment — Fetch from Entertainment tab only
  • --trending-only — Fetch from Trending tab only

By default, the command fetches from For You, News, Sports, and Entertainment tabs (Trending excluded to reduce noise). Headlines are automatically deduplicated across tabs.

Library

bird can be used as a library (same GraphQL client as the CLI):

import{TwitterClient,resolveCredentials}from'@steipete/bird';const{ cookies }=awaitresolveCredentials({cookieSource: 'safari'});constclient=newTwitterClient({ cookies });// Search for tweetsconstsearchResult=awaitclient.search('from:steipete',50);// Fetch news and trending topics from all tabs (default: For You, News, Sports, Entertainment)constnewsResult=awaitclient.getNews(10,{aiOnly: true});// Fetch from specific tabs with related tweetsconstsportsNews=awaitclient.getNews(10,{aiOnly: true,withTweets: true,tabs: ['sports','entertainment']});

Account details (About profile):

constaboutResult=awaitclient.getUserAboutAccount('steipete');if(aboutResult.success&&aboutResult.aboutProfile){console.log(aboutResult.aboutProfile.accountBasedIn);}

Fields:

  • accountBasedIn
  • source
  • createdCountryAccurate
  • locationAccurate
  • learnMoreUrl

Commands

  • bird tweet "<text>" — post a new tweet.
  • bird reply <tweet-id-or-url> "<text>" — reply to a tweet using its ID or URL.
  • bird help [command] — show help (or help for a subcommand).
  • bird query-ids [--fresh] [--json] — inspect or refresh cached GraphQL query IDs.
  • bird home [-n count] [--following] [--json] [--json-full] — fetch your home timeline (For You) or Following feed.
  • bird read <tweet-id-or-url> [--json] — fetch tweet content as text or JSON.
  • bird <tweet-id-or-url> [--json] — shorthand for read when only a URL or ID is provided.
  • bird replies <tweet-id-or-url> [--all] [--max-pages n] [--cursor string] [--delay ms] [--json] — list replies to a tweet.
  • bird thread <tweet-id-or-url> [--all] [--max-pages n] [--cursor string] [--delay ms] [--json] — show the full conversation thread.
  • bird search "<query>" [-n count] [--all] [--max-pages n] [--cursor string] [--json] — search for tweets matching a query; --max-pages requires --all or --cursor.
  • bird mentions [-n count] [--user @handle] [--json] — find tweets mentioning a user (defaults to the authenticated user).
  • bird user-tweets <@handle> [-n count] [--cursor string] [--max-pages n] [--delay ms] [--json] — get tweets from a user's profile timeline.
  • bird bookmarks [-n count] [--folder-id id] [--all] [--max-pages n] [--cursor string] [--expand-root-only] [--author-chain] [--author-only] [--full-chain-only] [--include-ancestor-branches] [--include-parent] [--thread-meta] [--sort-chronological] [--json] — list your bookmarked tweets (or a specific bookmark folder); expansion flags control thread context; --max-pages requires --all or --cursor.
  • bird unbookmark <tweet-id-or-url...> — remove one or more bookmarks by tweet ID or URL.
  • bird likes [-n count] [--all] [--max-pages n] [--cursor string] [--json] [--json-full] — list your liked tweets; --max-pages requires --all or --cursor.
  • bird news [-n count] [--ai-only] [--with-tweets] [--tweets-per-item n] [--for-you] [--news-only] [--sports] [--entertainment] [--trending-only] [--json] — fetch news and trending topics from X's Explore tabs.
  • bird trending — alias for news command.
  • bird lists [--member-of] [-n count] [--json] — list your lists (owned or memberships).
  • bird list-timeline <list-id-or-url> [-n count] [--all] [--max-pages n] [--cursor string] [--json] — get tweets from a list timeline; --max-pages implies --all.
  • bird following [--user <userId>] [-n count] [--cursor string] [--all] [--max-pages n] [--json] — list users that you (or another user) follow; --max-pages requires --all.
  • bird followers [--user <userId>] [-n count] [--cursor string] [--all] [--max-pages n] [--json] — list users that follow you (or another user); --max-pages requires --all.
  • bird about <@handle> [--json] — get account origin and location information for a user.
  • bird whoami — print which Twitter account your cookies belong to.
  • bird check — show which credentials are available and where they were sourced from.

Bookmarks flags:

  • --expand-root-only: expand threads only when the bookmark is a root tweet.
  • --author-chain: keep only the bookmarked author's connected self-reply chain.
  • --author-only: include all tweets from the bookmarked author within the thread.
  • --full-chain-only: keep the entire reply chain connected to the bookmarked tweet (all authors).
  • --include-ancestor-branches: include sibling branches for ancestors when using --full-chain-only.
  • --include-parent: include the direct parent tweet for non-root bookmarks.
  • --thread-meta: add thread metadata fields to each tweet.
  • --sort-chronological: sort output globally oldest to newest (default preserves bookmark order).

Global options:

  • --auth-token <token>: set the auth_token cookie manually.
  • --ct0 <token>: set the ct0 cookie manually.
  • --cookie-source <safari|chrome|firefox>: choose browser cookie source (repeatable; order matters).
  • --chrome-profile <name>: Chrome profile name for cookie extraction (e.g., Default, Profile 2).
  • --chrome-profile-dir <path>: Chrome/Chromium profile directory or cookie DB path for cookie extraction.
  • --firefox-profile <name>: Firefox profile for cookie extraction.
  • --cookie-timeout <ms>: cookie extraction timeout for keychain/OS helpers (milliseconds).
  • --timeout <ms>: abort requests after the given timeout (milliseconds).
  • --quote-depth <n>: max quoted tweet depth in JSON output (default: 1; 0 disables).
  • --plain: stable output (no emoji, no color).
  • --no-emoji: disable emoji output.
  • --no-color: disable ANSI colors (or set NO_COLOR=1).
  • --media <path>: attach media file (repeatable, up to 4 images or 1 video).
  • --alt <text>: alt text for the corresponding --media (repeatable).

Authentication (GraphQL)

GraphQL mode uses your existing X/Twitter web session (no password prompt). It sends requests to internal X endpoints and authenticates via cookies (auth_token, ct0).

Write operations:

  • tweet/reply primarily use GraphQL (CreateTweet).
  • If GraphQL returns error 226 (“automated request”), bird falls back to the legacy statuses/update.json endpoint.

bird resolves credentials in this order:

  1. CLI flags: --auth-token, --ct0
  2. Environment variables: AUTH_TOKEN, CT0 (fallback: TWITTER_AUTH_TOKEN, TWITTER_CT0)
  3. Browser cookies via @steipete/sweet-cookie (override via --cookie-source order)

Browser cookie sources:

  • Safari: ~/Library/Cookies/Cookies.binarycookies (fallback: ~/Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies)
  • Chrome: ~/Library/Application Support/Google/Chrome/<Profile>/Cookies
  • Firefox: ~/Library/Application Support/Firefox/Profiles/<profile>/cookies.sqlite
    • For Chromium variants (Arc/Brave/etc), pass a profile directory or cookie DB via --chrome-profile-dir.

Config (JSON5)

Config precedence: CLI flags > env vars > project config > global config.

  • Global: ~/.config/bird/config.json5
  • Project: ./.birdrc.json5

Example ~/.config/bird/config.json5:

{// Cookie source order for browser extraction (string or array)cookieSource: ["firefox","safari"],chromeProfileDir: "/path/to/Chromium/Profile",firefoxProfile: "default-release",cookieTimeoutMs: 30000,timeoutMs: 20000,quoteDepth: 1}

Environment shortcuts:

  • BIRD_TIMEOUT_MS
  • BIRD_COOKIE_TIMEOUT_MS
  • BIRD_QUOTE_DEPTH

Output

  • --json prints raw tweet objects for read/replies/thread/search/mentions/user-tweets/bookmarks/likes.
  • When using --json with pagination (--all, --cursor, --max-pages, or for user-tweets when -n > 20), output is { tweets, nextCursor }.
  • read returns full text for Notes and Articles when present.
  • Use --plain for stable, script-friendly output (no emoji, no color).

JSON Schema

When using --json, tweet objects include:

FieldTypeDescription
idstringTweet ID
textstringFull tweet text (includes Note/Article content when present)
authorobject{ username, name }
authorIdstring?Author's user ID
createdAtstringTimestamp
replyCountnumberNumber of replies
retweetCountnumberNumber of retweets
likeCountnumberNumber of likes
conversationIdstringThread conversation ID
inReplyToStatusIdstring?Parent tweet ID (present if this is a reply)
quotedTweetobject?Embedded quote tweet (same schema; depth controlled by --quote-depth)

When using --json with following/followers, user objects include:

FieldTypeDescription
idstringUser ID
usernamestringUsername/handle
namestringDisplay name
descriptionstring?User bio
followersCountnumber?Followers count
followingCountnumber?Following count
isBlueVerifiedboolean?Blue verified flag
profileImageUrlstring?Profile image URL
createdAtstring?Account creation timestamp

When using --json with news/trending, news objects include:

FieldTypeDescription
idstringUnique identifier for the news item
headlinestringNews headline or trend title
categorystring?Category (e.g., "AI · Technology", "Trending", "News")
timeAgostring?Relative time (e.g., "2h ago")
postCountnumber?Number of posts
descriptionstring?Item description
urlstring?URL to the trend or news article
tweetsarray?Related tweets (only when --with-tweets is used)
_rawobject?Raw API response (only when --json-full is used)

Query IDs (GraphQL)

X rotates GraphQL “query IDs” frequently. Each GraphQL operation is addressed as:

  • operationName (e.g. TweetDetail, CreateTweet)
  • queryId (rotating ID baked into X’s web client bundles)

bird ships with a baseline mapping in src/lib/query-ids.json (copied into dist/ on build). At runtime, it can refresh that mapping by scraping X’s public web client bundles and caching the result on disk.

Runtime cache:

  • Default path: ~/.config/bird/query-ids-cache.json
  • Override path: BIRD_QUERY_IDS_CACHE=/path/to/file.json
  • TTL: 24h (stale cache is still used, but marked “not fresh”)

Auto-recovery:

  • On GraphQL 404 (query ID invalid), bird forces a refresh once and retries.
  • For TweetDetail/SearchTimeline, bird also rotates through a small set of known fallback IDs to reduce breakage while refreshing.

Refresh on demand:

bird query-ids --fresh

Exit codes:

  • 0: success
  • 1: runtime error (network/auth/etc)
  • 2: invalid usage/validation (e.g. bad --user handle)

Version

bird --version prints package.json version plus current git sha when available, e.g. 0.3.0 (3df7969b).

Media uploads

  • Attach media with --media (repeatable) and optional --alt per item.
  • Up to 4 images/GIFs, or 1 video (no mixing). Supported: jpg, jpeg, png, webp, gif, mp4, mov.
  • Images/GIFs + 1 video supported (uploads via Twitter legacy upload endpoint + cookies; video may take longer to process).

Example:

bird tweet "hi" --media img.png --alt "desc"

Development

cd~/Projects/bird
pnpm install
pnpm run build # dist/ + bun binary
pnpm run build:dist # dist/ only
pnpm run build:binary
pnpm run dev tweet "Test"
pnpm run dev -- --plain check
pnpm test
pnpm run lint

Notes

  • GraphQL uses internal X endpoints and can be rate limited (429).
  • Query IDs rotate; refresh at runtime with bird query-ids --fresh (or update the baked baseline via pnpm run graphql:update).

About

CLI tool for X/Twitter - rescued from @steipete/bird v0.8.0

Resources

Stars

21 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors