x-reader
v0.1.0
Published
Read-only Twitter/X CLI. Search tweets, read timelines, bookmarks, and replies from the terminal.
Maintainers
Readme
x-reader
Read-only Twitter/X CLI for searching tweets, reading timelines, bookmarks, and replies from the terminal. Inspired by Bird CLI.
Uses your own X/Twitter cookies. One user, one account. No API keys required.
Features
- Search tweets by keyword or advanced query (
from:,to:,filter:, etc.) - Read a user's timeline
- Read a single tweet by ID or URL
- Read replies to any tweet
- Read your bookmarks (with
--allfor full export) - Look up user profiles by handle
- JSON output for piping into other tools (
jq, scripts, etc.) - Auto-discovers X's rotating GraphQL query IDs (no manual updates needed)
- Zero config beyond two browser cookies
Why x-reader?
- No Twitter API keys or developer account needed
- Read-only by design (no accidental tweets, likes, or follows)
- Works with X's current GraphQL endpoints
- Lightweight: single dependency (Commander)
- Scriptable: JSON output for automation and data pipelines
Install
From npm (recommended)
npm install -g x-readerFrom source
git clone https://github.com/DjinnFoundry/x-reader.git
cd x-reader
npm install
npm run build
npm linkQuick start
# 1. Set up authentication (interactive)
x-reader setup
# 2. Search tweets
x-reader search "machine learning"
# 3. Read a user's timeline
x-reader user-tweets @naval -n 10
# 4. Export your bookmarks as JSON
x-reader bookmarks --all --format json > bookmarks.jsonAuthentication
You need two cookies from x.com: auth_token and ct0.
Option 1: Interactive setup
x-reader setupOption 2: Environment variables
export AUTH_TOKEN="your_auth_token"
export CT0="your_ct0"Option 3: CLI flags
x-reader search "query" --auth-token xxx --ct0 yyyWhere to find your cookies
- Go to x.com and log in
- Open DevTools (F12) -> Application -> Cookies -> x.com
- Copy
auth_tokenandct0values
Config is saved to ~/.config/x-reader/config.json.
Usage
Search tweets
x-reader search "machine learning"
x-reader search "from:elonmusk" -n 5
x-reader search "AI safety" --format jsonRead a user's timeline
x-reader user-tweets @steipete
x-reader user-tweets elonmusk -n 10
x-reader user-tweets @naval --format jsonRead a single tweet
x-reader read 1234567890
x-reader read https://x.com/user/status/1234567890
x-reader read https://x.com/user/status/1234567890 --format jsonRead replies
x-reader replies 1234567890
x-reader replies https://x.com/user/status/1234567890 --format jsonExport bookmarks
x-reader bookmarks
x-reader bookmarks -n 50
x-reader bookmarks --all --format jsonUser lookup
x-reader user-lookup @steipete
x-reader user-lookup naval --format jsonQuery ID management
# Show cached query IDs
x-reader query-ids
# Force refresh from x.com (when IDs rotate)
x-reader query-ids --refreshOutput formats
- text (default) - human-readable
- json - machine-readable, pipe to
jqor save to file
# Pipe to jq
x-reader search "typescript" --format json | jq '.tweets[].text'
# Save to file
x-reader bookmarks --all --format json > my-bookmarks.jsonProgrammatic use
import { XReaderClient } from 'x-reader';
const client = new XReaderClient({
cookies: { authToken: '...', ct0: '...' },
});
const result = await client.search('hello world', 10);
console.log(result.tweets);How it works
X uses GraphQL endpoints with rotating query IDs embedded in their client-side JavaScript bundles. x-reader auto-discovers these IDs by scraping the JS bundles, caching them locally with a 24-hour TTL. No manual ID updates needed.
If you get 404 errors, force a refresh:
x-reader query-ids --refreshArchitecture
src/
├── api/
│ ├── client.ts # Main API client (read-only operations)
│ ├── constants.ts # Bearer token, URLs, default query IDs
│ ├── features.ts # GraphQL feature flags per operation
│ ├── parser.ts # Response parsing (raw JSON -> Tweet/User)
│ ├── query-ids.ts # Auto-discovery of query IDs from x.com JS
│ └── types.ts # TypeScript interfaces
├── cli/
│ └── index.ts # CLI entry point (commander)
├── utils/
│ ├── auth.ts # Cookie resolution (env, config, bird compat)
│ └── format.ts # Output formatting
└── index.ts # Library exportsCredits
- Inspired by Bird CLI by @steipete
- Uses the same public bearer token as the X web client
- Query ID discovery mechanism reverse-engineered from Bird v0.8.0
License
MIT
