Mexc.Net

May 9, 2026 · View on GitHub

.NET License

Mexc.Net is a strongly typed client library for accessing the Mexc REST and Websocket API.

Features

  • Response data is mapped to descriptive models
  • Input parameters and response values are mapped to discriptive enum values where possible
  • High performance
  • Automatic websocket (re)connection management
  • Client side rate limiting
  • Client side order book implementation
  • Support for managing different accounts
  • Extensive logging
  • Support for different environments
  • Easy integration with other exchange client based on the CryptoExchange.Net base library
  • Native AOT support

Supported Frameworks

The library is targeting both .NET Standard 2.0 and .NET Standard 2.1 for optimal compatibility, as well as the latest dotnet versions to use the latest framework features.

.NET implementationVersion Support
.NET Core2.0 and higher
.NET Framework4.6.1 and higher
Mono5.4 and higher
Xamarin.iOS10.14 and higher
Xamarin.Android8.0 and higher
UWP10.0.16299 and higher
Unity2018.1 and higher

Install the library

NuGet

NuGet version Nuget downloads

dotnet add package JK.Mexc.Net

GitHub packages

Mexc.Net is available on GitHub packages. You'll need to add https://nuget.pkg.github.com/JKorf/index.json as a NuGet package source.

Download release

GitHub Release

The NuGet package files are added along side the source with the latest GitHub release which can found here.

How to use

Basic request:

// Get the ETH/USDT ticker via rest request
var restClient = new MexcRestClient();
var tickerResult = await restClient.SpotApi.ExchangeData.GetTickerAsync("ETHUSDT");
var lastPrice = tickerResult.Data.LastPrice;

Place order:

var restClient = new MexcRestClient(opts => {
	opts.ApiCredentials = new MexcCredentials("APIKEY", "APISECRET");
});

// Place Limit order to buy 0.1 ETH at 2000
var orderResult = await restClient.SpotApi.Trading.PlaceOrderAsync(
    "ETHUSDT",
    OrderSide.Buy,
    OrderType.Limit,
    quantity: 10,
    price: 2000
    );

WebSocket subscription:

// Subscribe to ETH/USDT ticker updates via the websocket API
var socketClient = new MexcSocketClient();
var tickerSubscriptionResult = socketClient.SpotApi.SubscribeToMiniTickerUpdatesAsync("ETHUSDT", (update) => 
{
  var lastPrice = update.Data.LastPrice;
});

For information on the clients, dependency injection, response processing and more see the Mexc.Net documentation or have a look at the examples here or here.

AI / LLM documentation

Mexc.Net includes AI-oriented documentation and examples for code generation tools:

FilePurpose
AGENTS.mdAgents skill instructions with core usage patterns and pitfalls
llms.txtShort LLM index with links to docs, examples, and critical usage rules
llms-full.txtDetailed LLM context with endpoint routing, code patterns, and anti-hallucination checks
docs/ai-api-map.mdIntent-to-method map for the actual Mexc.Net REST, WebSocket, and shared API surface
Examples/ai-friendlyCompilable single-file examples for common REST, WebSocket, shared API, and error handling workflows

GitHub Copilot and Cursor instructions are also provided in .github/copilot-instructions.md and .cursor/rules/mexc-net.mdc; both point back to the root AI context files.

CryptoExchange.Net

Mexc.Net is based on the CryptoExchange.Net base library. Other exchange API implementations based on the CryptoExchange.Net base library are available and follow the same logic.

CryptoExchange.Net also allows for easy access to different exchange API's.

ExchangeRepositoryNuget
AsterJKorf/Aster.NetNuget version
BinanceJKorf/Binance.NetNuget version
BingXJKorf/BingX.NetNuget version
BitfinexJKorf/Bitfinex.NetNuget version
BitgetJKorf/Bitget.NetNuget version
BitMartJKorf/BitMart.NetNuget version
BitMEXJKorf/BitMEX.NetNuget version
BitstampJKorf/Bitstamp.NetNuget version
BloFinJKorf/BloFin.NetNuget version
BybitJKorf/Bybit.NetNuget version
CoinbaseJKorf/Coinbase.NetNuget version
CoinExJKorf/CoinEx.NetNuget version
CoinGeckoJKorf/CoinGecko.NetNuget version
CoinWJKorf/CoinW.NetNuget version
Crypto.comJKorf/CryptoCom.NetNuget version
DeepCoinJKorf/DeepCoin.NetNuget version
Gate.ioJKorf/GateIo.NetNuget version
HTXJKorf/HTX.NetNuget version
HyperLiquidJKorf/HyperLiquid.NetNuget version
KrakenJKorf/Kraken.NetNuget version
KucoinJKorf/Kucoin.NetNuget version
OKXJKorf/OKX.NetNuget version
PolymarketJKorf/Polymarket.NetNuget version
ToobitJKorf/Toobit.NetNuget version
UpbitJKorf/Upbit.NetNuget version
WeexJKorf/Weex.NetNuget version
WhiteBitJKorf/WhiteBit.NetNuget version
XTJKorf/XT.NetNuget 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.

Supported functionality

Spot V3

APISupportedLocation
Market Data EndpointsrestClient.SpotApi.ExchangeData
SubAccount EndpointsrestClient.SpotApi.SubAccount
Acount/TraderestClient.SpotApi.Account / restClient.SpotApi.Trading
Wallet endpointsrestClient.SpotApi.Account
Websocket Market StreamssocketClient.SpotApi
Websocket User Data StreamssocketClient.SpotApi

Futures

APISupportedLocation
Market EndpointsrestClient.FuturesApi.ExchangeData
Account and trading EndpointsrestClient.FuturesApi.Account/restClient.FuturesApi.Trading
WebSocket PublicsocketClient.FuturesApi
WebSocket PrivatesocketClient.FuturesApi

Broker

APISupportedLocation
*X

Support the project

Any support is greatly appreciated.

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

Alternatively, sponsor me on Github using Github Sponsors.

Release notes

  • Version 5.1.3 - 06 May 2026

    • Improved stability order book starting/resyncing operations
  • Version 5.1.2 - 03 May 2026

    • Fixed restClient.FuturesApi.Trading.GetTriggerOrdersAsync status parameter serialization
    • Fixed restClient.FuturesApi.Trading.GetOrderHistoryAsync status parameter serialization
  • Version 5.1.1 - 01 May 2026

    • Fixed incorrect order status enum in MexcStopOrder and MexcFuturesTriggerOrder models
    • Fixed incorrect order status enum parameter in GetTriggerOrdersAsync endpoint
  • Version 5.1.0 - 01 May 2026

    • Added restClient.SpotApi.ExchangeData.GetOfflineSymbols endpoint
  • Version 5.0.1 - 09 Apr 2026

  • Version 5.0.0 - 01 Apr 2026

    • Added FuturesApi endpoints
    • Added FuturesApi SubscribeToSymbolUpdatesAsync websocket stream
    • Added missing FuturesApi user websocket stream callbacks
    • Added IFeeRestClient, IFuturesOrderRestClient and IFuturesTriggerOrderRestClient REST Shared implementations
    • Added IUserTradeSocketClient Socket Shared implementation
    • Added Futures UserDataTracker implementation
    • Updated existing FuturesApi endpoints
    • Fixed some issues in existing FuturesApi implementation
  • Version 4.9.0 - 24 Mar 2026

    • Updated CryptoExchange.Net to version 11.0.1, see https://github.com/JKorf/CryptoExchange.Net/releases/ for full release notes

    • Updated class for supplying API credentials from ApiCredentials to MexcCredentials

    • Updated Shared order status parsing to default to Unknown value if not parsable

    • Added support for specifying non-HMAC credentials via Configuration

    • Notes for updating:

      • Update ApiCredentials to MexcCredentials for authentication, i.e. ApiCredentials = new ApiCredentials(..) => ApiCredentials = new MexcCredentials(..)
      • When using AddMexc with the Configuration overload (loading config from appsettings), the API credentials path has been changed from ApiCredentials:Key to ApiCredentials:HMAC:Key (and secret)
  • Version 4.8.0 - 06 Mar 2026

  • Version 4.7.0 - 24 Feb 2026

    • Updated CryptoExchange.Net to version 10.7.0
    • Added additional Http settings to client options
    • Updated Shared REST interfaces pagination logic
    • Updated HttpClient registration, fixing issue of DNS changes not getting processed
    • Fixed UserClientProvider using unconfigured HttpClient
  • Version 4.6.0 - 16 Feb 2026

  • Version 4.5.0 - 10 Feb 2026

    • Updated CryptoExchange.Net to version 10.5.1, see https://github.com/JKorf/CryptoExchange.Net/releases/ for full release notes
    • Updated UserClientProvider internal client cache to non-static to prevent cleanup issues
    • Updated futures client subscription to not wait for unsub response Futures websocket as no confirmation is send
  • Version 4.4.0 - 06 Feb 2026

    • Updated CryptoExchange.Net to version 10.4.0, see https://github.com/JKorf/CryptoExchange.Net/releases/ for full release notes
    • Added MexcUserSpotDataTracker
    • Added additional methods for requesting supported symbols to Shared ISpotSymbolRestClient/IFuturesSymbolRestClient interfaces
    • Added PositionMode mapping on SharedPosition models
    • Added Status mapping for SharedDeposit models
    • Updated SpotApi GetOpenOrdersAsync() symbol parameter to an optional string
    • Updated PlaceOrder methods to normalize quantity and price to prevent scale/precision error
    • Fixed disposed clients getting returned from UserClientProvider
  • Version 4.3.2 - 26 Jan 2026

    • Fixed incorrect parsing of Timestamp field in user websocket order updates
  • Version 4.3.1 - 23 Jan 2026

    • Fixed CryptoExchange.Net reference
  • Version 4.3.0 - 22 Jan 2026

  • Version 4.2.2 - 19 Jan 2026

  • Version 4.2.1 - 14 Jan 2026

  • Version 4.2.0 - 13 Jan 2026

  • Version 4.1.0 - 07 Jan 2026

    • Updated CryptoExchange.Net version to 10.1.0, see https://github.com/JKorf/CryptoExchange.Net/releases/ for full release notes
    • Added DataTimeLocal and DataAge properties to DataEvent object
    • Added UpdateServerTime, UpdateLocalTime and DataAge properties to (I)SymbolOrderBook
    • Removed CryptoExchange.Net.Protobuf reference
  • Version 4.0.2 - 18 Dec 2025

    • Fixed inconsistent change percentage result between socketClient.SpotApi.SubscribeToAllMiniTickerUpdatesAsync and socketClient.SpotApi.SubscribeToMiniTickerUpdatesAsync updates
  • Version 4.0.1 - 18 Dec 2025

    • Added overloads for socketClient.SpotApi.SubscribeToMiniTickerUpdatesAsync specifying timezone, updated default to 24h ticker
  • Version 4.0.0 - 16 Dec 2025

    • Added Net10.0 target framework
    • Updated CryptoExchange.Net version to 10.0.0, see https://github.com/JKorf/CryptoExchange.Net/releases/ for full release notes
    • Improved performance across the board, biggest gains in websocket message processing
    • Updated REST message response handling
    • Updated WebSocket message handling
    • Switched to LightProto library direct reference from CryptoExchange.Net.Protobuf using protobuf-net for increased performance and maintainability
    • Added UseUpdatedDeserialization socket client options to toggle by new and old message handling
    • Added SocketIndividualSubscriptionCombineTarget socket client option
    • Added socketClient.SpotApi.SubscribeToMiniTickerUpdatesAsync stream
    • Added socketClient.SpotApi.SubscribeToAllMiniTickerUpdatesAsync stream
    • Added Shared API Spot SubscribeToAllTickersUpdatesAsync and SubscribeToTickerUpdatesAsync subscriptions
    • Updated Shared API's subscription update types from ExchangeEvent to DataEvent
    • Fixed socketClient.FuturesApi.SubscribeToTradeUpdatesAsync incorrectly having single trade type instead of array, causing deserialization issue
    • Fixed order book factory always creating spot book
  • Version 3.12.0 - 11 Nov 2025

  • Version 3.11.0 - 03 Nov 2025

    • Updated CryptoExchange.Net to version 9.12.0
    • Added SubAccount API implementation
    • Added missing Shared futures interfaces DI registration
    • Added support for using SharedSymbol.UsdOrStable in Shared APIs
    • Fixed exception when initial trade snapshot has no items in TradeTracker
    • Removed some unhelpful verbose logs
  • Version 3.10.0 - 16 Oct 2025

    • Updated CryptoExchange.Net version to 9.10.0, see https://github.com/JKorf/CryptoExchange.Net/releases/
    • Added ClientOrderId mapping on SharedUserTrade models
    • Added ITransferRestClient.TransferAsync implementation
    • Fixed restClient.SpotApi.Account.TransferAsync endpoint
  • Version 3.9.0 - 30 Sep 2025

  • Version 3.8.0 - 01 Sep 2025

  • Version 3.7.0 - 25 Aug 2025

  • Version 3.6.0 - 20 Aug 2025

    • Updated CryptoExchange.Net to version 9.5.0, see https://github.com/JKorf/CryptoExchange.Net/releases/
    • Added improved error parsing
    • Updated rest request sending too prevent duplicate parameter serialization
    • Removed miniticker spot API subscription as it's no longer supported
  • Version 3.5.0 - 04 Aug 2025

  • Version 3.4.0 - 31 Jul 2025

    • Added futures REST and Websocket API implementation (exluding order operations since the API for it is disabled)
  • Version 3.3.0 - 23 Jul 2025

  • Version 3.2.0 - 14 Jul 2025

    • Updated from CryptoExchange.Net version 9.1.0 to CryptoExchange.Net.Protobuf version 9.2.0, see https://github.com/JKorf/CryptoExchange.Net/releases/
    • Added updateInterval parameter to socketClient.SpotApi.SubscribeToTradeUpdatesAsync and SubscribeToOrderBookUpdatesAsync subscriptions
    • Added socketClient.SpotApi.SubscribeToOrderBookUpdatesAsync subscription
    • Added check for listenKey being null to subscription requiring a listenKey
    • Updated spot websocket implementation to use the protobuf protocol
  • Version 3.1.1 - 20 Jun 2025

    • Fixed mapping of ClientOrderId in restClient.SpotApi.Trading.PlaceMultipleOrdersAsync response
  • Version 3.1.0 - 02 Jun 2025

  • Version 3.0.0 - 13 May 2025

    • Updated CryptoExchange.Net to version 9.0.0, see https://github.com/JKorf/CryptoExchange.Net/releases/
    • Added support for Native AOT compilation
    • Added RateLimitUpdated event
    • Added SharedSymbol response property to all Shared interfaces response models returning a symbol name
    • Added GenerateClientOrderId method to Spot Shared client
    • Added IBookTickerRestClient implementation to SpotApi Shared clients
    • Added TriggerPrice property to SharedSpotOrder model
    • Added OptionalExchangeParameters and Supported properties to EndpointOptions
    • Added restClient.SpotApi.Trading.PlaceMultipleOrdersAsync endpoint
    • Added restClient.SpotApi.ExchangeData.GetBookPricesAsync endpoint for single symbol
    • Added QuoteVolume property mapping to SharedSpotTicker model
    • Added All property to retrieve all available environment on MexcEnvironment
    • Refactored Shared clients quantity parameters and responses to use SharedQuantity
    • Updated all IEnumerable response and model types to array response types
    • Removed Newtonsoft.Json dependency
    • Removed legacy ISpotClient implementation
    • Removed legacy AddMexc(restOptions, socketOptions) DI overload
    • Fixed some typos
    • Fixed AveragePrice being return 0 instead of null for Shared order updates
  • Version 3.0.0-beta3 - 01 May 2025

    • Updated CryptoExchange.Net version to 9.0.0-beta5
    • Added property to retrieve all available API environments
  • Version 3.0.0-beta2 - 23 Apr 2025

    • Updated CryptoExchange.Net to version 9.0.0-beta2
    • Added Shared spot ticker QuoteVolume mapping
  • Version 3.0.0-beta1 - 22 Apr 2025

    • Updated CryptoExchange.Net to version 9.0.0-beta1, see https://github.com/JKorf/CryptoExchange.Net/releases/
    • Added support for Native AOT compilation
    • Added RateLimitUpdated event
    • Added SharedSymbol response property to all Shared interfaces response models returning a symbol name
    • Added GenerateClientOrderId method to Spot Shared client
    • Added IBookTickerRestClient implementation to SpotApi Shared clients
    • Added TriggerPrice property to SharedSpotOrder model
    • Added OptionalExchangeParameters and Supported properties to EndpointOptions
    • Added restClient.SpotApi.Trading.PlaceMultipleOrdersAsync endpoint
    • Added restClient.SpotApi.ExchangeData.GetBookPricesAsync endpoint for single symbol
    • Refactored Shared clients quantity parameters and responses to use SharedQuantity
    • Updated all IEnumerable response and model types to array response types
    • Removed Newtonsoft.Json dependency
    • Removed legacy ISpotClient implementation
    • Removed legacy AddMexc(restOptions, socketOptions) DI overload
    • Fixed restClient.SpotApi.ExchangeData.GetKlinesAsync returning signature error
    • Fixed some typos
  • Version 2.1.0 - 11 Feb 2025

    • Updated CryptoExchange.Net to version 8.8.0, see https://github.com/JKorf/CryptoExchange.Net/releases/
    • Added support for more SharedKlineInterval values
    • Added setting of DataTime value on websocket DataEvent updates
    • Fix Mono runtime exception on rest client construction using DI
  • Version 2.0.0 - 24 Jan 2025

  • Version 1.15.2 - 22 Jan 2025

    • Added restClient.SpotApi.Account.TransferInternalAsync endpoint
    • Added restClient.SpotApi.Account.GetInternalTransferHistoryAsync endpoint
  • Version 1.15.1 - 07 Jan 2025

    • Updated CryptoExchange.Net version
    • Added Type property to MexcExchange class
  • Version 1.15.0 - 23 Dec 2024

    • Updated CryptoExchange.Net to version 8.5.0, see https://github.com/JKorf/CryptoExchange.Net/releases/
    • Added SetOptions methods on Rest and Socket clients
    • Added setting of DefaultProxyCredentials to CredentialCache.DefaultCredentials on the DI http client
    • Improved websocket disconnect detection
  • Version 1.14.1 - 20 Dec 2024

    • Fixed deserialization of too large decimal values in Ticker and Kline models
  • Version 1.14.0 - 13 Dec 2024

    • Fixed typo in MexcAggregatedTrade and MexcKline models
    • Fix for restClient.SpotApi.Account.WithdrawAsync deserialization
  • Version 1.13.1 - 03 Dec 2024

  • Version 1.13.0 - 28 Nov 2024

    • Updated CryptoExchange.Net to version 8.4.0, see https://github.com/JKorf/CryptoExchange.Net/releases/tag/8.4.0
    • Added GetFeesAsync Shared REST client implementations
    • Updated MexcOptions to LibraryOptions implementation
    • Updated test and analyzer package versions
    • Fixed some deserialization issues on decimal larger than Decimal.MaxValue on websocket streams
  • Version 1.12.0 - 19 Nov 2024

    • Updated CryptoExchange.Net to version 8.3.0, see https://github.com/JKorf/CryptoExchange.Net/releases/tag/8.3.0
    • Added support for loading client settings from IConfiguration
    • Added DI registration method for configuring Rest and Socket options at the same time
    • Added DisplayName and ImageUrl properties to MexcExchange class
    • Updated client constructors to accept IOptions from DI
    • Removed redundant MexcSocketClient constructor
  • Version 1.11.0 - 06 Nov 2024

  • Version 1.10.0 - 28 Oct 2024

    • Updated CryptoExchange.Net to version 8.1.0, see https://github.com/JKorf/CryptoExchange.Net/releases/tag/8.1.0
    • Moved FormatSymbol to MexcExchange class
    • Added support Side setting on SharedTrade model
    • Added MexcTrackerFactory for creating trackers
    • Added overload to Create method on MexcOrderBookFactory support SharedSymbol parameter
  • Version 1.9.0 - 22 Oct 2024

    • Added mexcRestClient.SpotApi.Account.GetKycStatusAsync endpoint
    • Added ListenkeyRenewed event to socketClient.SpotApi client so users can react to updated listenkeys for keep-alive caused by reconnecting
  • Version 1.8.2 - 14 Oct 2024

  • Version 1.8.1 - 14 Oct 2024

    • Fixed cancellation token not being passed to subscribe method in Shared client
  • Version 1.8.0 - 27 Sep 2024

    • Updated CryptoExchange.Net to version 8.0.0, see https://github.com/JKorf/CryptoExchange.Net/releases/tag/8.0.0
    • Added Shared client interfaces implementation for Spot Rest and Socket clients
    • Added QuoteQuantity property to MexcOrder model
    • Updated KlineInterval Enum values to match number of seconds
    • Updated Sourcelink package version
    • Marked ISpotClient references as deprecated
  • Version 1.7.2 - 08 Aug 2024

    • Fixed SpotApi.Account.GetUserAssetsAsync deserialization due to too large number being returned
  • Version 1.7.1 - 08 Aug 2024

    • Fixed deserialization issues caused by too big number value
  • Version 1.7.0 - 07 Aug 2024

  • Version 1.6.0 - 27 Jul 2024

  • Version 1.5.0 - 16 Jul 2024

  • Version 1.4.1 - 02 Jul 2024

  • Version 1.4.0 - 23 Jun 2024

  • Version 1.3.0 - 11 Jun 2024

  • Version 1.2.5 - 02 Jun 2024

    • Added SpotApi.Account.GetTradeFeeAsync endpoint
  • Version 1.2.4 - 07 May 2024

  • Version 1.2.3 - 01 May 2024

  • Version 1.2.2 - 28 Apr 2024

  • Version 1.2.1 - 23 Apr 2024

  • Version 1.2.0 - 18 Apr 2024

  • Version 1.1.1 - 24 Mar 2024

  • Version 1.1.0 - 16 Mar 2024

  • Version 1.0.1 - 28 Feb 2024

    • Fixed SpotApi.Trading.GetAccountInfoAsync deserialization
    • Renamed OrderType on MexcOrder model to Type
    • Renamed OrderSide on MexcOrderUpdate to Side
  • Version 1.0.0 - 25 Feb 2024

    • Initial release