mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-08-11 08:22:53 +00:00
229 lines
23 KiB
Markdown
229 lines
23 KiB
Markdown
#  CryptoExchange.Net
|
|
|
|
[](https://github.com/JKorf/CryptoExchange.Net/actions/workflows/dotnet.yml) [](https://www.nuget.org/packages/CryptoExchange.Net) 
|
|

|
|
|
|
CryptoExchange.Net is a base library which is used to implement different cryptocurrency (exchange) API's. It provides a standardized way of implementing different API's, which results in a very similar experience for users of the API implementations.
|
|
Note that the CryptoExchange.Net package itself can not be used directly for accessing API's. Either install a client library from the list below or use [CryptoClients.Net](https://github.com/jkorf/CryptoClients.Net) which includes access to all exchange API's.
|
|
|
|
For more information on what CryptoExchange.Net and it's client libraries offers see the [Documentation](https://cryptoexchange.jkorf.dev/).
|
|
|
|
### For AI Coding Assistants
|
|
|
|
This library and the entire CryptoExchange.Net ecosystem provide first-class support for AI coding assistants. The relevant skill files are in this repository:
|
|
|
|
- **Agents**: `AGENTS.md` (auto-detected at repo root)
|
|
- **Cursor**: `.cursor/rules/cryptoexchange-net.mdc`
|
|
- **GitHub Copilot**: `.github/copilot-instructions.md`
|
|
- **Other tools** (Windsurf, Codex, Continue, Aider, etc.): `llms.txt` at repo root
|
|
- **Compilable examples**: `Examples/ai-friendly/`
|
|
|
|
For single-exchange code, see also the AI files in each exchange's repository (Binance.Net, Bybit.Net, OKX.Net, ...) — they cover exchange-specific patterns.
|
|
|
|
See [cryptoexchange-skills-hub](https://github.com/JKorf/cryptoexchange-skills-hub) for installable skills.
|
|
|
|
**Quick prompt to verify your assistant is using these:**
|
|
> "Show me how to fetch BTC/USDT spot tickers from Binance and OKX concurrently in C# using the SharedApis pattern."
|
|
|
|
The expected output should use `.SharedClient` properties, `SharedSymbol`, `ISpotTickerRestClient`, and `Task.WhenAll`.
|
|
|
|
### CryptoExchange.Net Ecosystem
|
|
Full list of all libraries part of the CryptoExchange.Net ecosystem. Consider using a referral link to support development, as well as potentially get some trading fee discount!
|
|
|
|
||API|Type|Repository|Nuget|Referral Link|Referral Fee Discount|
|
|
|--|--|--|--|--|--|--|
|
|
||Aster|DEX|[JKorf/Aster.Net](https://github.com/JKorf/Aster.Net)|[](https://www.nuget.org/packages/JKorf.Aster.Net)|[Link](https://www.asterdex.com/en/referral/FD2E11)|4%|
|
|
||Binance|CEX|[JKorf/Binance.Net](https://github.com/JKorf/Binance.Net)|[](https://www.nuget.org/packages/Binance.Net)|[Link](https://accounts.binance.com/register?ref=X5K3F2ZG)|20%|
|
|
||BingX|CEX|[JKorf/BingX.Net](https://github.com/JKorf/BingX.Net)|[](https://www.nuget.org/packages/JK.BingX.Net)|[Link](https://bingx.com/invite/FFHRJKWG/)|20%|
|
|
||Bitfinex|CEX|[JKorf/Bitfinex.Net](https://github.com/JKorf/Bitfinex.Net)|[](https://www.nuget.org/packages/Bitfinex.Net)|-|-|
|
|
||Bitget|CEX|[JKorf/Bitget.Net](https://github.com/JKorf/Bitget.Net)|[](https://www.nuget.org/packages/JK.Bitget.Net)|[Link](https://partner.bitget.com/bg/1qlf6pj1)|20%|
|
|
||BitMart|CEX|[JKorf/BitMart.Net](https://github.com/JKorf/BitMart.Net)|[](https://www.nuget.org/packages/BitMart.Net)|[Link](https://www.bitmart.com/invite/JKorfAPI/en-US)|30%|
|
|
||BitMEX|CEX|[JKorf/BitMEX.Net](https://github.com/JKorf/BitMEX.Net)|[](https://www.nuget.org/packages/JKorf.BitMEX.Net)|[Link](https://www.bitmex.com/app/register/94f98e)|30%|
|
|
||Bitstamp|CEX|[JKorf/Bitstamp.Net](https://github.com/JKorf/Bitstamp.Net)|[](https://www.nuget.org/packages/Bitstamp.Net)|-|-|
|
|
||BloFin|CEX|[JKorf/BloFin.Net](https://github.com/JKorf/BloFin.Net)|[](https://www.nuget.org/packages/BloFin.Net)|-|-|
|
|
||Bybit|CEX|[JKorf/Bybit.Net](https://github.com/JKorf/Bybit.Net)|[](https://www.nuget.org/packages/Bybit.Net)|[Link](https://partner.bybit.com/b/jkorf)|-|
|
|
||Coinbase|CEX|[JKorf/Coinbase.Net](https://github.com/JKorf/Coinbase.Net)|[](https://www.nuget.org/packages/JKorf.Coinbase.Net)|[Link](https://advanced.coinbase.com/join/T6H54H8)|-|
|
|
||CoinEx|CEX|[JKorf/CoinEx.Net](https://github.com/JKorf/CoinEx.Net)|[](https://www.nuget.org/packages/CoinEx.Net)|[Link](https://www.coinex.com/register?rc=rbtnp)|20%|
|
|
||CoinW|CEX|[JKorf/CoinW.Net](https://github.com/JKorf/CoinW.Net)|[](https://www.nuget.org/packages/CoinW.Net)|[Link](https://www.coinw.com/register?rc=rbtnp)|-|
|
|
||CoinGecko|-|[JKorf/CoinGecko.Net](https://github.com/JKorf/CoinGecko.Net)|[](https://www.nuget.org/packages/CoinGecko.Net)|-|-|
|
|
||Crypto.com|CEX|[JKorf/CryptoCom.Net](https://github.com/JKorf/CryptoCom.Net)|[](https://www.nuget.org/packages/CryptoCom.Net)|[Link](https://crypto.com/exch/26ge92xbkn)|-|
|
|
||DeepCoin|CEX|[JKorf/DeepCoin.Net](https://github.com/JKorf/DeepCoin.Net)|[](https://www.nuget.org/packages/DeepCoin.Net)|[Link](https://s.deepcoin.com/jddhfca)|-|
|
|
||Gate.io|CEX|[JKorf/GateIo.Net](https://github.com/JKorf/GateIo.Net)|[](https://www.nuget.org/packages/GateIo.Net)|[Link](https://www.gate.io/share/JKorf)|20%|
|
|
||HTX|CEX|[JKorf/HTX.Net](https://github.com/JKorf/HTX.Net)|[](https://www.nuget.org/packages/JKorf.HTX.Net)|[Link](https://www.htx.com/invite/en-us/1f?invite_code=ekek5223)|30%|
|
|
||HyperLiquid|DEX|[JKorf/HyperLiquid.Net](https://github.com/JKorf/HyperLiquid.Net)|[](https://www.nuget.org/packages/HyperLiquid.Net)|[Link](https://app.hyperliquid.xyz/join/JKORF)|4%|
|
|
||Kraken|CEX|[JKorf/Kraken.Net](https://github.com/JKorf/Kraken.Net)|[](https://www.nuget.org/packages/KrakenExchange.Net)|-|-|
|
|
||Kucoin|CEX|[JKorf/Kucoin.Net](https://github.com/JKorf/Kucoin.Net)|[](https://www.nuget.org/packages/Kucoin.Net)|[Link](https://www.kucoin.com/r/rf/QBS4FPED)|-|
|
|
||LBank|CEX|[JKorf/LBank.Net](https://github.com/JKorf/LBank.Net)|[](https://www.nuget.org/packages/LBank.Net)|[Link](https://www.lbank.com/ref/60SLT)|-|
|
|
||Lighter|DEX|[JKorf/Lighter.Net](https://github.com/JKorf/Lighter.Net)|[](https://www.nuget.org/packages/JKorf.Lighter.Net)|-|-|
|
|
||Mexc|CEX|[JKorf/Mexc.Net](https://github.com/JKorf/Mexc.Net)|[](https://www.nuget.org/packages/JK.Mexc.Net)|-|-|
|
|
||OKX|CEX|[JKorf/OKX.Net](https://github.com/JKorf/OKX.Net)|[](https://www.nuget.org/packages/JK.OKX.Net)|[Link](https://www.okx.com/join/14592495)|20%|
|
|
||Pionex|CEX|[JKorf/Pionex.Net](https://github.com/JKorf/Pionex.Net)|[](https://www.nuget.org/packages/Pionex.Net)|-|-|
|
|
||Polymarket|DEX|[JKorf/Polymarket.Net](https://github.com/JKorf/Polymarket.Net)|[](https://www.nuget.org/packages/Polymarket.Net)|-|-|
|
|
||Toobit|CEX|[JKorf/Toobit.Net](https://github.com/JKorf/Toobit.Net)|[](https://www.nuget.org/packages/Toobit.Net)|[Link](https://www.toobit.com/en-US/register?invite_code=zsV19h)|-|
|
|
||Upbit|CEX|[JKorf/Upbit.Net](https://github.com/JKorf/Upbit.Net)|[](https://www.nuget.org/packages/JKorf.Upbit.Net)|-|-|
|
|
||Weex|CEX|[JKorf/Weex.Net](https://github.com/JKorf/Weex.Net)|[](https://www.nuget.org/packages/Weex.Net)|-|-|
|
|
||WhiteBit|CEX|[JKorf/WhiteBit.Net](https://github.com/JKorf/WhiteBit.Net)|[](https://www.nuget.org/packages/WhiteBit.Net)|[Link](https://whitebit.com/referral/a8e59b59-186c-4662-824c-3095248e0edf)|-|
|
|
||XT|CEX|[JKorf/XT.Net](https://github.com/JKorf/XT.Net)|[](https://www.nuget.org/packages/XT.Net)|[Link](https://www.xt.com/ru/accounts/register?ref=CZG39C)|25%|
|
|
|
|
Any of these can be installed independently or install [CryptoClients.Net](https://github.com/jkorf/CryptoClients.Net) which includes all exchange API's.
|
|
|
|
### Full demo application
|
|
A full demo application is available using the [CryptoClients.Net](https://github.com/jkorf/CryptoClients.Net) library:
|
|
https://github.com/JKorf/CryptoManager.Net
|
|
|
|
## Discord
|
|
[](https://discord.gg/MSpeEtSY8t)
|
|
A Discord server is available [here](https://discord.gg/MSpeEtSY8t). Feel free to join for discussion and/or questions around the CryptoExchange.Net and implementation libraries.
|
|
|
|
## Support the project
|
|
Any support is greatly appreciated.
|
|
|
|
### Referral
|
|
When creating an account on new exchanges please consider using a referral link from above.
|
|
|
|
### Donate
|
|
Make a one time donation in a crypto currency of your choice. If you prefer to donate in a different currency or network send me a message.
|
|
|
|
**USDT (TRX)** TKigKeJPXZYyMVDgMyXxMf17MWYia92Rjd
|
|
|
|
### Sponsor
|
|
Alternatively, sponsor me on Github using [Github Sponsors](https://github.com/sponsors/JKorf).
|
|
|
|
## Update notes from version 11.x to 12.x for client implementations
|
|
* Result types:
|
|
* (Web)CallResult types are replaced by HttpResult, WebSocketResult and QueryResult
|
|
* Use (Http/WebSocket/Query)Result.Ok(..) and .Fail(..) for creation
|
|
* Result objects no longer override implicit conversion to bool, use Success property instead
|
|
* CallResult.SuccessResult has been replaced with CallResult.Ok()
|
|
|
|
* Parameters & serialization:
|
|
* ParameterCollection type is replaced by Parameters, most AddXX() methods can be replaced by Add()
|
|
* Parameter serialization behavior can be controlled in the Add method as third parameter, or in the ParameterSerializationSettings
|
|
* ArraySerialization has been move into the new Parameters object
|
|
* RestRequestConfiguration in AuthenticationProvider.ProcessRequest now contains the full RequestDefinition instead of copied fields. This changes for example `request.Authenticated` to `request.RequestDefinition.Authenticated`
|
|
|
|
WebSocket routing:
|
|
* MessageRouting has been split into event and query routing; use CreateForEvent for subscriptions and CreateForQuery for queries.
|
|
* Queries returning a mapped type can specify a second type parameter in CreateForQuery for the result type
|
|
* MessageRouter.CreateWithoutHandler has been replaced with CreateVoid
|
|
|
|
Shared APIs:
|
|
* Option defintions now always require the exchange name as first parameter
|
|
* Every request/subscription now has a dedicated options type
|
|
* ExchangeSymbolCache now requires EnvironmentName as parameter for operations
|
|
* Validation has been unified via `SharedClient.[Request]Options.ValidateRequest(request, this);`
|
|
* Validation now includes auth check and klines support internally, no need for explicit checks
|
|
* AsExchangeResult/ExchangeWebResult has been removed, use normal HttpResults instead
|
|
* ExchangeResult has been replaced by ExchangeCallResult
|
|
* TradingMode has been removed from the response model, only maintained on models where it makes sense
|
|
* IListenKey support has been removed, listen keys should be managed internally with TokenManager
|
|
|
|
Various:
|
|
* ApiClients now require an exchange name in the constructor
|
|
* ApiClients now required ILoggerFactory parameter instead of ILogger instance
|
|
* RestApiClient SendAsync without type parameter removed, use SendAsync<Unit> instead
|
|
* Address parameter removed from SendAsync RestApiClient, should be specified on the request definition instead
|
|
* SymbolOrderBook DoResyncAsync now returns CallResult instead of CallResult<bool> which was redundant
|
|
* PlatformInfo now required support environment names in the constructor
|
|
|
|
## Release notes
|
|
* Version 12.4.0 - 28 Jul 2026
|
|
* Added AveragePrice property to SharedQuantity model
|
|
* Added DebuggerDisplay attributes to Result objects
|
|
* Updated SharedFuturesTicker, SharedSpotTicker, SharedTrade and SharedKline to use SharedOrderQuantity for volumes/quantities
|
|
* Updated REST json deserialization error for empty response
|
|
|
|
* Version 12.3.0 - 23 Jul 2026
|
|
* Added calculation of AveragePrice on Shared order models if data is available and AveragePrice is not set
|
|
* Extracted ConnectionCanBeUsedFor method in SocketApiClient for easier custom logic implementation
|
|
* Updated some Shared APIs error messages
|
|
* Remove duplicate warnings from testing output
|
|
|
|
* Version 12.2.0 - 20 Jul 2026
|
|
* Added SpotSymbolCatalog to Shared ISpotSymbolRestClient interface
|
|
* Added FuturesSymbolCatalog to Shared IFuturesSymbolRestClient interface
|
|
* Added BaseAssetType, BaseAssetSubType, QuoteAssetType and QuoteAssetSubType to GetSymbolsRequest model
|
|
* Added DisplayName to SharedSpotSymbol and SharedFuturesSymbol models
|
|
* Added BaseAssetType, BaseAssetSubType, QuoteAssetType and QuoteAssetSubType to SharedSpotSymbol and SharedFuturesSymbol models
|
|
* Added IsStableCoin, IsCommodity and IsEquity helper methods to LibraryHelpers
|
|
* Added DebuggerDisplay attributes to Shared models
|
|
* Fixed socket connection combine calculations
|
|
|
|
* Version 12.1.1 - 11 Jul 2026
|
|
* Added timestamp deserialization support for yyyy-MM-dd HH:mm:ss.ffffff+00:00:00
|
|
|
|
* Version 12.1.0 - 09 Jul 2026
|
|
* Added ExchangeParameters parameter to KlineTracker, TradeTracker and ITrackerFactory methods
|
|
* Updated some testing logic
|
|
* Fixed nullability operator on Parameters.AddCommaSeperated
|
|
|
|
* Version 12.0.2 - 01 Jul 2026
|
|
* Updated test validation to output a list of issues instead of throwing on the first
|
|
|
|
* Version 12.0.1 - 29 Jun 2026
|
|
* Fixed bug in bool converter
|
|
|
|
* Version 12.0.0 - 29 Jun 2026
|
|
* Result types:
|
|
* (Web)CallResult types are replaced by HttpResult, WebSocketResult and QueryResult with the same logic
|
|
* Updated result types to record type
|
|
* Result creation can be done with (Http/WebSocket/Query)Result.Ok(..) and .Fail(..)
|
|
* Removed implicit result type conversion to bool, `if (result)` no longer works, instead use `if (result.Success)`
|
|
* Replaced CallResult.SuccessResult with CallResult.Ok()
|
|
* Fixed result object nullability hinting, for example Data might be null if Success isn't checked for true
|
|
* Parameters & serialization:
|
|
* Added support for `enabled` and `disabled` strings to bool converter
|
|
* Removed ParameterCollection type, has been replaced by Parameters type
|
|
* Removed ArraySerialization, OrderParameters and ParameterOrderComparer properties from RestApiClient, moved to ParameterSerializationsSettings
|
|
* Updated RestRequestConfiguration in AuthenticationProvider.ProcessRequest to contain the full RequestDefinition instead of copied fields
|
|
* Clients:
|
|
* Updated Api client constructor logging parameter from ILogger to ILoggerFactory?
|
|
* Added Api client constructor exchange name parameter
|
|
* Added ToString overrides on base API types
|
|
* Added Exchange property on BaseApiClient
|
|
* Added ApiCredentials property on IRestApiClient and ISocketApiClient interfaces
|
|
* Updated ILogger source from client name to topic specific client name
|
|
* Removed logging from client creation
|
|
* Fixed BaseRestClient SetApiCredentials not marked as virtual
|
|
* Rest:
|
|
* Added BaseAddress to RequestDefinition object
|
|
* Updated RestApiClient AuthenticationProvider logic from private to protected and virtual
|
|
* Removed RestApiClient.SendAsync baseAddress parameter removed
|
|
* Removed RestApiClient.SendAsync without type parameter
|
|
* WebSocket:
|
|
* Updated MessageRouting definition into CreateForEvent for subscriptions and CreateForQuery for queries
|
|
* Improved Query type safety with CeateForQuery which allows second parameter for specifying the result type
|
|
* Renamed MessageRouter.CreateWithoutHandler to CreateVoid
|
|
* Updated SocketApiClient.GetSocketConnection to check connection uri instead of Tag for finding compatible connections
|
|
* Removed unused UnhandledMessageExpected property SocketApiClient
|
|
* Fixed issue in SocketApiClient.GetSocketConnection causing requests to always wait the full max 10 seconds when there was a reconnecting socket
|
|
|
|
* Shared APIs:
|
|
* Updated Option definitions to always require the exchange name as first parameter
|
|
* Added missing dedicated option types
|
|
* Added Discover method on ISharedClient interface, returning info on supported capabilities and operations
|
|
* Added SharedRequest GetParamValue helper method accepting multiple parameter names
|
|
* Added ResetStaticExchangeParameters method on ExchangeParameters
|
|
* Added Status property to SharedWithdrawal model
|
|
* Added TradingModes property to SharedBalance model
|
|
* Updated ExchangeSymbolCache to support multiple environments and additional key separation
|
|
* Updated Shared ExchangeParameters parameter names to be case insensitive
|
|
* Updated code comments
|
|
* Replaced ExchangeResult with ExchangeCallResult type
|
|
* Removed AsExchangeResult/ExchangeWebResult
|
|
* Removed TradingMode from the response model, only maintained on models where it makes sense
|
|
* Removed IListenKey support, listen keys now rely on internal management with TokenManager
|
|
* Rate limiting:
|
|
* Fixed websocket connection attempts counting towards rate limit even when server could not be reached
|
|
* Removed host from rate limit methods, now part of the already provided RequestDefinition
|
|
* Added amount parameter to RateLimit Reset method to allow partially resetting the limit
|
|
* Added TokenManager implementation for automatic listenkey/token management
|
|
* Added UserClientProvider base class
|
|
* Added async streaming on UserDataTracker items with StreamUpdatesAsync
|
|
* Added cancellation token support to UserDataTracker starting
|
|
* Added Unit type for non-result types
|
|
* Added ServerError constructor taking ErrorType and message to make it easier to create
|
|
* Added SupportedEnvironments property to PlatformInfo
|
|
* Updated SymbolOrderBook DoResyncAsync to return CallResult instead of CallResult<bool> which was redundant
|
|
* Various small performance improvements
|