Skip to main content

Crate rust_okx

Crate rust_okx 

Source
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:

  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

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 NumberString wrapper, 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.
OkxClientBuilder
Builder for OkxClient.

Enums§

Error
Errors that can occur while making an OKX API request.
OkxRegion
OKX REST API region.

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.