Async Rust client for the OKX v5 REST API.
Status: early
0.1.xcrate. The core REST client is usable, but API coverage is still expanding and breaking changes may happen before1.0.
Installation
Add rust-okx and an async runtime:
[]
= "0.1"
= { = "1", = ["rt-multi-thread", "macros"] }
The default feature enables the built-in reqwest HTTP client. Disable default
features only when you provide your own transport.
Quick Start
Public market data does not require credentials.
use OkxClient;
async
Authenticated Client
Authenticated endpoints require an API key, secret, and passphrase.
use ;
async
Demo Trading
OKX uses separate credentials for live and demo trading. Enable demo trading to
send the x-simulated-trading: 1 header.
use ;
let credentials = new;
let client = builder
.credentials
.demo_trading
.build;
Regional Accounts
The default client uses the global OKX API domain. Regional accounts should use the matching domain.
use ;
let client = builder
.region
.build;
Feature Overview
- Typed REST accessors:
market,public_data,account,funding,convert,finance, andtrade. - Demo trading support through
OkxClientBuilder::demo_trading(true). - Regional API domains through
OkxRegion. - Lossless numeric strings through
NumberString. - Matchable error enum for transport, encoding, decoding, HTTP status, API, and configuration failures.
- Default
reqwesttransport, with custom transport support for tests, proxies, retries, request recording, or replacing the HTTP stack. - Optional
rust-decimalfeature forNumberString::to_decimal(). - Optional
websocketfeature for typed WebSocket clients and events.
Examples
Testing
Most tests run offline with mock transports. Network and credential-dependent tests skip automatically when the required environment variables are missing.
For live account, demo trading, asset mutation, advanced trade, convert, or
finance tests, see .env.example. Mutation tests are disabled
unless the matching OKX_ENABLE_*_MUTATION=1 switch is set.
Roadmap
Current REST coverage includes market data, public data, account, funding,
convert, finance, and trade endpoints. WebSocket support is available behind
the websocket feature.
The next major areas are SubAccount, RFQ/block trading, grid/copy trading, spread trading, trading-data analytics, and status endpoints. See TODO.md for the detailed backlog.
Disclaimer
This is an unofficial OKX client and is not affiliated with OKX. Trading involves financial risk. Test your flows against the demo environment before using live credentials.
License
Licensed under MIT OR Apache-2.0.