diff --git a/docs/index.html b/docs/index.html
index 6f04a6a..bff0ad3 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -262,7 +262,421 @@
============================ -->
+ All client libraries support and encourage usage via the Dotnet dependency injection system. Add all necesary services by calling the This registers the following interfaces which can then be injectedDependency Injection
-
+ Add[Library]();
extension method on the service collection. Options for the clients can be passed as parameters.
+
+ builder.Services.AddBinance();
+ builder.Services.AddBitfinex();
+ builder.Services.AddBitget();
+ builder.Services.AddBybit();
+ builder.Services.AddCoinGecko();
+ builder.Services.AddCoinEx();
+ builder.Services.AddHuobi();
+ builder.Services.AddKraken();
+ builder.Services.AddKucoin();
+ builder.Services.AddMexc();
+ builder.Services.AddOKX();
+
+
+ Interface Description
+
+
+ IBinanceRestClient
The client for accessing the Binance REST API
+
+
+
+ IBinanceSocketClient
The client for accessing the Binance Websocket API
+
+
+
+ IBinanceOrderBookFactory
A factory for creating SymbolOrderBook instances for the Binance API
+
+
+
+ ICryptoRestClient
An aggregating client from which multiple different library REST clients can be accessed
+
+
+
+ ICryptoSocketClient
An aggregating client from which multiple different library Websocket clients can be accessed
+
+
+
+ ISpotClient
An implementation of the ISpotClient interface for Binance. The ISpotClient offers basic Spot API functionality in a combined interface
+
+
+
+ Interface Description
+
+
+ IBitfinexRestClient
The client for accessing the Bitfinex REST API
+
+
+
+ IBitfinexSocketClient
The client for accessing the Bitfinex Websocket API
+
+
+
+ IBitfinexOrderBookFactory
A factory for creating SymbolOrderBook instances for the Bitfinex API
+
+
+
+ ICryptoRestClient
An aggregating client from which multiple different library REST clients can be accessed
+
+
+
+ ICryptoSocketClient
An aggregating client from which multiple different library Websocket clients can be accessed
+
+
+
+ ISpotClient
An implementation of the ISpotClient interface for Bitfinex. The ISpotClient offers basic Spot API functionality in a combined interface
+
+
+
+ Interface Description
+
+
+ IBitgetRestClient
The client for accessing the Bitget REST API
+
+
+
+ IBitgetSocketClient
The client for accessing the Bitget Websocket API
+
+
+
+ IBitgetOrderBookFactory
A factory for creating SymbolOrderBook instances for the Bitget API
+
+
+
+ ICryptoRestClient
An aggregating client from which multiple different library REST clients can be accessed
+
+
+
+ ICryptoSocketClient
An aggregating client from which multiple different library Websocket clients can be accessed
+
+
+
+ ISpotClient
An implementation of the ISpotClient interface for Bitget. The ISpotClient offers basic Spot API functionality in a combined interface
+
+
+
+ Interface Description
+
+
+ IBybitRestClient
The client for accessing the Bybit REST API
+
+
+
+ IBybitSocketClient
The client for accessing the Bybit Websocket API
+
+
+
+ IBybitOrderBookFactory
A factory for creating SymbolOrderBook instances for the Bybit API
+
+
+
+ ICryptoRestClient
An aggregating client from which multiple different library REST clients can be accessed
+
+
+
+ ICryptoSocketClient
An aggregating client from which multiple different library Websocket clients can be accessed
+
+
+
+ ISpotClient
An implementation of the ISpotClient interface for Bybit. The ISpotClient offers basic Spot API functionality in a combined interface
+
+
+
+ Interface Description
+
+
+ ICoinGeckoRestClient
The client for accessing the CoinGecko REST API
+
+
+
+ ICryptoRestClient
An aggregating client from which multiple different library REST clients can be accessed
+
+
+
+ Interface Description
+
+
+ ICoinExRestClient
The client for accessing the CoinEx REST API
+
+
+
+ ICoinExSocketClient
The client for accessing the CoinEx Websocket API
+
+
+
+ ICoinExOrderBookFactory
A factory for creating SymbolOrderBook instances for the CoinEx API
+
+
+
+ ICryptoRestClient
An aggregating client from which multiple different library REST clients can be accessed
+
+
+
+ ICryptoSocketClient
An aggregating client from which multiple different library Websocket clients can be accessed
+
+
+
+ ISpotClient
An implementation of the ISpotClient interface for CoinEx. The ISpotClient offers basic Spot API functionality in a combined interface
+
+
+
+ Interface Description
+
+
+ IHuobiRestClient
The client for accessing the Huobi REST API
+
+
+
+ IHuobiSocketClient
The client for accessing the Huobi Websocket API
+
+
+
+ IHuobiOrderBookFactory
A factory for creating SymbolOrderBook instances for the Huobi API
+
+
+
+ ICryptoRestClient
An aggregating client from which multiple different library REST clients can be accessed
+
+
+
+ ICryptoSocketClient
An aggregating client from which multiple different library Websocket clients can be accessed
+
+
+
+ ISpotClient
An implementation of the ISpotClient interface for Huobi. The ISpotClient offers basic Spot API functionality in a combined interface
+
+
+
+ Interface Description
+
+
+ IKrakenRestClient
The client for accessing the Kraken REST API
+
+
+
+ IKrakenSocketClient
The client for accessing the Kraken Websocket API
+
+
+
+ IKrakenOrderBookFactory
A factory for creating SymbolOrderBook instances for the Kraken API
+
+
+
+ ICryptoRestClient
An aggregating client from which multiple different library REST clients can be accessed
+
+
+
+ ICryptoSocketClient
An aggregating client from which multiple different library Websocket clients can be accessed
+
+
+
+ ISpotClient
An implementation of the ISpotClient interface for Kraken. The ISpotClient offers basic Spot API functionality in a combined interface
+
+
+
+ Interface Description
+
+
+ IKucoinRestClient
The client for accessing the Kucoin REST API
+
+
+
+ IKucoinSocketClient
The client for accessing the Kucoin Websocket API
+
+
+
+ IKucoinOrderBookFactory
A factory for creating SymbolOrderBook instances for the Kucoin API
+
+
+
+ ICryptoRestClient
An aggregating client from which multiple different library REST clients can be accessed
+
+
+
+ ICryptoSocketClient
An aggregating client from which multiple different library Websocket clients can be accessed
+
+
+
+ ISpotClient
An implementation of the ISpotClient interface for Kucoin. The ISpotClient offers basic Spot API functionality in a combined interface
+
+
+
+ Interface Description
+
+
+ IMexcRestClient
The client for accessing the Mexc REST API
+
+
+
+ IMexcSocketClient
The client for accessing the Mexc Websocket API
+
+
+
+ IMexcOrderBookFactory
A factory for creating SymbolOrderBook instances for the Mexc API
+
+
+
+ ICryptoRestClient
An aggregating client from which multiple different library REST clients can be accessed
+
+
+
+ ICryptoSocketClient
An aggregating client from which multiple different library Websocket clients can be accessed
+
+
+
+ ISpotClient
An implementation of the ISpotClient interface for Mexc. The ISpotClient offers basic Spot API functionality in a combined interface
+
+
+
+ Interface Description
+
+
+ IOKXRestClient
The client for accessing the OKX REST API
+
+
+
+ IOKXSocketClient
The client for accessing the OKX Websocket API
+
+
+
+ IOKXOrderBookFactory
A factory for creating SymbolOrderBook instances for the OKX API
+
+
+
+ ICryptoRestClient
An aggregating client from which multiple different library REST clients can be accessed
+
+
+
+ ICryptoSocketClient
An aggregating client from which multiple different library Websocket clients can be accessed
+
+
+
+ ISpotClient
An implementation of the ISpotClient interface for OKX. The ISpotClient offers basic Spot API functionality in a combined interface
+
Each library provides a REST API client. This client follows the following naming convention: [Library]RestClient
. The REST API client is split into different sub-API access clients, which in turn are split into different topics. This structure is the same for each library, which makes it easier to navigate the clients.
The client can be injected via dependency injection, or constructed manually.
+ +var client = new BinanceRestClient();
+var tickersResult = await client.SpotApi.ExchangeData.GetTickersAsync();
+if (!tickersResult.Success)
+{
+ // Handle error, tickersResult.Error contains more information
+}
+else
+{
+ // Handle data, tickersResult.Data will contain the actual data
+}
+ var client = new BitfinexRestClient();
+var tickersResult = await client.SpotApi.ExchangeData.GetTickersAsync();
+if (!tickersResult.Success)
+{
+ // Handle error, tickersResult.Error contains more information
+}
+else
+{
+ // Handle data, tickersResult.Data will contain the actual data
+}
+ var client = new BitgetRestClient();
+var tickersResult = await client.SpotApi.ExchangeData.GetTickersAsync();
+if (!tickersResult.Success)
+{
+ // Handle error, tickersResult.Error contains more information
+}
+else
+{
+ // Handle data, tickersResult.Data will contain the actual data
+}
+ var client = new BybitRestClient();
+var tickersResult = await client.V5Api.ExchangeData.GetSpotTickersAsync();
+if (!tickersResult.Success)
+{
+ // Handle error, tickersResult.Error contains more information
+}
+else
+{
+ // Handle data, tickersResult.Data will contain the actual data
+}
+ var client = new CoinGeckoRestClient();
+var assetsResult = await client.Api.GetAssetsAsync();
+if (!assetsResult.Success)
+{
+ // Handle error, assetsResult.Error contains more information
+}
+else
+{
+ // Handle data, assetsResult.Data will contain the actual data
+}
+ var client = new CoinExRestClient();
+var tickersResult = await client.SpotApi.ExchangeData.GetTickersAsync();
+if (!tickersResult.Success)
+{
+ // Handle error, tickersResult.Error contains more information
+}
+else
+{
+ // Handle data, tickersResult.Data will contain the actual data
+}
+ var client = new HuobiRestClient();
+var tickersResult = await client.SpotApi.ExchangeData.GetTickersAsync();
+if (!tickersResult.Success)
+{
+ // Handle error, tickersResult.Error contains more information
+}
+else
+{
+ // Handle data, tickersResult.Data will contain the actual data
+}
+ var client = new KrakenRestClient();
+var tickersResult = await client.SpotApi.ExchangeData.GetTickersAsync();
+if (!tickersResult.Success)
+{
+ // Handle error, tickersResult.Error contains more information
+}
+else
+{
+ // Handle data, tickersResult.Data will contain the actual data
+}
+ var client = new KucoinRestClient();
+var tickersResult = await client.SpotApi.ExchangeData.GetTickersAsync();
+if (!tickersResult.Success)
+{
+ // Handle error, tickersResult.Error contains more information
+}
+else
+{
+ // Handle data, tickersResult.Data will contain the actual data
+}
+ var client = new MexcRestClient();
+var tickersResult = await client.SpotApi.ExchangeData.GetTickersAsync();
+if (!tickersResult.Success)
+{
+ // Handle error, tickersResult.Error contains more information
+}
+else
+{
+ // Handle data, tickersResult.Data will contain the actual data
+}
+ var client = new OKXRestClient();
+var tickersResult = await client.UnifiedApi.ExchangeData.GetTickersAsync(OKXInstrumentType.Spot);
+if (!tickersResult.Success)
+{
+ // Handle error, tickersResult.Error contains more information
+}
+else
+{
+ // Handle data, tickersResult.Data will contain the actual data
+}
+ The response object
+Calls made with the REST API client will return a WebCallResult
object. This object contains information about both the request that was send and the response that was received. The WebCallResult
object exposes the following properties:
Property | Description |
---|---|
Success | +Whether or not the call was completed successfully | +
Data | +The parsed response object, only available when Success is true |
+
Error | +Error information, only available when Success is false |
+
OriginalData | +The raw response data, only filled when the OutputOriginalData is enabled in the client options |
+
RequestMethod | +The HTTP method that was used for the request | +
RequestHeaders | +The list of headers which were send with the request | +
RequestId | +A unique request id | +
RequestUrl | +The full urls which was called | +
RequestBody | +The request body send with the request | +
ResponseLength | +The length of the response in bytes | +
ResponseHeaders | +The list of headers send along with the response | +
ResponseTime | +The time it took from sending the request to receiving the response | +
If the API supports websocket connections then the library provides a Websocket API client. This client follows the following naming convention: [Library]SocketClient
. The Websocket API client is split into different sub-API access clients, which in turn are sometimes split into different topics. This structure is the same for each library, which makes it easier to navigate the clients.
The client can be injected via dependency injection, or constructed manually. When constructing manually keep in mind that when the client is disposed all connections will get closed as well.
+ +var client = new BinanceSocketClient();
+var subscribeResult = await client.SpotApi.ExchangeData.SubscribeToAllTickerUpdatesAsync(update => {
+ // Handle the data update, update.Data will contain the actual data
+});
+if (!subscribeResult.Success)
+{
+ // Handle error, subscribeResult.Error contains more information on why the subscription failed
+}
+// Subscribing was successfull, the data will now be streamed into the data handler
+ var client = new BitfinexSocketClient();
+var subscribeResult = await client.SpotApi.SubscribeToTickerUpdatesAsync("tETHUST", update => {
+ // Handle the data update, update.Data will contain the actual data
+});
+if (!subscribeResult.Success)
+{
+ // Handle error, subscribeResult.Error contains more information on why the subscription failed
+}
+// Subscribing was successfull, the data will now be streamed into the data handler
+ var client = new BitgetSocketClient();
+var subscribeResult = await client.SpotApi.SubscribeToTickerUpdatesAsync("ETHUSDT", update => {
+ // Handle the data update, update.Data will contain the actual data
+});
+if (!subscribeResult.Success)
+{
+ // Handle error, subscribeResult.Error contains more information on why the subscription failed
+}
+// Subscribing was successfull, the data will now be streamed into the data handler
+ var client = new BybitSocketClient();
+var subscribeResult = await client.V5SpotApi.SubscribeToTickerUpdatesAsync("ETHUSDT", update => {
+ // Handle the data update, update.Data will contain the actual data
+});
+if (!subscribeResult.Success)
+{
+ // Handle error, subscribeResult.Error contains more information on why the subscription failed
+}
+// Subscribing was successfull, the data will now be streamed into the data handler
+ var client = new CoinExSocketClient();
+var subscribeResult = await client.SpotApi.SubscribeToTickerUpdatesAsync("ETHUSDT", update => {
+ // Handle the data update, update.Data will contain the actual data
+});
+if (!subscribeResult.Success)
+{
+ // Handle error, subscribeResult.Error contains more information on why the subscription failed
+}
+// Subscribing was successfull, the data will now be streamed into the data handler
+ var client = new HuobiSocketClient();
+var subscribeResult = await client.SpotApi.SubscribeToTickerUpdatesAsync(update => {
+ // Handle the data update, update.Data will contain the actual data
+});
+if (!subscribeResult.Success)
+{
+ // Handle error, subscribeResult.Error contains more information on why the subscription failed
+}
+// Subscribing was successfull, the data will now be streamed into the data handler
+ var client = new KrakenSocketClient();
+var subscribeResult = await client.SpotApi.SubscribeToTickerUpdatesAsync("ETH/USD", update => {
+ // Handle the data update, update.Data will contain the actual data
+});
+if (!subscribeResult.Success)
+{
+ // Handle error, subscribeResult.Error contains more information on why the subscription failed
+}
+// Subscribing was successfull, the data will now be streamed into the data handler
+ var client = new KucoinSocketClient();
+var subscribeResult = await client.SpotApi.SubscribeToAllTickerUpdatesAsync(update => {
+ // Handle the data update, update.Data will contain the actual data
+});
+if (!subscribeResult.Success)
+{
+ // Handle error, subscribeResult.Error contains more information on why the subscription failed
+}
+// Subscribing was successfull, the data will now be streamed into the data handler
+ var client = new MexcSocketClient();
+var subscribeResult = await client.SpotApi.SubscribeToMiniTickerUpdatesAsync(update => {
+ // Handle the data update, update.Data will contain the actual data
+});
+if (!subscribeResult.Success)
+{
+ // Handle error, subscribeResult.Error contains more information on why the subscription failed
+}
+// Subscribing was successfull, the data will now be streamed into the data handler
+ var client = new OKXSocketClient();
+var subscribeResult = await client.UnifiedApi.ExchangeData.SubscribeToTickerUpdatesAsync("ETH-USDT", update => {
+ // Handle the data update, update.Data will contain the actual data
+});
+if (!subscribeResult.Success)
+{
+ // Handle error, subscribeResult.Error contains more information on why the subscription failed
+}
+// Subscribing was successfull, the data will now be streamed into the data handler
+ The subscription result object
+Subscriptions calls will return a CallResult<UpdateSubscription>
object. This object contains information about the status of the intial subscription, and the UpdateSubscription data object exposes events for status changes and methods for managing the subscription. The CallResult<UpdateSubscription>
object exposes the following properties:
Property | Description |
---|---|
Success | +Whether or not the subscription was completed successfully | +
Error | +Error information, only available when Success is false |
+
Data | +The UpdateSubscription object, only available when Success is true |
+
Data.Id | +Unique id of the subscription | +
Data.SocketId | +The id of the underlying websocket | +
Data.ConnectionLost | +Event which will be invoked whenever the connection to the server is lost and reconnecting will be started | +
Data.ConnectionRestored | +Event which will be invoked when the connection to the server is restored after being disconnected | +
Data.ActivityPaused | +Event which will be invoked when the server has indicated that currently no operations will be accepted | +
Data.ActivityUnpaused | +Event which will be invoked when the server has indicated that operations will be accepted again after a previous ActivityPaused event | +
Data.Exception | +Event which will be invoked when the data handler of the subscription throws an exception | +
The subscription update event object
+Whenever new data is received for a subscription the data handler will be called with a DataEvent<T>
object. This object contains information about the event and the actual update data. The DataEvent<T>
object exposes the following properties:
Property | Description |
---|---|
Timestamp | +The timestamp the data was received | +
Topic | +The topic of the update, typically the symbol or stream name | +
OriginalData | +The raw update data, only filled when the OutputOriginalData is enabled in the client options |
+
UpdateType | +The type of update. SocketUpdateType.Snapshot means the update is a snapshot, not an incremental update. SocketUpdateType.Update means it's an update with new data |
+
Data | +The data received in the update | +
+ When no longer interested in updates from a specific subscription it can be unsubscribed. This can be done in one of the following ways: +
+
+ Unsubscribe via UpdateSubscription object
+ When you have the reference to the UpdateSubscription object received from the Subscribe method you can call the CloseAsync()
method on that to unsubscribe
+
var subscribeResult = await client.SpotApi.SubscribeToTickerUpdates(data => {});
+await subscribeResult.Data.CloseAsync();
+
+
+ Unsubscribe via CancellationToken
+ Passing in a CancellationToken
as parameter in the subscribe method will allow you to cancel subscriptions by canceling the token. This can be useful when you need to cancel some streams but not others. In this example, both BTCUSDT
and ETHUSDT
streams get canceled, while the XRPUSDT
stream remains active.
+
var cts = new CancellationTokenSource();
+var subscriptionResult1 = await client.SpotApi.SubscribeToTickerUpdatesAsync("BTCUSDT", DataHandler, cts.Token);
+var subscriptionResult2 = await client.SpotApi.SubscribeToTickerUpdatesAsync("ETHUSDT", DataHandler, cts.Token);
+var subscriptionResult3 = await client.SpotApi.SubscribeToTickerUpdatesAsync("XRPUSDT", DataHandler);
+cts.Cancel();
+
+
+ Unsubscribe via the websocket client
+ The Websocket client has multiple ways of unsubscribing one or more subscriptions:
+
var subscribeResult = await client.SpotApi.SubscribeToTickerUpdates(data => {});
+// Unsubscribe by passing the UpdateSubscription
+await client.UnsubscribeAsync(subscribeResult.Data);
+// OR store the ID and pass that
+var subId = subscribeResult.Data.Id;
+await client.UnsubscribeAsync(subId);
+// OR unsubscribe all subscriptions at the same time
+await client.UnsubscribeAllAsync();
+
+
+
The options can be defined in the static SetDefaultOptions method on the client BEFORE creating the client. Any client created after this call will use the specified options
+The options can be defined using the static SetDefaultOptions method on the client BEFORE creating the client. Any client created after this call will use the specified options