Bybit SDK
Unofficial Rust SDK for the Bybit exchange API.
Disclaimer
Stability & Versioning Policy
No stability or backward-compatibility guarantees are provided.
Every version change must be treated as a breaking change, including minor and patch releases.
Users are strongly advised to pin an exact version, for example:
patisson-bybit-sdk = "=0.2.6"
Maintenance Policy
This package is developed only in the author's free time.
Releases are best-effort and not planned in advance.
The scope of the package is intentionally limited to the most commonly used functionality.
Features
- REST API support
- Websocket API support
- Only async clients
- All categories: Spot, Linear, Inverse, Option
Examples
See examples/ for runnable programs.
Get tickers
use ;
let cfg = new;
let client = new?;
// If category=option, symbol or baseCoin must be passed.
let params = new.with_symbol;
let response = client.get_tickers.await?;
println!;
Private endpoints, timeouts and rate limiting
use Duration;
use ;
let cfg = new
.credentials
.recv_window // Milliseconds.
.timeout
.rate_limiter;
let client = new?;
Calling a private endpoint on a client without credentials returns
Error::MissingCredentials.
Clock synchronization
Bybit rejects signed requests whose timestamp is more than recv_window behind
(or 1 s ahead of) its own clock (retCode 10002). Client::sync_time measures
the offset to the server clock and applies it to every signed request; call it
after creating the client, periodically in long-running programs and after a
10002 error. Use Client::server_timestamp for the WebSocket auth message:
use create_outgoing_message_auth_at;
let offset_ms = client.sync_time.await?;
let auth = create_outgoing_message_auth_at;
Subscribe to public channel 'ticker'
use ;
let url = format!;
let args = vec!;
let = new;
handle.connect.await?;
while let Some = events.recv.await
Subscribe to private channels
use ;
let api_key = from;
let api_secret = from;
let url = format!;
let args = vec!;
let = new;
handle.connect.await?;
while let Some = events.recv.await
License
This project is licensed under the MIT license.