Skip to main content

bybit_client/
lib.rs

1//! # Bybit Client
2//!
3//! A Rust client library for the Bybit V5 API.
4//!
5//! ## Features
6//!
7//! - Full REST API V5 coverage.
8//! - WebSocket support for real-time data.
9//! - HMAC-SHA256 authentication.
10//! - Async/await support with tokio.
11//! - Strongly typed request/response structures.
12//!
13//! ## Quick Start
14//!
15//! ```no_run
16//! use bybit_client::{BybitClient, ClientConfig};
17//!
18//! #[tokio::main]
19//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
20//!     // Create a public-only client for public endpoints.
21//!     let client = BybitClient::public_only()?;
22//!
23//!     // Or create an authenticated client for private endpoints.
24//!     let client = BybitClient::new("your_api_key", "your_api_secret")?;
25//!
26//!     // Use testnet for testing.
27//!     let client = BybitClient::with_config(
28//!         ClientConfig::new("api_key", "api_secret").testnet()
29//!     )?;
30//!
31//!     Ok(())
32//! }
33//! ```
34//!
35//! ## Configuration
36//!
37//! The client supports various configuration options:
38//!
39//! ```no_run
40//! use bybit_client::{ClientConfig, Environment, ApiRegion};
41//!
42//! let config = ClientConfig::new("api_key", "api_secret")
43//!     .testnet()                    // Use testnet.
44//!     .recv_window(10000)           // Set `recv_window` to 10 seconds.
45//!     .debug(true)                  // Enable debug logging.
46//!     .timeout_ms(30000);           // Set request timeout to 30 seconds.
47//! ```
48
49pub mod api;
50pub mod auth;
51pub mod client;
52pub mod config;
53pub mod error;
54pub mod http;
55pub mod types;
56pub mod ws;
57
58pub use client::{BybitClient, BybitClientBuilder};
59pub use config::{ApiRegion, ClientConfig, Environment};
60pub use error::{ApiResponse, BybitError, ListResult};
61pub use types::*;
62
63/// Prelude module for common imports.
64pub mod prelude {
65    pub use crate::client::{BybitClient, BybitClientBuilder};
66    pub use crate::config::{ApiRegion, ClientConfig, Environment};
67    pub use crate::error::{ApiResponse, BybitError, ListResult};
68    pub use crate::types::*;
69}