Crate binance[][src]

Expand description

githubcrates-iodocs-rs


This library provides access to all of Binance’s APIs using . [async/std]: https://docs.rs/async-std/1.9.0/async_std/


Risk Warning

It is a personal project, use at your own risk. I will not be responsible for your investment losses. Cryptocurrency investment is subject to high market risk. Nonetheless, this crate is aimed at high performance and production use.

Example

This example simply pings the main binance api

use binance::general::General;
use binance::api::Binance;
use binance::errors::Error as BinanceLibError;

#[tokio::main]
async fn main() -> std::io::Result<()> {
    let general: General = Binance::new(None, None);
    let ping = general.ping().await;
    match ping {
        Ok(answer) => println!("{:?}", answer),
        Err(err) => {
            match err {
                BinanceLibError::BinanceError { response } => match response.code {
                    -1000_i16 => println!("An unknown error occured while processing the request"),
                    _ => println!("Unknown code {}: {}", response.code, response.msg),
                },
                _ => println!("Other errors: {}.", err),
            };
        }
    }
    Ok(())
}

Details

  • Credentials are not enforced, you will get authentication errors if you don’t provide credentials and they are required by an endpoint

  • Error codes are handled on a best effort basis as some are inconsistent and not even documented on Binance’s side

  • Errors are implemented using thiserror

Re-exports

pub use util::bool_to_string;
pub use util::bool_to_string_some;

Modules