Expand description
Async Rust client for the OKX v5 REST API.
The crate is built around three layers that map cleanly onto the OKX request lifecycle:
- Request building — typed request/response models live under
api. - Authentication — credentials and HMAC-SHA256 request signing.
- Transport — sending raw HTTP. The
Transporttrait abstracts this so the defaultReqwestTransportcan be swapped for a custom or mock implementation without changing any calling code.
§Example
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?;Re-exports§
pub use model::NumberString;pub use transport::ReqwestTransport;pub use transport::Transport;pub use transport::TransportError;
Modules§
- api
- Typed request/response models and endpoint methods, grouped by OKX API area.
- model
- Shared data types: the
NumberStringwrapper, the response envelope, and the common string enums used across the API modules. - transport
- The HTTP transport abstraction.
Structs§
- Credentials
- OKX API credentials: an API key, secret key, and passphrase.
- OkxClient
- An OKX v5 REST API client, generic over the HTTP
Transport. - OkxClient
Builder - Builder for
OkxClient.
Enums§
Constants§
- API_URL
- Default global OKX REST API base URL.
- EEA_
API_ URL - EEA OKX REST API base URL.
- GLOBAL_
API_ URL - Global OKX REST API base URL.
- US_
API_ URL - US and AU OKX REST API base URL.
Type Aliases§
- Result
- A type alias for
std::result::Resultusing this crate’sError.