Skip to content

xdevplatform/xurl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xurl - A curl-like CLI Tool for the X API

A command-line tool for interacting with the X (formerly Twitter) API, supporting both OAuth 1.0a and OAuth 2.0 authentication.

Features

  • OAuth 2.0 PKCE flow authentication
  • OAuth 1.0a authentication
  • Multiple OAuth 2.0 account support
  • Persistent token storage
  • HTTP request customization (headers, methods, body)

Installation

curl -fsSL https://raw.githubusercontent.com/xdevplatform/xurl/main/install.sh | sudo bash

Configuration

Add the following to your environment variables if you want to use OAuth 2.0:

export CLIENT_ID=your_client_id
export CLIENT_SECRET=your_client_secret

Optional environment variables:

Usage

Authentication

OAuth 2.0 authentication:

xurl auth oauth2

OAuth 1.0a authentication:

xurl auth oauth1 --consumer-key KEY --consumer-secret SECRET --access-token TOKEN --token-secret SECRET

View authentication status:

xurl auth status

Clear authentication:

xurl auth clear --all              # Clear all tokens
xurl auth clear --oauth1           # Clear OAuth 1.0a tokens
xurl auth clear --oauth2-username USERNAME  # Clear specific OAuth 2.0 token

Making Requests

Basic GET request:

xurl /2/users/me

Custom HTTP method:

xurl -X POST /2/tweets -d '{"text":"Hello world!"}'

Add headers:

xurl -H "Content-Type: application/json" /2/tweets

Specify authentication type:

xurl --auth oauth2 /2/users/me
xurl --auth oauth1 /2/tweets

Use specific OAuth 2.0 account:

xurl --username johndoe /2/users/me

Token Storage

Tokens are stored securely in ~/.xurl in your home directory.

Development

The project uses the following structure:

  • src/main.rs: Entry point and command handling
  • src/auth/: Authentication implementation
  • src/api/: API client implementation
  • src/cli/: Command-line interface definitions
  • src/config/: Configuration management
  • src/error/: Error types and handling

Testing

Run the test suite:

cargo test

Contributing

Contributions are welcome!

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a new Pull Request

License

This project is open-sourced under the MIT License - see the LICENSE file for details.