A command-line tool for Twitter/X API v2 that focuses on bot detection and user analysis. X-Knife helps you analyze Twitter accounts and detect potentially automated behavior through various metrics and algorithms.
- User Information Retrieval: Get detailed information about any Twitter user including account creation date, verification status, follower counts, and more
- Follower Analysis: Analyze recent followers of any account
- Bot Detection Scoring: Advanced scoring algorithm that evaluates accounts based on:
- Verification status and account protection
- Follower-to-following ratios with mathematical scoring
- Account age vs. following velocity (detects rapid following behavior)
- Additional metrics for comprehensive bot detection
- Go 1.23.2 or later
- Twitter API v2 Bearer Token (OAuth 2.0)
git clone <repository-url>
cd xknife/src/go/xknife
go build -o xknifeThe project is configured for Goreleaser builds. Binary releases will include version information.
Set up your Twitter API credentials by copying the sample environment file:
cp src/go/.env.sample .envThen edit the .env file with your credentials:
export GOTWI_API_KEY=your-api-key
export GOTWI_API_KEY_SECRET=your-api-key-secret
export GOTWI_ACCESS_TOKEN=your-oauth-access-token
export GOTWI_ACCESS_TOKEN_SECRET=your-oauth-access-token-secretX-Knife supports configuration via a YAML file located at $HOME/.xknife.yaml. You can also specify a custom config file using the --config flag.
Get information about a specific user:
xknife get --user usernameGet recent followers for a user:
xknife followers --user username --size 50--user, -u: Specify the Twitter username (default: "mkoertg")--id: Specify the Twitter user ID directly--size, -s: Number of items to retrieve (default: 20)--config, -c: Path to config file (default: $HOME/.xknife.yaml)
Analyze a user's account:
xknife get --user elonmuskCheck recent followers with custom page size:
xknife followers --user someuser --size 100The bot detection scoring system evaluates accounts on a 0-100% scale:
- Verified & Protected Accounts: Automatically receive 100% (human) score
- Follower/Following Ratio: Uses arctangent function to score based on followers vs. following
- Following Velocity: Analyzes daily following rate since account creation (accounts following >20 users/day average are flagged as suspicious)
The algorithm combines multiple factors to provide a comprehensive bot probability score.
- michimani/gotwi - Twitter API v2 Go library
- spf13/cobra - CLI framework
- spf13/viper - Configuration management
- carlmjohnson/versioninfo - Version information
The project structure:
src/go/xknife/
├── main.go # Entry point with version handling
├── cmd/
│ ├── root.go # CLI root command and configuration
│ └── bots.go # User analysis and bot detection commands
├── go.mod # Go module definition
└── .goreleaser.yaml # Release configuration
- Botometer X
- A Decade of Social Bot Detection
- Twibot-22
- GeoGebra Graphing Calculator (used for algorithm visualization)
MIT License - see LICENSE file for details.