2 unstable releases
Uses new Rust 2024
| 0.2.0 | Aug 11, 2025 |
|---|---|
| 0.1.0 | Aug 10, 2025 |
#5 in #spot
35 downloads per month
Used in binance-rs
155KB
4.5K
SLoC
Binance API in Rust π‘
Warning β οΈ
This project is under active development and may contain bugs or partial implementations. Use at your own risk. β
Credits β
People & Ideas π‘
- π¦ Rust Language & Community β for making systems programming modern and safe.
- π Binance API Docs β https://binance-docs.github.io/apidocs/
- π§ High-frequency trading system architectures β inspiration for thread-safe, real-time, high-performance design.
- π¬ ChatGPT by OpenAI β for guidance, feedback, and code architecture suggestions. π€
Crates & Libraries π¦
| Crate | Version | Purpose | Link |
|---|---|---|---|
ed25519-dalek |
2.1.1 | Ed25519 digital signature algorithm (crypto) | docs.rs |
futures-util |
0.3.31 | Utilities for async/await, stream handling | docs.rs |
hex |
0.4.3 | Encode/decode hex strings | docs.rs |
hmac |
0.12.1 | HMAC (keyed-hash message authentication) | docs.rs |
reqwest |
0.12.15 | HTTP client with TLS + JSON support | docs.rs |
serde |
1.0.219 | Serialization framework | docs.rs |
serde_json |
1.0.140 | JSON serialization/deserialization | docs.rs |
serde_urlencoded |
0.7.1 | URL form encoding/decoding support | docs.rs |
sha2 |
0.10.8 | SHA-2 family hash functions | docs.rs |
tokio |
1.44.2 | Asynchronous runtime for Rust | docs.rs |
tokio-tungstenite |
0.26.2 | Async WebSocket client/server over Tokio | docs.rs |
binance-common |
β | Shared types/utilities (local crate) | Local path: ../binance-common |
chrono |
0.4.40 | Date and time library |
About the Project πͺ΄
This library provides both asynchronous and synchronous Binance API clients for Spot and Futures markets. REST clients are separated by type (market, trade, account, etc.) and asset class (Spot, USDT Futures, COIN-M Futures).
Authenticated endpoints use an HMAC-SHA256 signer to generate signatures for private actions like placing orders or querying account balances. All API types share common data structures and error handling logic for consistency.
For WebSockets, the project supports the Websocket Market for Futures data streaming with a multiplexed, manager/controller architecture that enables multiple topics (e.g. trades, depth, kline, account) to be streamed concurrently over a single connection. Messages are routed across threads using thread-safe channels and handled with strongly typed enums (WebSocketResponse) for zero-cost abstraction and safety.
The code is modular and built for extension β REST and WS clients can be plugged into higher-level trading systems, bots, or analytics engines.
Built With βοΈ
- π¦ Rust
- βοΈ Tokio β async runtime
- π Tungstenite β WebSocket protocol
- π§© Serde β serialization/deserialization
- π¦ Cargo β package manager
Getting Started π
System Requirements β
- Operating System: Linux, macOS
- Rust toolchain (recommended: stable)
- WebSocket connectivity (ensure ports aren't blocked)
Features π
-
β Subscribe to trade, depth, kline, and user/account WebSocket streams
Real-time access to Binance market and account events. -
π§ Multiplexed WebSocket handling with internal manager/controller architecture
Efficient coordination of multiple WebSocket tasks in a structured system. -
π§΅ Thread-safe command + response channel design
Allows cross-thread interaction with WebSocket tasks using safe, bounded channels. -
π§ Custom message enums (
WebSocketResponse) for type-safe stream handling
Ensures efficient and maintainable decoding of WebSocket messages. -
π Easily extendable to REST integration or order execution
Designed with future support in mind for REST trading endpoints and more.
Learning Resources π±
- π Binance API Docs
- π§΅ Tokio Book
- π Rust Async Book
- π¦ The Rust Programming Language
- π Crypto Trading Systems in Rust (cryptick)
- π Tungstenite Docs
- π Rust by Example
Contributing ποΈ
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any improvements, bug reports, or ideas are greatly appreciated!
How to Contribute
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Describe clearly what youβve added or fixed, and wait for feedback! Donβt forget to β the project if you found it useful β thanks again for your support!
Contact. βοΈ
Denis Gruia
- Twitter - @denisgruiax
- Email - [email protected]
- Project Link - https://github.com/denisgruiax
Dependencies
~12β31MB
~433K SLoC