Rusty-Bybit SDK
An unofficial Rust SDK for the Bybit V5 API.
⚠️ Warning
This repository is mostly generated by AI agents. While every effort is made to ensure code quality and correctness, this codebase should be used with caution.
Use at your own risk:
- This is an unofficial SDK and is not endorsed or maintained by Bybit
- Code generated by AI agents may contain errors or unexpected behavior
- Always thoroughly test any code before using it with real funds
- Start with testnet environments and small amounts
- Review the code before integrating it into production systems
- The authors assume no liability for any financial losses or damages
Features
- Unified Trading Account Support - Single account type for all trading
- Type-Safe API - Strongly-typed enums prevent errors at compile time
- Full Async/Await - Built on tokio for non-blocking operations
- Comprehensive Error Handling - Detailed error types for better debugging
- HMAC-SHA256 Authentication - Secure signature generation for private endpoints
Installation
Add to your Cargo.toml:
[]
= "0.1"
Quick Start
Public Endpoints
use BybitClient;
async
Authenticated Endpoints
use BybitClient;
async
Creating Orders
use ;
async
API Endpoints
Market Data
get_server_time()- Get Bybit server timeget_tickers(category)- Get tickers for a market categoryget_orderbook(category, symbol, limit)- Get orderbookget_instruments(category)- Get instrument infoget_kline(category, symbol, interval)- Get kline data
Trading
create_order(request)- Create a new ordercancel_order(category, order_id, symbol)- Cancel a specific ordercancel_all_orders(category, symbol)- Cancel all orders for a symbolget_order(category, order_id)- Get order detailsget_open_orders(category)- Get all open orders
Account
get_wallet_balance(account_type)- Get wallet balanceget_position(category, symbol)- Get position infoset_leverage(category, symbol, buy_leverage, sell_leverage)- Set leverageget_execution_list(category, symbol)- Get execution historyget_closed_pnl(category, symbol)- Get closed PnL
Environment
Testnet
let client = testnet;
Mainnet
let client = mainnet;
Custom URL
let client = new;
API Reference
See the crate documentation for detailed API reference.
Examples
See the examples/ directory for more usage examples:
basic_usage.rs- Basic market data and authenticated requestsmarket_data.rs- Market data endpointsorder_management.rs- Order creation and managementaccount_management.rs- Wallet and position management
Error Handling
The SDK provides comprehensive error types via BybitError:
use ;
async
Breaking Changes
See CHANGELOG.md for version history and breaking changes.
Bybit API Documentation
Contributing
Contributions are welcome! Please ensure:
- Code passes
cargo clippyandcargo fmt - All tests pass:
cargo test - Documentation is updated for public API changes
License
Apache-2.0 License
Copyright 2025 rusty-bybit contributors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.