Expand description
§Bybit API
A Rust SDK for the Bybit V5 API.
§Features
- Async-first design with tokio
- Type-safe request/response models
- Zero-panic error handling
- Support for REST API and WebSocket
§Quick Start
use bybit_api::{BybitClient, Category};
#[tokio::main]
async fn main() -> bybit_api::Result<()> {
// Create a client for testnet
let client = BybitClient::testnet("your_api_key", "your_api_secret")?;
// Get tickers
let tickers = client.get_tickers(Category::Linear, Some("BTCUSDT")).await?;
println!("{:?}", tickers);
Ok(())
}Modules§
- account
- Account models.
- api
- API endpoint implementations.
- asset
- Asset models.
- market
- Market data models.
- position
- Position models.
- trade
- Trade models for orders.
- websocket
- WebSocket client for Bybit streaming API.
Structs§
- Bybit
Client - Bybit HTTP API client.
- Client
Config - Configuration for the Bybit HTTP client.
- Client
Config Builder - Builder for ClientConfig.
- Funding
History - Funding rate history response.
- Funding
Record - Single funding record.
- Instrument
Info - Single instrument info.
- Instruments
Info - Instruments info response.
- Kline
- Parsed kline data.
- Klines
- Kline response.
- Leverage
Filter - Leverage filter.
- LotSize
Filter - Lot size filter.
- Open
Interest - Open interest response.
- Open
Interest Record - Single open interest record.
- Orderbook
- Orderbook response.
- Price
Filter - Price filter.
- Recent
Trades - Recent trades response.
- Risk
Limit - Single risk limit.
- Risk
Limits - Risk limit response.
- Server
Time - Server time response.
- Ticker
- Single ticker.
- Tickers
- Tickers response.
- Trade
- Single trade.
- WsConfig
- Configuration for WebSocket client.
Enums§
- Account
Type - Account type.
- Bybit
Error - The main error type for the Bybit API client.
- Category
- Product category.
- Interval
- Kline interval.
- Margin
Mode - Margin mode.
- Order
Status - Order status.
- Order
Type - Order type.
- Position
Idx - Position side.
- Position
Mode - Position mode.
- Side
- Order side.
- Time
InForce - Time in force.
- TpSl
Mode - TP/SL mode.
- Trigger
By - Trigger price type.
Constants§
- DEFAULT_
RECV_ WINDOW - Default receive window in milliseconds
- DEFAULT_
TIMEOUT_ SECS - Default request timeout in seconds
- DEFAULT_
WS_ PING_ INTERVAL - Default WebSocket ping interval in seconds
- DEMO
- Demo trading environment
- DEMO_
WS_ PRIVATE - Private channel (demo)
- DEMO_
WS_ TRADE - Trade channel (demo)
- HEADER_
API_ KEY - API key header
- HEADER_
RECV_ WINDOW - Receive window header
- HEADER_
SIGN - Signature header
- HEADER_
SIGN_ TYPE - Sign type header
- HEADER_
TIMESTAMP - Timestamp header
- HONGKONG
- Hong Kong
- KAZAKHSTAN
- Kazakhstan
- MAINNET
- Mainnet REST API
- MAINNET_
BYTICK - Mainnet alternative (bytick)
- MAINNET_
WS_ PRIVATE - Private channel (mainnet)
- MAINNET_
WS_ PUBLIC_ INVERSE - Inverse public channel (mainnet)
- MAINNET_
WS_ PUBLIC_ LINEAR - Linear public channel (mainnet)
- MAINNET_
WS_ PUBLIC_ OPTION - Option public channel (mainnet)
- MAINNET_
WS_ PUBLIC_ SPOT - Spot public channel (mainnet)
- MAINNET_
WS_ PUBLIC_ SPREAD - Spread public channel (mainnet)
- MAINNET_
WS_ TRADE - Trade channel (mainnet)
- NETHERLANDS
- Netherlands
- TESTNET
- Testnet REST API
- TESTNET_
WS_ PRIVATE - Private channel (testnet)
- TESTNET_
WS_ PUBLIC_ INVERSE - Inverse public channel (testnet)
- TESTNET_
WS_ PUBLIC_ LINEAR - Linear public channel (testnet)
- TESTNET_
WS_ PUBLIC_ OPTION - Option public channel (testnet)
- TESTNET_
WS_ PUBLIC_ SPOT - Spot public channel (testnet)
- TESTNET_
WS_ PUBLIC_ SPREAD - Spread public channel (testnet)
- TESTNET_
WS_ TRADE - Trade channel (testnet)
- TURKEY
- Turkey
Type Aliases§
- Result
- Result type alias for Bybit operations