OKX.Api is a .NET wrapper for the OKX V5 REST and WebSocket APIs.
The project aims to stay close to the official OKX surface while still feeling natural in C#:
- section-based clients such as
api.Account,api.Trade,api.Public, andapi.Funding - typed request and response models instead of loose dictionaries
- REST and WebSocket coverage in the same package
- support for both public and authenticated workflows
- examples, fixtures, and integration coverage for the live API
Available on NuGet:
Install-Package OKX.ApiThe package currently targets:
netstandard2.0netstandard2.1
Add the namespace:
using OKX.Api;Create a REST client for public endpoints:
var api = new OkxRestApiClient();
var instruments = await api.Public.GetInstrumentsAsync(OkxInstrumentType.Spot);
var ticker = await api.Public.GetTickerAsync("BTC-USDT");
if (ticker.Success)
{
Console.WriteLine($"{ticker.Data!.InstrumentId}: {ticker.Data.LastPrice}");
}Create a REST client for private endpoints:
var api = new OkxRestApiClient();
api.SetApiCredentials("YOUR-API-KEY", "YOUR-API-SECRET", "YOUR-API-PASSPHRASE");
var balances = await api.Account.GetBalancesAsync();
var openOrders = await api.Trade.GetOpenOrdersAsync();Create a WebSocket client:
var ws = new OkxWebSocketApiClient();
var subscription = await ws.Public.SubscribeToTickersAsync(
data => Console.WriteLine($"{data.InstrumentId} {data.LastPrice}"),
"BTC-USDT");
// later
await ws.UnsubscribeAsync(subscription.Data!);The root README is intentionally short. Full documentation now lives in docs/.
- Documentation Home
- Installation
- Creating REST Clients
- Authentication and Public vs Private Requests
- WebSocket Quick Start
- REST Client Reference
- Changelog
OkxRestApiClient is organized around OKX sections:
AccountTradeAlgoGridDCASignalBotRecurringBuyCopyTradingPublic(Marketis an alias)BlockSpreadRubik(TradingStatisticsis an alias)FundingSubAccountFinancialBrokerAffiliate
Each section now has its own reference page under docs/reference.
The repository includes a dedicated examples project:
It contains end-to-end sample calls across REST and WebSocket sections and is a good place to explore the current API surface quickly.
Release notes were moved out of the root file into split documents:
This wrapper follows the official OKX documentation:
Where behavior differs in practice, the wrapper and its tests prefer live API behavior over stale examples whenever possible.
If you think something is broken, something is missing, or you have a question, please open an issue.
If you want to support maintenance, the original donation addresses are kept here:
BTC:33WbRKqt7wXARVdAJSu1G1x3QnbyPtZ2bHETH:0x65b02db9b67b73f5f1e983ae10796f91ded57b64USDT (TRC-20):TXwqoD7doMESgitfWa8B2gHL7HuweMmNBJ