Skip to content

JKorf/CryptoClients.Net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

.CryptoClients.Net CryptoClients.Net

.NET Nuget downloads License

CryptoClients.Net is a collection of different cryptocurrency exchange client libraries based on the same base library. CryptoClients.Net bundles the different client libraries in a single package and adds some additional tools to make use of them. The client libraries offer access to market data, Spot and Futures trading and various other topics depending on the API.

For more information on what CryptoExchange.Net and it's client libraries offers see the Documentation.

Supported Frameworks

The library is targeting both .NET Standard 2.0 and .NET Standard 2.1 for optimal compatibility

.NET implementation Version Support
.NET Core 2.0 and higher
.NET Framework 4.6.1 and higher
Mono 5.4 and higher
Xamarin.iOS 10.14 and higher
Xamarin.Android 8.0 and higher
UWP 10.0.16299 and higher
Unity 2018.1 and higher

Get the library

Nuget version Nuget downloads

dotnet add package CryptoClients.Net

How to use

Get a client

There are 2 main clients, the ExchangeRestClient and ExchangeSocketClient, for accessing the REST and Websocket API respectively. All exchange API's are available via these clients.
Alternatively exchange specific clients can be used, for example BinanceRestClient or KucoinSocketClient. Either create new clients directly or use Dotnet dependency injection:

// Construction
var restClient = new ExchangeRestClient();
var socketClient = new ExchangeSocketClient();


// Dependency injection, allows the injection of `IExchangeRestClient`, `IExchangeSocketClient`, `IExchangeOrderBookFactory` and for all exchanges the `I[ExchangeName]RestClient`, `I[ExchangeName]SocketClient` and `I[ExchangeName]OrderBookFactory` types
services.AddCryptoClients();

Configuration

Clients can be configured when doing the dependency injection registration, or when constructing the clients. Configuration can be done for all exchanges/clients, can be set per exchange or a combination:

builder.Services.AddCryptoClients(globalOptions =>
{
    // Global options apply to each exchange/client
    globalOptions.OutputOriginalData = true;
	// Set credentials for the different exchanges, will be applied to both REST and socket clients
    globalOptions.ApiCredentials = new CryptoClients.Net.Models.ExchangeCredentials
    {
        Binance = new ApiCredentials("BinanceKey", "BinanceSecret"),
        Kucoin = new KucoinApiCredentials("KucoinKey", "KucoinSecret", "KucoinPassphrase"),
        OKX = new OKXApiCredentials("OKXKey", "OKXSecret", "OKXPassphrase")
    };
},
bybitRestOptions: bybitOptions =>
{
    // Specify options specifically for a specific exchange and client, in this case the Bybit REST client
    bybitOptions.Environment = Bybit.Net.BybitEnvironment.Netherlands;
    bybitOptions.ApiCredentials = new ApiCredentials("BybitKey", "BybitSecret");
});

Using the client

There are multiple options for accessing exchange API's. Options 1 and 2 allow access to the full exchange API while option 3 uses a common interface which allows exchange agnostic requesting, but is therefor limited in functionality.
Option 3 is currently only supported for the Spot REST API's.

// Option 1
// Use exchange clients directly, full functionality
var kucoinClient1 = new KucoinRestClient();
var binanceClient1 = new BinanceRestClient();
var binanceResult1 = await binanceClient1.SpotApi.ExchangeData.GetTickerAsync("ETHUSDT");
var kucoinResult1 = await kucoinClient1.SpotApi.ExchangeData.GetTickerAsync("ETH-USDT");

// Option 2
// Use exchange client via ExchangeRestClient, full functionality
var restClient2 = new ExchangeRestClient();
var baseAsset2 = "ETH";
var quoteAsset2 = "USDT";
var binanceResult2 = await restClient2.Binance.SpotApi.ExchangeData.GetTickerAsync(restClient2.Binance.SpotApi.FormatSymbol(baseAsset2, quoteAsset2));
var kucoinResult2 = await restClient2.Kucoin.SpotApi.ExchangeData.GetTickerAsync(restClient2.Kucoin.SpotApi.FormatSymbol(baseAsset2, quoteAsset2));

// Option 3
// Use unified spot client via GetUnifiedSpotClient, most generic but only supports common functionality
var restClient3 = new ExchangeRestClient();
var baseAsset3 = "ETH";
var quoteAsset3 = "USDT";
var unifiedBinanceClient3 = restClient3.GetUnifiedSpotClient(Exchange.Binance);
var unifiedKucoinClient3 = restClient3.GetUnifiedSpotClient(Exchange.Kucoin);
var binanceResult3 = await unifiedBinanceClient3.GetTickerAsync(unifiedBinanceClient3.GetSymbolName(baseAsset3, quoteAsset3));
var kucoinResult3 = await unifiedKucoinClient3.GetTickerAsync(unifiedKucoinClient3.GetSymbolName(baseAsset3, quoteAsset3));

For information on the specific exchange clients, dependency injection, response processing and more see the CryptoExchange.Net documentation or have a look at the examples here. See the CryptoExchange.Net examples for client examples which also apply to CryptClients.Net

Supported Exchanges

The following API's are included in CryptoClients.Net:

Exchange Repository Nuget
Binance JKorf/Binance.Net Nuget version
BingX JKorf/BingX.Net Nuget version
Bitfinex JKorf/Bitfinex.Net Nuget version
Bitget JKorf/Bitget.Net Nuget version
Bybit JKorf/Bybit.Net Nuget version
CoinEx JKorf/CoinEx.Net Nuget version
CoinGecko JKorf/CoinGecko.Net Nuget version
Huobi/HTX JKorf/Huobi.Net Nuget version
Kraken JKorf/Kraken.Net Nuget version
Kucoin JKorf/Kucoin.Net Nuget version
Mexc JKorf/Mexc.Net Nuget version
OKX JKorf/OKX.Net Nuget version

Discord

Nuget version
A Discord server is available here. Feel free to join for discussion and/or questions around the CryptoExchange.Net and implementation libraries.

Support the project

I develop and maintain this package on my own for free in my spare time, any support is greatly appreciated.

Donate

Make a one time donation in a crypto currency of your choice. If you prefer to donate a currency not listed here please contact me.

Btc: bc1q277a5n54s2l2mzlu778ef7lpkwhjhyvghuv8qf
Eth: 0xcb1b63aCF9fef2755eBf4a0506250074496Ad5b7
USDT (TRX) TKigKeJPXZYyMVDgMyXxMf17MWYia92Rjd

Sponsor

Alternatively, sponsor me on Github using Github Sponsors.

Release notes

  • Version 1.1.0

    • Added support for GlobalExchangeOptions when constructing clients without dependency injection
    • Updated CryptoExchange.Net to 7.5.2
      • Added testing implementations
      • Small refactor AuthenticationProvider to allow better testing
      • Change result of MessageAccessor.Read methods to CallResult so error can be returned
      • Moved some DateTimeConverter logic to seperate methods to allow access from outside converters
      • Fixed SetApiCredentials not correctly being used by rate limiter causing exception
    • Updated Binance to 9.9.7
      • Updated multiple response models
      • Fixed multiple bugs after new, more thorough unit testing implementation
      • Removed duplicate SpotApi.Trading.ConvertTransferAsync and GetConvertTransferHistoryAsync endpoints
      • Updated CoinFuturesApi.Account.GetBracketsAsync to V2 endpoint
      • Updated CoinFuturesApi.Trading.PlaceMultipleOrdersAsync orders parameter from array to IEnumerable
    • Updated BingX to 1.1.1
      • Removed need for API credentials in certain ExchangeData calls
      • Renamed PerpetualFutures.Trading.GetClosedOrderAsync to GetClosedOrdersAsync
      • Changed PerpetualFutures.SubscribeToUserDataUpdatesAsync handlers to be nullable
      • Fixed SpotApi.SubscribeToBalanceUpdatesAsync update handling
      • Various small fixes
    • Updated Bitfinex to 7.2.8
    • Updated Bitget to 1.3.7
    • Updated Bybit to 3.8.8
      • Split PurchaseLeverageTokenAsync and RedeemLeverageTokenAsync response models
      • Updated various response models
      • Fixed PurchaseLeverageTokenAsync, RedeemLeverageTokenAsync and GetLeverageTokenOrderHistoryAsync request path
    • Updated CoinEx to 7.0.5
    • Updated CoinGecko to 2.2.7
    • Updated Huobi to 5.2.8
    • Updated Kraken to 4.6.5
      • Updated various models
      • Fixed deserialization issue in SpotApi.ExchangeData.GetSymbolsAsync endpoint
    • Updated Kucoin to 5.5.5
      • Added SpotApi.Trading.GetOcoOrderByClientOrderIdAsync to interface
      • Fixed universal transfer endpoint
      • Fixed FuturesApi.SubscribeToStopOrderUpdatesAsync deserialization
      • Updated various response models
    • Updated Mexc to 1.2.4
    • Updated OKX to 1.8.4
  • Version 1.0.0 - 28 Apr 2024

    • Initial version

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages