▀▄▀ ▄▀▀ █▄█
█ █ ▄██ █ █
Twitter/X CLI without API keys.
xsh is a command-line interface for Twitter/X that works with cookie-based authentication. No developer account, no API keys, no rate limit headaches. Just log in with your browser and go.
- 🔑 Cookie-based auth - Use your existing browser session
- 📊 Rich terminal output - Beautiful formatted tweets and threads
- 🤖 JSON mode - Perfect for scripting and AI agents (
--json) - 🔍 Search, timeline, user profiles - Full read access
- 💬 Post, like, retweet, bookmark - Write operations supported
- 🏷️ Bookmarks management - View and manage your bookmarks
🪟 Windows PowerShell (AMD64)
$exe="xsh-windows-amd64.exe"; Invoke-WebRequest -Uri ((Invoke-RestMethod "https://api.github.com/repos/benoitpetit/xsh/releases/latest").assets | Where-Object name -like "*windows_amd64.exe").browser_download_url -OutFile $exe; Write-Host "Downloaded: .\$exe"🪟 Windows PowerShell (ARM64)
$exe="xsh-windows-arm64.exe"; Invoke-WebRequest -Uri ((Invoke-RestMethod "https://api.github.com/repos/benoitpetit/xsh/releases/latest").assets | Where-Object name -like "*windows_arm64.exe").browser_download_url -OutFile $exe; Write-Host "Downloaded: .\$exe"🐧 Linux AMD64
curl -LO $(curl -s https://api.github.com/repos/benoitpetit/xsh/releases/latest | grep -oP 'https.*linux-amd64.tar.gz' | head -1) && tar -xzf xsh-linux-amd64.tar.gz && chmod +x xsh-linux-amd64 && sudo mv xsh-linux-amd64 /usr/local/bin/xsh && rm xsh-linux-amd64.tar.gz🐧 Linux ARM64
curl -LO $(curl -s https://api.github.com/repos/benoitpetit/xsh/releases/latest | grep -oP 'https.*linux-arm64.tar.gz' | head -1) && tar -xzf xsh-linux-arm64.tar.gz && chmod +x xsh-linux-arm64 && sudo mv xsh-linux-arm64 /usr/local/bin/xsh && rm xsh-linux-arm64.tar.gz🍎 macOS Intel (AMD64)
curl -LO $(curl -s https://api.github.com/repos/benoitpetit/xsh/releases/latest | grep -oP 'https.*darwin-amd64.tar.gz' | head -1) && tar -xzf xsh-darwin-amd64.tar.gz && chmod +x xsh-darwin-amd64 && sudo mv xsh-darwin-amd64 /usr/local/bin/xsh && rm xsh-darwin-amd64.tar.gz🍎 macOS Apple Silicon (ARM64)
curl -LO $(curl -s https://api.github.com/repos/benoitpetit/xsh/releases/latest | grep -oP 'https.*darwin-arm64.tar.gz' | head -1) && tar -xzf xsh-darwin-arm64.tar.gz && chmod +x xsh-darwin-arm64 && sudo mv xsh-darwin-arm64 /usr/local/bin/xsh && rm xsh-darwin-arm64.tar.gzgo install github.com/benoitpetit/xsh@latestgit clone https://github.com/benoitpetit/xsh
cd xsh
go build -o xsh
./xsh --helpExtract cookies from your browser (Chrome, Firefox, Brave, Edge supported):
xsh auth login --browser chromeOr manually set credentials:
xsh auth set --auth-token "your_auth_token" --ct0 "your_ct0"# View your timeline
xsh feed
# Search tweets
xsh search "golang"
# View a tweet thread
xsh tweet view 1234567890 --thread
# Post a tweet
xsh tweet post "Hello from xsh!"
# Like/Retweet
xsh like 1234567890
xsh retweet 1234567890
# User profile
xsh user elonmusk
# Your bookmarks
xsh bookmarks| Command | Description |
|---|---|
auth login |
Authenticate with browser cookies |
feed |
View home timeline |
search <query> |
Search tweets |
tweet view <id> |
View a tweet |
tweet post <text> |
Post a tweet |
tweet delete <id> |
Delete your tweet |
like <id> |
Like a tweet |
unlike <id> |
Unlike a tweet |
retweet <id> |
Retweet |
unretweet <id> |
Undo retweet |
bookmark <id> |
Bookmark a tweet |
unbookmark <id> |
Remove bookmark |
bookmarks |
View your bookmarks |
user <handle> |
View user profile |
user tweets <handle> |
View user's tweets |
user following <handle> |
View following list |
user followers <handle> |
View followers list |
trends |
View trending topics |
count <text> |
Count characters in a tweet |
--json- Output as JSON for scripting-v, --verbose- Show HTTP requests--account <name>- Use specific account (for multi-account)
xsh uses your browser's Twitter/X cookies to authenticate. The login command extracts:
auth_token- Session tokenct0- CSRF token
Cookies are stored securely in ~/.config/xsh/auth.json.
If browser extraction fails, you can manually set credentials:
- Open your browser's DevTools (F12)
- Go to Application/Storage → Cookies → x.com
- Copy
auth_tokenandct0values - Set credentials with:
xsh auth set --auth-token "..." --ct0 "..."All commands support --json for machine-readable output:
xsh search "python" --json | jq '.[].text'
xsh user elonmusk --json | jq '.followers_count'
xsh feed --json | jq '.[].id'Auto-detected when piping output.
Config file: ~/.config/xsh/config.toml
[general]
default_count = 20
show_engagement = true
theme = "dark"
[request]
delay = 1.5
timeout = 30
max_retries = 3# Run tests
go test ./...
# Build
go build -o xsh
# Run with verbose output
./xsh -v feedOccasional 404 responses can happen. x.com regularly changes the format and structure of its API to discourage automation, so endpoints may change or disappear unexpectedly. xsh provides an internal command, xsh endpoints, which tries to detect the current endpoints on x.com, but 404s can still occur.
If you run into a 404, please open an issue — I will investigate and update the retry logic and the dynamic endpoint discovery/recovery as needed.
This tool is for educational purposes. Use at your own risk. Respect Twitter/X's Terms of Service.
MIT