| Crates.io | rusty-bybit |
| lib.rs | rusty-bybit |
| version | 0.1.1 |
| created_at | 2026-01-16 13:31:00.37556+00 |
| updated_at | 2026-01-24 12:59:18.535089+00 |
| description | An unofficial Rust SDK for the Bybit V5 API |
| homepage | |
| repository | https://github.com/54corbin/rusty-bybit |
| max_upload_size | |
| id | 2048604 |
| size | 155,513 |
An unofficial Rust SDK for the Bybit V5 API.
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:
Add to your Cargo.toml:
[dependencies]
rusty-bybit = "0.1"
Or install with cargo:
cargo add rusty-bybit
use rusty_bybit::BybitClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = BybitClient::testnet();
let time = client.get_server_time().await?;
println!("Server time: {}", time.time_second);
let tickers = client.get_tickers("linear").await?;
println!("Got {} tickers", tickers.list.len());
Ok(())
}
use rusty_bybit::BybitClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key = std::env::var("BYBIT_API_KEY")?;
let api_secret = std::env::var("BYBIT_API_SECRET")?;
let client = BybitClient::testnet()
.with_credentials(api_key, api_secret);
let balance = client.get_wallet_balance(None).await?;
if let Some(account) = balance.list.first() {
println!("Total equity: {}", account.total_equity);
}
Ok(())
}
use rusty_bybit::{BybitClient, CreateOrderRequest};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = BybitClient::testnet()
.with_credentials("api_key".to_string(), "api_secret".to_string());
let request = CreateOrderRequest {
category: "linear".to_string(),
symbol: "BTCUSDT".to_string(),
side: "Buy".to_string(),
order_type: "Limit".to_string(),
qty: Some("0.001".to_string()),
price: Some("28000".to_string()),
time_in_force: Some("GTC".to_string()),
..Default::default()
};
let response = client.create_order(&request).await?;
println!("Order ID: {}", response.order_id);
Ok(())
}
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 datacreate_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 ordersget_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 PnLlet client = BybitClient::testnet();
let client = BybitClient::mainnet();
let client = BybitClient::new("https://api.bybit.com".to_string());
See the crate documentation for detailed API reference.
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 managementThe SDK provides comprehensive error types via BybitError:
use rusty_bybit::{BybitClient, BybitError};
#[tokio::main]
async fn main() {
let client = BybitClient::testnet();
match client.get_server_time().await {
Ok(time) => println!("Time: {}", time.time_second),
Err(BybitError::ApiError { ret_code, ret_msg }) => {
eprintln!("API error {}: {}", ret_code, ret_msg);
}
Err(e) => eprintln!("Error: {}", e),
}
}
See CHANGELOG.md for version history and breaking changes.
Contributions are welcome! Please ensure:
cargo clippy and cargo fmtcargo testApache-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.