Open Source .NET API Wrapper for OKEx V5 REST and WebSocket APIs

ยท

Overview

OKEx.Net is a comprehensive .NET wrapper for the OKEx V5 API, providing developers with easy access to both REST and WebSocket functionalities. This open-source solution offers clear, readable objects that simplify interaction with OKEx's cryptocurrency trading platform.

Migration Notice

๐Ÿ‘‰ We strongly recommend migrating to OKX.Api for continued updates and to avoid issues related to CryptoExchange.Net dependencies. The new package offers improved functionality and maintenance.

Key Features

Implementation Details

Built upon the CryptoExchange.Net library, this wrapper inherits its robust WebSocket handling and connection management features.

Technical Foundation

Getting Started

Installation

PM> Install-Package OKEx.Net

Basic Usage

using Okex.Net;

// REST Client
var client = new OkexClient();

// WebSocket Client
var socketClient = new OkexSocketClient();

API Examples

REST API Endpoints

Public Market Data

var instruments = client.GetInstruments(OkexInstrumentType.Spot);
var ticker = client.GetTicker("BTC-USDT");

Account Management (Authenticated)

client.SetApiCredentials("API_KEY", "API_SECRET", "PASSPHRASE");
var balance = client.GetAccountBalance();

WebSocket Subscriptions

Real-time Order Book

socketClient.SubscribeToOrderBook("BTC-USDT", OkexOrderBookType.OrderBook, data => 
{
    // Handle updates
});

Private Account Updates

socketClient.SetApiCredentials("API_KEY", "API_SECRET", "PASSPHRASE");
socketClient.SubscribeToAccountUpdates(data =>
{
    // Handle balance changes
});

Best Practices

  1. Connection Management: Always dispose clients properly
  2. Error Handling: Implement robust exception handling
  3. Rate Limiting: Respect OKEx's API rate limits
  4. WebSocket Reconnection: Implement automatic reconnection logic

FAQ

Q: How do I migrate from OKEx.Net to OKX.Api?

A: Update your NuGet package reference and modify any namespace references from Okex.Net to OKX.Api.

Q: What's the difference between REST and WebSocket APIs?

A: REST is for request-response operations while WebSocket provides real-time streaming data.

Q: How do I handle authentication?

A: Use the SetApiCredentials method with your API key, secret, and passphrase.

Q: Where can I report issues?

A: Issues can be reported on the GitHub repository's issue tracker.

Q: Is there support for algorithmic orders?

A: Yes, through both REST and WebSocket interfaces.

Conclusion

OKEx.Net provides a powerful, developer-friendly way to integrate with OKEx's trading platform. Whether you're building trading bots, analytical tools, or portfolio management applications, this wrapper simplifies complex API interactions.