Skip to content

dazeb/bird-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bird-Go

A fast, native Linux Twitter/X CLI client written in Go. Bird-Go bypasses Twitter's restrictive API by using your browser's session cookies to interact with Twitter's internal GraphQL endpoints.

Features

  • 🚀 Native Go Binary - Single executable, no runtime dependencies
  • 🔐 Cookie-Based Auth - Automatically extracts session from Chrome/Firefox
  • 🐧 Linux Optimized - Built specifically for Linux (amd64/arm64)
  • Fast & Lightweight - Minimal overhead, instant startup
  • 🔒 No API Keys Required - Uses your existing browser session

Installation

From Source

git clone https://github.com/dazeb/bird-go.git
cd bird-go
go build -ldflags="-s -w" -o bin/bird ./cmd/bird
sudo mv bin/bird /usr/local/bin/

Prerequisites

  • Go 1.24 or later
  • Chrome, Chromium, or Firefox installed natively (not Snap/Flatpak)
  • Active Twitter/X session in your browser

Usage

Bird-Go provides several commands to interact with Twitter/X from the command line. All commands support the global --debug flag for verbose output.

Quick Start

# Post a tweet (default command)
bird "Hello from Bird-Go!"

Agent Reference

For AI agents: Below is a structured reference of all available commands in machine-readable format.

# BIRD-GO CLI COMMANDS

## PROJECT INFO
- Binary: bird
- Language: Go
- Purpose: Twitter/X CLI client using browser cookies
- Auth: Automatic cookie extraction from Chrome/Firefox or env vars

## GLOBAL FLAGS
--debug, -d    Enable debug mode with verbose output
--help, -h     Show help information

## AVAILABLE COMMANDS

### DEFAULT COMMAND
Command: bird [text]
Description: Post a tweet (default action)
Args: 
  - text (required): Tweet content as string
Exit Code: 0 on success, 1 on error
Output: Tweet ID and URL on success
Example: bird "Hello World"

### POST
Command: bird post [text]
Description: Post a tweet to Twitter/X
Args:
  - text (required): Tweet content as string
Exit Code: 0 on success, 1 on error
Output: Tweet ID and URL on success
Example: bird post "Hello World"

### LOGIN
Command: bird login
Description: Verify cookie extraction and authentication
Args: None
Exit Code: 0 on success, 1 on error
Output: Cookie source and masked tokens
Example: bird login

### TIMELINE
Command: bird timeline
Description: View home timeline (NOT YET IMPLEMENTED)
Args: None
Status: Not implemented
Exit Code: 1 (not implemented)
Output: Error message
Example: bird timeline

## ENVIRONMENT VARIABLES
BIRD_AUTH_TOKEN    Twitter auth_token cookie value
BIRD_CT0           Twitter ct0 CSRF token value

## AUTHENTICATION PRIORITY
1. Environment variables (BIRD_AUTH_TOKEN, BIRD_CT0)
2. Browser cookies (Chrome → Chromium → Firefox)

## BUILD COMMANDS
go build -ldflags="-s -w" -o bin/bird ./cmd/bird    Build optimized binary
go build -o bird ./cmd/bird                          Build standard binary
make build                                            Build using Makefile (if exists)

## TESTING COMMANDS
go test ./...           Run all tests
go test -v ./...        Run tests with verbose output

## DEPENDENCY MANAGEMENT
go mod tidy            Clean up dependencies
go mod download        Download dependencies
go get -u <package>    Update specific package

## COMMON USAGE PATTERNS
bird "$(cat file.txt)"                 Post from file
echo "text" | xargs bird               Post from pipe
bird --debug login                     Debug authentication
export BIRD_AUTH_TOKEN="..." && bird   Use env vars

## ERROR HANDLING
- HTTP 403: Cookies expired, refresh browser session
- HTTP 404: Query IDs rotated, update internal/client/constants.go
- Cookie not found: Browser not native install or not logged into x.com
- Auth failed: Verify browser session at x.com

## PROJECT STRUCTURE
cmd/bird/              CLI entry point and command definitions
internal/auth/         Cookie extraction logic
internal/client/       Twitter GraphQL client
internal/models/       Data structures and GraphQL types
go.mod                 Go module dependencies

Commands Reference

Global Flags

All commands support the following flags:

-d, --debug    Enable debug mode (shows detailed credential info)
-h, --help     Show help information

bird [text] - Default Command

Post a tweet directly without using the post subcommand.

Syntax:

bird [text]

Examples:

# Post a simple tweet
bird "Hello from Bird-Go!"

# Post a multi-line tweet
bird "Line 1
Line 2
Line 3"

# Post with debug mode
bird --debug "Testing debug output"

Output:

Posting tweet: Hello from Bird-Go!
✓ Tweet posted successfully!
  Tweet ID: 1234567890123456789
  URL: https://x.com/i/status/1234567890123456789

bird post [text] - Post a Tweet

Post a new tweet to your Twitter/X account.

Syntax:

bird post [text]

Examples:

# Post a tweet
bird post "Hello from Bird-Go!"

# Post with emoji
bird post "🚀 Launching Bird-Go!"

# Post with hashtags
bird post "Testing #BirdGo #TwitterCLI"

# Post with debug mode
bird post --debug "Debug tweet"

Output:

Posting tweet: Hello from Bird-Go!
✓ Tweet posted successfully!
  Tweet ID: 1234567890123456789
  URL: https://x.com/i/status/1234567890123456789

bird login - Verify Authentication

Verify that Bird-Go can extract Twitter session cookies from your browser.

Syntax:

bird login

Examples:

# Check authentication
bird login

# Check authentication with full token display
bird login --debug

Output (Normal):

✓ Successfully found Twitter cookies!
  Source: Chrome
  auth_token: ****abc123
  ct0: ****xyz789

Output (Debug Mode):

✓ Successfully found Twitter cookies!
  Source: Chrome
  auth_token: 1a2b3c4d5e...890xyz123abc
  ct0: abcdef1234...567890zyxw

bird timeline - View Timeline

Fetch and display your Twitter/X home timeline.

Syntax:

bird timeline

Status: 🚧 Not yet implemented

Examples:

# View your timeline (coming soon)
bird timeline

Advanced Usage Examples

Using Environment Variables

Override automatic cookie detection with manual credentials:

# Set credentials
export BIRD_AUTH_TOKEN="your_auth_token_here"
export BIRD_CT0="your_ct0_token_here"

# Post a tweet
bird "Testing with env vars"

Debug Mode

Debug mode reveals detailed information about credential sources and tokens:

# Check where credentials are coming from
bird --debug login

# Debug a tweet post
bird --debug post "Test tweet"

Shell Integration

# Read from file
bird "$(cat message.txt)"

# Pipe from another command
echo "Automated tweet" | xargs bird

# Schedule tweets with cron
echo "0 9 * * * bird 'Good morning!'" | crontab -

Handling Special Characters

# Quotes within tweets
bird 'He said "Hello World"'

# Newlines
bird $'First line\nSecond line\nThird line'

# Variables
MESSAGE="Hello from shell"
bird "$MESSAGE"

How It Works

Bird-Go uses the kooky library to extract Twitter session cookies (auth_token and ct0) from your browser's cookie database. It then uses these cookies to authenticate requests to Twitter's internal GraphQL API, the same API used by the official web client.

Authentication Priority

  1. Command-line arguments (if implemented)
  2. Environment variables (BIRD_AUTH_TOKEN, BIRD_CT0)
  3. Browser cookies (Chrome → Chromium → Firefox)

Environment Variables

If automatic cookie extraction fails, you can manually provide credentials:

export BIRD_AUTH_TOKEN="your_auth_token_here"
export BIRD_CT0="your_ct0_token_here"
bird "Test tweet"

Important Notes

Browser Compatibility

⚠️ Snap/Flatpak Limitations: Browsers installed via Snap or Flatpak may have restricted filesystem access. Bird-Go requires access to the browser's cookie database, which may be sandboxed in these installations.

Recommended: Install Chrome/Firefox using your distribution's native package manager:

# Debian/Ubuntu
sudo apt install firefox chromium-browser

# Fedora
sudo dnf install firefox chromium

# Arch
sudo pacman -S firefox chromium

Query ID Rotation

Twitter occasionally rotates GraphQL Query IDs. If you encounter errors, the Query IDs in internal/client/constants.go may need updating. Check the original Bird repository for the latest values.

Troubleshooting

"Could not find Twitter cookies"

  1. Ensure you're logged into x.com in Chrome or Firefox
  2. Check that your browser is installed natively (not Snap/Flatpak)
  3. Try running with debug mode: bird --debug login
  4. Manually set environment variables as a fallback

"HTTP 403 Forbidden"

Your cookies may have expired. Open x.com in your browser to refresh your session, then try again.

"HTTP 404 Not Found"

Twitter may have rotated the GraphQL Query IDs. Check for updates or manually update the Query IDs in internal/client/constants.go.

Development

Project Structure

bird-go/
├── cmd/bird/           # CLI entry point
├── internal/
│   ├── auth/          # Cookie extraction
│   ├── client/        # Twitter API client
│   └── models/        # Data structures
└── go.mod

Building

# Standard build
go build -o bird ./cmd/bird

# Optimized build (smaller binary)
go build -ldflags="-s -w" -o bird ./cmd/bird

# Cross-compile for ARM64
GOARCH=arm64 go build -ldflags="-s -w" -o bird-arm64 ./cmd/bird

Security

  • Never commit your auth_token or ct0 values
  • Bird-Go does not log credentials unless debug mode is enabled
  • Cookies are read directly from browser databases and never stored

Credits

License

MIT License - See LICENSE file for details

Disclaimer

This tool is for educational purposes. Use responsibly and in accordance with Twitter's Terms of Service. The author is not responsible for any misuse or violations.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors