Skip to content

burakoner/OKX.Api

Repository files navigation

OKX.Api

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, and api.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

Installation

Available on NuGet:

Install-Package OKX.Api

The package currently targets:

  • netstandard2.0
  • netstandard2.1

Quick Start

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!);

Documentation

The root README is intentionally short. Full documentation now lives in docs/.

REST Sections

OkxRestApiClient is organized around OKX sections:

  • Account
  • Trade
  • Algo
  • Grid
  • DCA
  • SignalBot
  • RecurringBuy
  • CopyTrading
  • Public (Market is an alias)
  • Block
  • Spread
  • Rubik (TradingStatistics is an alias)
  • Funding
  • SubAccount
  • Financial
  • Broker
  • Affiliate

Each section now has its own reference page under docs/reference.

Examples

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.

Changelog

Release notes were moved out of the root file into split documents:

Official OKX Documentation

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.

Support

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: 33WbRKqt7wXARVdAJSu1G1x3QnbyPtZ2bH
  • ETH: 0x65b02db9b67b73f5f1e983ae10796f91ded57b64
  • USDT (TRC-20): TXwqoD7doMESgitfWa8B2gHL7HuweMmNBJ

About

Up-to-date, most-complete, well-organized, well-documented, easy-to-use, multi-task and multi-thread compatible OKX Cryptocurrency Exchange Rest and Websocket Api Wrapper

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors