1 unstable release
0.1.0 | Sep 9, 2024 |
---|
#1150 in Development tools
415KB
12K
SLoC
Birdie - Binance Rust Development Kit
Birdie is a third party Binance API client, allowing you to easily interact with the Binance API using Rust.
lib.rs
:
Birdie - Binance Rust Development Kit
Birdie is a third party Binance API client, allowing you to easily interact with the Binance API using Rust.
Disclaimer
- This is a third party client and is not affiliated with Binance. Use at your own risk.
- While we will try to keep this client aligned with the official Binance API specification, please refer to the official Binance API documentation for the most up-to-date information.
- Always test your code.
Components
Birdie is divided into several components, each representing a different part of the Binance API:
- [
mod@fix_api
] - FIX API client (stub). - [
mod@rest_api
] - REST API client.- [
mod@spot
] - Spot API. - [
mod@margin
] - Margin API. - [
mod@usd_futures
] - USD Futures API (WIP).
- [
- [
mod@web_socket_api
] - Web Socket API client. - [
mod@web_socket_stream
] - Web Socket stream client.
REST API Client
See the [mod@rest_api
] module for more information.
To interact with the Binance REST API, create a REST API client first.
let endpoint = "https://api.binance.com";
let api_key = "your_api_key";
let api_secret = "your_api_secret";
let client = birdie::rest_api(endpoint, api_key, api_secret).unwrap();
Once you have the client, you can access the different categories of the API and the different endpoints.
Example 1: retrieve account information
Also see the account_balances.rs
example in the examples/
directory.
use birdie::{rest_api::Endpoint, spot::account::AccountInformationParams};
let params = AccountInformationParams::new().omit_zero_balances(true);
let resp = client.spot().account().account_information().request(params).await;
assert!(resp.is_ok());
Example 2: retrieve klines of a symbol
Also see the klines.rs
example in the examples/
directory.
use birdie::{enums::KlineInterval, rest_api::Endpoint, spot::market::KlinesParams};
let params = KlinesParams::new("BTCUSDT", KlineInterval::OneMinute).limit(5);
let klines = client.spot().market().klines().request(params).await;
assert!(klines.is_ok());
Example 3: place a limit order
use birdie::{
enums::{OrderSide, OrderType},
rest_api::Endpoint,
spot::trade::NewOrderParams,
};
let params = NewOrderParams::new("SOLUSDT", OrderSide::Buy, OrderType::Limit)
.time_in_force(birdie::enums::TimeInForce::Gtc)
.new_order_resp_type(birdie::enums::ResponseType::Result)
.quantity(1.0)
.price(100.0);
let resp = client.trade().new_order().request(params).await;
assert!(resp.is_ok());
Web Socket API Client
Web Socket Streams
Dependencies
~13–25MB
~356K SLoC