Skip to content

dcompoze/binance-api-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

binance-api-client

Async Rust client for Binance Spot REST and WebSocket APIs.

  • Async REST client for market, account, wallet, and margin endpoints.
  • WebSocket support for market streams and user data streams.
  • Auth support for HMAC-SHA256, RSA-SHA256, and Ed25519 signatures.
  • Production, testnet, and Binance.US configuration.
  • Typed request builders and typed response models.

Usage

use binance_api_client::Binance;

#[tokio::main]
async fn main() -> binance_api_client::Result<()> {
    let client = Binance::new_unauthenticated()?;
    let ticker = client.market().price("BTCUSDT").await?;
    println!("BTCUSDT: {}", ticker.price);
    Ok(())
}

Authenticated usage:

use binance_api_client::Binance;

#[tokio::main]
async fn main() -> binance_api_client::Result<()> {
    let client = Binance::new("your_api_key", "your_secret_key")?;
    let account = client.account().get_account().await?;
    println!("Balances: {}", account.balances.len());
    Ok(())
}

Configuration

  • Config::default() for Binance production.
  • Config::testnet() for Binance Spot testnet.
  • Config::binance_us() for Binance.US.

Security

  • Do not commit real API keys or secrets.
  • Use environment variables, for example BINANCE_API_KEY and BINANCE_SECRET_KEY.
  • Start from .env.example for local development.

Examples

Run examples with:

cargo run --example market_data
cargo run --example websocket_streams

About

A Rust async client library for the Binance REST APIs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages