1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! Async Rust client for the [OKX v5 REST API](https://www.okx.com/docs-v5/en/).
//!
//! The crate is built around three layers that map cleanly onto the OKX request
//! lifecycle:
//!
//! 1. **Request building** — typed request/response models live under [`api`].
//! 2. **Authentication** — credentials and HMAC-SHA256 request signing.
//! 3. **Transport** — sending raw HTTP. The [`Transport`] trait abstracts this
//! so the default [`ReqwestTransport`] can be swapped for a custom or mock
//! implementation without changing any calling code.
//!
//! # Example
//!
//! ```no_run
//! # #[cfg(feature = "reqwest")]
//! # async fn run() -> Result<(), rust_okx::Error> {
//! use rust_okx::{Credentials, OkxClient};
//!
//! // Public, unauthenticated client.
//! let client = OkxClient::builder().build();
//! let ticker = client.market().get_ticker("BTC-USDT").await?;
//! println!("last price: {}", ticker[0].last.as_str());
//!
//! // Authenticated client.
//! let creds = Credentials::new("key", "secret", "passphrase");
//! let client = OkxClient::builder().credentials(creds).build();
//! let balance = client.account().get_balance(None).await?;
//! # Ok(())
//! # }
//! # #[cfg(not(feature = "reqwest"))]
//! # fn run() {}
//! ```
pub use ;
pub use Credentials;
pub use Error;
pub use NumberString;
pub use ReqwestTransport;
pub use ;
/// Global OKX REST API base URL.
pub const GLOBAL_API_URL: &str = "https://www.okx.com";
/// US and AU OKX REST API base URL.
pub const US_API_URL: &str = "https://us.okx.com";
/// EEA OKX REST API base URL.
pub const EEA_API_URL: &str = "https://eea.okx.com";
/// Default global OKX REST API base URL.
///
/// This alias is retained for compatibility. Use [`OkxRegion`] with
/// [`OkxClientBuilder::region`] when building a client for a regional account.
pub const API_URL: &str = GLOBAL_API_URL;
/// OKX REST API region.
///
/// Regional accounts must use the matching API domain. US and AU users
/// registered on `app.okx.com` should use [`OkxRegion::Us`]. EU users
/// registered on `my.okx.com` should use [`OkxRegion::Eea`].