### Install the MEXC Python SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/python.md Clone the MEXC API demo repository and navigate to the Python directory to get started with the SDK. ```bash # Clone the repository git clone https://github.com/mexcdevelop/mexc-api-demo.git cd mexc-api-demo/python ``` -------------------------------- ### All Orders Response Example Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/trading.md Example response for the GET /api/v3/allOrders endpoint, showing a single filled order. ```json [ { "symbol": "BTCUSDT", "orderId": 28, "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP", "price": "0.00000000", "origQty": "10.00000000", "executedQty": "0.00000000", "status": "FILLED", "timeInForce": "GTC", "type": "LIMIT", "side": "SELL", "stopPrice": "0.00000000", "time": 1499827319559, "updateTime": 1499827319559, "isWorking": true } ] ``` -------------------------------- ### Account Information Response Example Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/account.md Example response for the GET /api/v3/account endpoint. Shows commission rates, trading permissions, account type, and a balances array with free and locked amounts for each asset. ```json { "makerCommission": 15, "takerCommission": 15, "buyerCommission": 0, "sellerCommission": 0, "canTrade": true, "canWithdraw": true, "canDeposit": true, "updateTime": 123456789, "accountType": "SPOT", "balances": [ { "asset": "BTC", "free": "4723846.89208129", "locked": "0.00000000" }, { "asset": "USDT", "free": "1.00000000", "locked": "0.00000000" } ], "permissions": [ "SPOT" ] } ``` -------------------------------- ### Install MEXC Go SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/go.md Clone the MEXC Go SDK repository and install its dependencies using Go modules. ```bash git clone https://github.com/mexcdevelop/mexc-api-demo.git cd mexc-api-demo/go go mod download ``` -------------------------------- ### Open Orders Response Example Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/trading.md Example response for the GET /api/v3/openOrders endpoint, showing a single open order with status NEW. ```json [ { "symbol": "BTCUSDT", "orderId": 28, "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP", "price": "0.00000000", "origQty": "10.00000000", "executedQty": "0.00000000", "status": "NEW", "timeInForce": "GTC", "type": "LIMIT", "side": "SELL", "stopPrice": "0.00000000", "time": 1499827319559, "updateTime": 1499827319559, "isWorking": true } ] ``` -------------------------------- ### Install MEXC Node.js SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/nodejs.md Clone the MEXC API demo repository and install dependencies for the Node.js SDK. ```bash # Clone the repository git clone https://github.com/mexcdevelop/mexc-api-demo.git cd mexc-api-demo/node.js # Install dependencies npm install ``` -------------------------------- ### Clone MEXC Java SDK Repository Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/java.md Clone the MEXC API demo repository and navigate to the Java directory to get started. ```bash # Clone the repository git clone https://github.com/mexcdevelop/mexc-api-demo.git cd mexc-api-demo/Java ``` -------------------------------- ### Account Trade List Response Example Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/account.md Example response for the GET /api/v3/myTrades endpoint. Contains trade details such as symbol, price, quantity, commission, and flags indicating buyer/maker status. ```json [ { "symbol": "BTCUSDT", "id": 28457, "orderId": 100234, "price": "4.00000100", "qty": "12.00000000", "commission": "10.10000000", "commissionAsset": "BTC", "time": 1499865549590, "isBuyer": true, "isMaker": false, "isBestMatch": true } ] ``` -------------------------------- ### Authenticated curl request to MEXC API Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/authentication.md Example curl command to make an authenticated GET request to the MEXC API. Includes the required headers: X-MEXC-APIKEY, X-MEXC-SIGNATURE, and X-MEXC-TIMESTAMP. ```bash curl -X GET 'https://api.mexc.com/api/v3/account' \ -H "X-MEXC-APIKEY: your_api_key" \ -H "X-MEXC-SIGNATURE: generated_signature" \ -H "X-MEXC-TIMESTAMP: timestamp" ``` -------------------------------- ### Response ACK Example for New Order Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/futures/trading.md Example JSON response when newOrderRespType is ACK (default). Shows order details such as orderId, symbol, status, and clientOrderId. ```javascript { "code": 0, "message": "success", "data": { "orderId": 123456789, "symbol": "BTCUSDT", "status": "NEW", "clientOrderId": "abc123", "price": "10000", "origQty": "1", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "side": "BUY", "stopPrice": "0", "time": 1499827319559 } } ``` -------------------------------- ### Trading Examples for MEXC Java SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/java.md Place a limit buy order and retrieve account information using the UserDataClient methods. ```java // Place Order public void placeOrder() { try { Map params = new HashMap<>(); params.put("symbol", "BTC-USDT"); params.put("side", "BUY"); params.put("type", "LIMIT"); params.put("quantity", "0.001"); params.put("price", "30000"); String response = userDataClient.newOrder(params); System.out.println("Order Response: " + response); } catch (Exception e) { e.printStackTrace(); } } // Get Account Information public void getAccountInfo() { try { String response = userDataClient.accountInformation(); System.out.println("Account Info: " + response); } catch (Exception e) { e.printStackTrace(); } } ``` -------------------------------- ### Get Current Open Orders (GET /api/v3/openOrders) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/trading.md Retrieves all open orders for a symbol. Requires the symbol parameter and has a weight of 3. ```http GET /api/v3/openOrders ``` -------------------------------- ### GET /api/v3/account Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/account.md Retrieves the current account information including balances, commissions, and permissions. ```APIDOC ## GET /api/v3/account ### Description Get current account information. ### Method GET ### Endpoint /api/v3/account ### Parameters #### Query Parameters - **recvWindow** (LONG) - Optional - Request timeout in milliseconds ### Response #### Success Response (200) - **makerCommission** (number) - Maker commission rate - **takerCommission** (number) - Taker commission rate - **buyerCommission** (number) - Buyer commission rate - **sellerCommission** (number) - Seller commission rate - **canTrade** (boolean) - Whether trading is allowed - **canWithdraw** (boolean) - Whether withdrawals are allowed - **canDeposit** (boolean) - Whether deposits are allowed - **updateTime** (number) - Last update time in milliseconds - **accountType** (string) - Account type (e.g., SPOT) - **balances** (array) - List of asset balances - **asset** (string) - Asset symbol - **free** (string) - Available balance - **locked** (string) - Locked balance - **permissions** (array) - List of permissions (e.g., SPOT) #### Response Example { "makerCommission": 15, "takerCommission": 15, "buyerCommission": 0, "sellerCommission": 0, "canTrade": true, "canWithdraw": true, "canDeposit": true, "updateTime": 123456789, "accountType": "SPOT", "balances": [ { "asset": "BTC", "free": "4723846.89208129", "locked": "0.00000000" }, { "asset": "USDT", "free": "1.00000000", "locked": "0.00000000" } ], "permissions": [ "SPOT" ] } ``` -------------------------------- ### Check Server Time Response Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/futures/market.md Example response from the /api/v1/time endpoint, containing the server time in milliseconds. ```javascript { "serverTime": 1499827319559 } ``` -------------------------------- ### GET /api/v1/account Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/futures/account.md Retrieves the current account information including balances, margin details, and trading permissions. ```APIDOC ## GET /api/v1/account ### Description Get current account information. ### Method GET ### Endpoint /api/v1/account ### Authentication HMAC SHA256 ### Parameters #### Query Parameters - **recvWindow** (LONG) - Optional - The value cannot be greater than 60000 - **timestamp** (LONG) - Required - ### Response #### Success Response (200) - **feeTier** (number) - Account commission tier - **canTrade** (boolean) - if can trade - **canDeposit** (boolean) - if can deposit - **canWithdraw** (boolean) - if can withdraw - **updateTime** (number) - - **totalInitialMargin** (string) - Total initial margin required - **totalMaintMargin** (string) - Total maintenance margin required - **totalWalletBalance** (string) - Total wallet balance - **totalUnrealizedProfit** (string) - Total unrealized profit - **totalMarginBalance** (string) - Total margin balance - **totalPositionInitialMargin** (string) - Total position initial margin - **totalOpenOrderInitialMargin** (string) - Total open order initial margin - **totalCrossWalletBalance** (string) - Total cross wallet balance - **totalCrossUnPnl** (string) - Total cross unrealized PnL - **availableBalance** (string) - Available balance - **maxWithdrawAmount** (string) - Maximum amount for transfer out #### Response Example ```json { "feeTier": 0, "canTrade": true, "canDeposit": true, "canWithdraw": true, "updateTime": 123456789, "totalInitialMargin": "0.00000000", "totalMaintMargin": "0.00000000", "totalWalletBalance": "23.72469206", "totalUnrealizedProfit": "0.00000000", "totalMarginBalance": "23.72469206", "totalPositionInitialMargin": "0.00000000", "totalOpenOrderInitialMargin": "0.00000000", "totalCrossWalletBalance": "23.72469206", "totalCrossUnPnl": "0.00000000", "availableBalance": "23.72469206", "maxWithdrawAmount": "23.72469206" } ``` ``` -------------------------------- ### Trading Examples (PlaceOrder, GetAccountInfo) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/dotnet.md Demonstrates placing a limit buy order for BTC-USDT and retrieving account information. PlaceOrderAsync expects a dictionary with symbol, side, type, quantity, and price; GetAccountInfoAsync returns account details. ```csharp public class TradingExample { private readonly MexcService _service; public TradingExample(string apiKey, string apiSecret) { _service = new MexcService(apiKey, apiSecret); } public async Task PlaceOrder() { try { var parameters = new Dictionary { { "symbol", "BTC-USDT" }, { "side", "BUY" }, { "type", "LIMIT" }, { "quantity", "0.001" }, { "price", "30000" } }; var response = await _service.PlaceOrderAsync(parameters); Console.WriteLine($"Order Response: {response}"); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } } public async Task GetAccountInfo() { try { var response = await _service.GetAccountInfoAsync(); Console.WriteLine($"Account Info: {response}"); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } } } ``` -------------------------------- ### Initialize Spot Client Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/nodejs.md Create a Spot client instance with your API key and secret to interact with the MEXC Spot Trading API. ```javascript const { Spot } = require('./src/modules'); const client = new Spot({ apiKey: 'your_api_key', apiSecret: 'your_api_secret' }); ``` -------------------------------- ### Clone and Build .NET SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/dotnet.md Clone the MEXC API demo repository and build the .NET project. Requires Git and .NET SDK installed. ```bash # Clone the repository git clone https://github.com/mexcdevelop/mexc-api-demo.git cd mexc-api-demo/dotnet # Build the project dotnet build ``` -------------------------------- ### Configure MEXC Go SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/go.md Initialize the MEXC Go SDK configuration with your API key, secret key, and the base URL for the Spot Trading API. ```go package main import ( "github.com/mexcdevelop/mexc-api-demo/go/config" ) func main() { cfg := &config.Config{ ApiKey: "your_api_key", SecretKey: "your_api_secret", BaseURL: "https://api.mexc.com", } } ``` -------------------------------- ### Market Data Examples (GetExchangeInfo, GetTickerPrice, GetOrderBook) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/dotnet.md Shows how to call market data endpoints: GetExchangeInfoAsync, GetTickerPriceAsync, and GetOrderBookAsync. Each method wraps the call in a try-catch and prints the response or error message. ```csharp public class MarketDataExample { private readonly MexcService _service; public MarketDataExample(string apiKey, string apiSecret) { _service = new MexcService(apiKey, apiSecret); } public async Task GetExchangeInfo() { try { var response = await _service.GetExchangeInfoAsync(); Console.WriteLine($"Exchange Info: {response}"); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } } public async Task GetSymbolPrice(string symbol) { try { var response = await _service.GetTickerPriceAsync(symbol); Console.WriteLine($"Price: {response}"); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } } public async Task GetOrderBook(string symbol, int limit) { try { var response = await _service.GetOrderBookAsync(symbol, limit); Console.WriteLine($"Order Book: {response}"); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } } } ``` -------------------------------- ### Get Market Data with the MEXC Spot SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/python.md Initialize the SDK client with your API credentials and fetch exchange information, symbol price, and order book. ```python # Get Exchange Information from spot.mexc_spot_v3 import mexc_spot_v3 client = mexc_spot_v3( api_key='your_api_key', api_secret='your_api_secret' ) # Get Exchange Info response = client.exchange_info() print(response) # Get Symbol Price response = client.price('BTC-USDT') print(response) # Get Order Book response = client.depth('BTC-USDT', limit=10) print(response) ``` -------------------------------- ### GET /api/v3/broker/sub-account/list Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/broker/subaccount.md Get a list of all sub-accounts under the broker account. ```APIDOC ## GET /api/v3/broker/sub-account/list ### Description Get a list of all sub-accounts under the broker account. ### Method GET ### Endpoint /api/v3/broker/sub-account/list ### Authentication HMAC SHA256 ### Weight 1 ### Parameters #### Query Parameters - **subAccount** (STRING) - Optional - Filter by sub-account name - **page** (INT) - Optional - Default 1 - **limit** (INT) - Optional - Default 10, Max 200 - **timestamp** (LONG) - Required - Timestamp - **signature** (STRING) - Required - HMAC SHA256 signature ### Response #### Success Response (200) - **code** (STRING) - Response code - **message** (STRING) - Response message - **data** (ARRAY) - Response data - **subAccount** (STRING) - Sub-account name - **note** (STRING) - Note for the sub-account - **timestamp** (STRING) - Timestamp #### Response Example ```javascript { "code": "0", "message": "", "data": [{ "subAccount": "mexc1", "note": "1", "timestamp": "1597026383085" }, { "subAccount": "mexc2", "note": "2", "timestamp": "1597026383787" }] } ``` ``` -------------------------------- ### GET /api/v3/broker/sub-account/tradingSummary Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/broker/account.md Get trading summary of a sub-account. Requires HMAC SHA256 signature. ```APIDOC ## [GET] /api/v3/broker/sub-account/tradingSummary ### Description Get trading summary of a sub-account. ### Method GET ### Endpoint /api/v3/broker/sub-account/tradingSummary ### Parameters #### Query Parameters - **subAccount** (STRING) - Required - The sub-account to query - **startTime** (LONG) - Optional - Start time - **endTime** (LONG) - Optional - End time - **timestamp** (LONG) - Required - - **signature** (STRING) - Required - HMAC SHA256 signature ### Response #### Success Response (200) - **totalTrades** (INT) - Total number of trades - **totalVolume** (STRING) - Total trading volume - **totalCommission** (STRING) - Total commission - **commissionAsset** (STRING) - Commission asset - **startTime** (LONG) - Start time - **endTime** (LONG) - End time #### Response Example { "totalTrades": 100, "totalVolume": "1000.0", "totalCommission": "1.5", "commissionAsset": "USDT", "startTime": 1656408193478, "endTime": 1656494593478 } ``` -------------------------------- ### GET /api/v1/time Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/futures/market.md Test connectivity to the Rest API and get the current server time. ```APIDOC ## GET /api/v1/time ### Description Test connectivity to the Rest API and get the current server time. ### Method GET ### Endpoint /api/v1/time ### Parameters None ### Response #### Success Response (200) - **serverTime** (number) - The current server time in milliseconds since Unix epoch. #### Response Example ```javascript { "serverTime": 1499827319559 } ``` ``` -------------------------------- ### Check Server Time - GET /api/v3/time Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/market.md Gets the current server time. No parameters are required. ```http GET /api/v3/time ``` -------------------------------- ### Place Order and Get Account Info with MEXC Go SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/go.md Place a limit buy order for BTC-USDT and retrieve account information using the MEXC Go SDK. ```go package main import ( "fmt" "github.com/mexcdevelop/mexc-api-demo/go/config" "github.com/mexcdevelop/mexc-api-demo/go/utils" ) func main() { cfg := &config.Config{ ApiKey: "your_api_key", SecretKey: "your_api_secret", BaseURL: "https://api.mexc.com", } // Place Order order := map[string]string{ "symbol": "BTC-USDT", "side": "BUY", "type": "LIMIT", "quantity": "0.001", "price": "30000", } result, err := utils.PlaceOrder(cfg, order) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Order Result: %+v\n", result) // Get Account Information account, err := utils.GetAccountInfo(cfg) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Account Info: %+v\n", account) } ``` -------------------------------- ### GET /api/v3/time Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/market.md Get the current server time. This endpoint requires no parameters and returns the server time in milliseconds. ```APIDOC ## GET /api/v3/time ### Description Get the current server time. ### Method GET ### Endpoint /api/v3/time ### Parameters None ### Response #### Success Response (200) - **serverTime** (integer) - The current server time in milliseconds since the Unix epoch. #### Response Example ```json { "serverTime": 1499827319559 } ``` ``` -------------------------------- ### Initialize MEXC Java SDK Clients Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/java.md Initialize the MarketDataClient and UserDataClient with your API key and secret for making authenticated requests. ```java import com.mexc.example.common.MarketDataClient; import com.mexc.example.common.UserDataClient; public class MexcApiExample { private static final String API_KEY = "your_api_key"; private static final String API_SECRET = "your_api_secret"; private final MarketDataClient marketDataClient; private final UserDataClient userDataClient; public MexcApiExample() { this.marketDataClient = new MarketDataClient(); this.userDataClient = new UserDataClient(API_KEY, API_SECRET); } } ``` -------------------------------- ### Initialize MexcService Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/dotnet.md Initializes the MexcService with API credentials and sets the base URL to https://api.mexc.com. Use this as the foundation for all other MEXC API calls. ```csharp using System; using System.Collections.Generic; using System.Threading.Tasks; public class MexcService { private readonly string _apiKey; private readonly string _apiSecret; private readonly string _baseUrl; public MexcService(string apiKey, string apiSecret) { _apiKey = apiKey; _apiSecret = apiSecret; _baseUrl = "https://api.mexc.com"; } } ``` -------------------------------- ### WebSocket Client Implementation and Usage Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/dotnet.md Implements a WebSocket client using WebSocket4Net to connect to wss://wss.mexc.com/ws. Subscribe sends a SUBSCRIPTION message with the channel; the example subscribes to spot@public.deals.v3.api@BTCUSDT and keeps the app running with Task.Delay(-1). ```csharp using WebSocket4Net; using Newtonsoft.Json; public class WebSocketClient : IDisposable { private readonly WebSocket _webSocket; private readonly string _url = "wss://wss.mexc.com/ws"; public WebSocketClient() { _webSocket = new WebSocket(_url); _webSocket.Opened += WebSocketOnOpened; _webSocket.Error += WebSocketOnError; _webSocket.Closed += WebSocketOnClosed; _webSocket.MessageReceived += WebSocketOnMessageReceived; } public void Connect() { _webSocket.Open(); } public void Subscribe(string channel) { var message = new { method = "SUBSCRIPTION", @params = new[] { channel } }; _webSocket.Send(JsonConvert.SerializeObject(message)); } private void WebSocketOnOpened(object sender, EventArgs e) { Console.WriteLine("WebSocket connected"); } private void WebSocketOnError(object sender, SuperSocket.ClientEngine.ErrorEventArgs e) { Console.WriteLine($"WebSocket error: {e.Exception.Message}"); } private void WebSocketOnClosed(object sender, EventArgs e) { Console.WriteLine("WebSocket closed"); } private void WebSocketOnMessageReceived(object sender, MessageReceivedEventArgs e) { Console.WriteLine($"Received: {e.Message}"); } public void Dispose() { _webSocket?.Dispose(); } } // Usage Example public class Program { public static async Task Main() { using var client = new WebSocketClient(); client.Connect(); client.Subscribe("spot@public.deals.v3.api@BTCUSDT"); // Keep the application running await Task.Delay(-1); } } ``` -------------------------------- ### Get Latest Price with GET /api/v3/ticker/price Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/market.md Retrieves the latest price for a single symbol or multiple symbols. The symbol and symbols parameters are optional. ```http GET /api/v3/ticker/price ``` -------------------------------- ### Market Data Examples for MEXC Java SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/java.md Retrieve exchange information, symbol price, and order book data using the MarketDataClient methods. ```java // Get Exchange Information public void getExchangeInfo() { try { String response = marketDataClient.exchangeInformation(); System.out.println("Exchange Info: " + response); } catch (Exception e) { e.printStackTrace(); } } // Get Symbol Price public void getSymbolPrice(String symbol) { try { String response = marketDataClient.tickerPrice(symbol); System.out.println("Price: " + response); } catch (Exception e) { e.printStackTrace(); } } // Get Order Book public void getOrderBook(String symbol, Integer limit) { try { String response = marketDataClient.orderBook(symbol, limit); System.out.println("Order Book: " + response); } catch (Exception e) { e.printStackTrace(); } } ``` -------------------------------- ### Place and Cancel Orders with the MEXC Spot SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/python.md Place a limit buy order, cancel it using the returned order ID, and get account information. ```python # Place Order order = client.place_order( symbol='BTC-USDT', side='BUY', order_type='LIMIT', quantity=0.001, price=30000 ) print(order) # Cancel Order result = client.cancel_order( symbol='BTC-USDT', order_id=order['orderId'] ) print(result) # Get Account Information account = client.account_info() print(account) ``` -------------------------------- ### Get All Orders (GET /api/v3/allOrders) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/trading.md Retrieves all account orders (active, canceled, or filled) for a symbol. Requires the symbol parameter and has a weight of 10. ```http GET /api/v3/allOrders ``` -------------------------------- ### Exchange Information - GET /api/v3/exchangeInfo Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/market.md Gets current exchange trading rules and symbol information. Optional parameters: symbol (STRING) and symbols (Array). ```http GET /api/v3/exchangeInfo ``` -------------------------------- ### Query Sub-account Trading Summary - GET /api/v3/broker/sub-account/tradingSummary Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/broker/account.md Get trading summary of a sub-account. Weight: 1. Requires subAccount, timestamp, and signature; optional startTime and endTime. ```http GET /api/v3/broker/sub-account/tradingSummary (HMAC SHA256) ``` -------------------------------- ### GET /api/v3/exchangeInfo Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/market.md Get current exchange trading rules and symbol information. This endpoint accepts optional symbol and symbols parameters and returns detailed exchange information including rate limits and symbol filters. ```APIDOC ## GET /api/v3/exchangeInfo ### Description Get current exchange trading rules and symbol information. ### Method GET ### Endpoint /api/v3/exchangeInfo ### Parameters #### Query Parameters - **symbol** (STRING) - Optional - Trading symbol, e.g. "BTCUSDT". - **symbols** (Array) - Optional - Array of trading symbols. ### Response #### Success Response (200) - **timezone** (string) - The timezone of the exchange. - **serverTime** (integer) - The current server time in milliseconds. - **rateLimits** (array) - Array of rate limit objects. - **rateLimitType** (string) - The type of rate limit. - **interval** (string) - The interval for the rate limit. - **intervalNum** (integer) - The interval number. - **limit** (integer) - The rate limit value. - **symbols** (array) - Array of symbol information objects. - **symbol** (string) - The trading symbol. - **status** (string) - The status of the symbol (e.g., TRADING). - **baseAsset** (string) - The base asset. - **baseAssetPrecision** (integer) - The precision of the base asset. - **quoteAsset** (string) - The quote asset. - **quotePrecision** (integer) - The precision of the quote asset. - **orderTypes** (array) - Array of supported order types. - **filters** (array) - Array of filter objects. - **filterType** (string) - The type of filter (e.g., PRICE_FILTER, LOT_SIZE). - **minPrice** (string) - The minimum price (for PRICE_FILTER). - **maxPrice** (string) - The maximum price (for PRICE_FILTER). - **tickSize** (string) - The tick size (for PRICE_FILTER). - **minQty** (string) - The minimum quantity (for LOT_SIZE). - **maxQty** (string) - The maximum quantity (for LOT_SIZE). - **stepSize** (string) - The step size (for LOT_SIZE). #### Response Example ```json { "timezone": "UTC", "serverTime": 1565246363776, "rateLimits": [ { "rateLimitType": "REQUEST_WEIGHT", "interval": "MINUTE", "intervalNum": 1, "limit": 1200 } ], "symbols": [ { "symbol": "BTCUSDT", "status": "TRADING", "baseAsset": "BTC", "baseAssetPrecision": 8, "quoteAsset": "USDT", "quotePrecision": 8, "orderTypes": [ "LIMIT", "MARKET", "LIMIT_MAKER" ], "filters": [ { "filterType": "PRICE_FILTER", "minPrice": "0.01", "maxPrice": "100000.00", "tickSize": "0.01" }, { "filterType": "LOT_SIZE", "minQty": "0.00001", "maxQty": "10000.00000", "stepSize": "0.00001" } ] } ] } ``` ``` -------------------------------- ### Get Market Data with MEXC Go SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/go.md Fetch exchange information, symbol price, and order book depth for BTC-USDT using the MEXC Go SDK utility functions. ```go package main import ( "fmt" "github.com/mexcdevelop/mexc-api-demo/go/config" "github.com/mexcdevelop/mexc-api-demo/go/utils" ) func main() { cfg := &config.Config{ ApiKey: "your_api_key", SecretKey: "your_api_secret", BaseURL: "https://api.mexc.com", } // Get Exchange Information exchangeInfo, err := utils.GetExchangeInfo(cfg) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Exchange Info: %+v\n", exchangeInfo) // Get Symbol Price price, err := utils.GetSymbolPrice(cfg, "BTC-USDT") if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Price: %+v\n", price) // Get Order Book depth, err := utils.GetOrderBook(cfg, "BTC-USDT", 10) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Order Book: %+v\n", depth) } ``` -------------------------------- ### Get Account Trade List: GET /api/v3/myTrades Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/account.md Retrieves trades for a specific account and symbol. Requires USER_DATA permission and has a weight of 10. The symbol parameter is required; limit defaults to 500 with a maximum of 1000. ```http GET /api/v3/myTrades ``` -------------------------------- ### Place and Cancel Orders, Get Account Info Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/nodejs.md Place a limit order, cancel an order by ID, and retrieve account information using the Spot client. ```javascript // Place Order client.newOrder({ symbol: 'BTC-USDT', side: 'BUY', type: 'LIMIT', quantity: 0.001, price: 30000 }) .then(response => console.log(response)) .catch(error => console.error(error)); // Cancel Order client.cancelOrder({ symbol: 'BTC-USDT', orderId: 'order_id' }) .then(response => console.log(response)) .catch(error => console.error(error)); // Get Account Information client.account() .then(response => console.log(response)) .catch(error => console.error(error)); ``` -------------------------------- ### WebSocket Client for MEXC Go SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/go.md Connect to the MEXC WebSocket endpoint, subscribe to a public deals channel, and listen for incoming messages. ```go package main import ( "fmt" "github.com/gorilla/websocket" "log" ) type WebSocketClient struct { conn *websocket.Conn done chan struct{} } func NewWebSocketClient() (*WebSocketClient, error) { conn, _, err := websocket.DefaultDialer.Dial("wss://wss.mexc.com/ws", nil) if err != nil { return nil, err } return &WebSocketClient{ conn: conn, done: make(chan struct{}), }, nil } func (c *WebSocketClient) Subscribe(channel string) error { message := map[string]interface{}{ "method": "SUBSCRIPTION", "params": []string{channel}, } return c.conn.WriteJSON(message) } func (c *WebSocketClient) Listen() { for { select { case <-c.done: return default: _, message, err := c.conn.ReadMessage() if err != nil { log.Printf("Error reading message: %v", err) return } fmt.Printf("Received: %s\n", message) } } } // Usage Example func main() { client, err := NewWebSocketClient() if err != nil { log.Fatal(err) } defer client.conn.Close() err = client.Subscribe("spot@public.deals.v3.api@BTCUSDT") if err != nil { log.Fatal(err) } client.Listen() } ``` -------------------------------- ### Python Error Handling Example Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/error-codes.md Example Python function that checks the HTTP status code, retries on 429 and 500-level errors with backoff, and raises an exception for other errors using the API error code and message. ```python def handle_api_error(response): if response.status_code != 200: if response.status_code == 429: # Handle rate limit retry_after = int(response.headers.get('Retry-After', 5)) time.sleep(retry_after) return True # Retry request elif response.status_code >= 500: # Handle server error time.sleep(1) return True # Retry request else: # Handle other errors error = response.json() raise Exception(f"API Error {error['code']}: {error['msg']}") return False # Don't retry ``` -------------------------------- ### Get Account Information: GET /api/v3/account Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/account.md Retrieves current account information including commissions, trade permissions, and balances. Requires USER_DATA permission and has a weight of 10. The optional recvWindow parameter sets the request timeout in milliseconds. ```http GET /api/v3/account ``` -------------------------------- ### POST /api/v3/sub-account/create Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/account.md Creates a new sub-account with a name and optional note. ```APIDOC ## POST /api/v3/sub-account/create ### Description Create a new sub-account. ### Method POST ### Endpoint /api/v3/sub-account/create ### Parameters #### Query Parameters - **subAccountName** (STRING) - Required - Sub-account name - **note** (STRING) - Optional - Note for the sub-account - **recvWindow** (LONG) - Optional - Request timeout in milliseconds ### Response #### Success Response (200) - **subAccountId** (STRING) - Sub-account ID - **note** (STRING) - Note for the sub-account - **createTime** (LONG) - Creation timestamp #### Response Example { "subAccountId": "123456", "note": "Trading account", "createTime": 1499865549590 } ``` -------------------------------- ### GET /api/v1/ping Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/futures/market.md Tests connectivity to the Rest API. ```APIDOC ## GET /api/v1/ping ### Description Tests connectivity to the Rest API. ### Method GET ### Endpoint /api/v1/ping ### Parameters None ### Response #### Success Response (200) - **{}** (object) - Empty object indicating successful connectivity. #### Response Example ```javascript {} ``` ``` -------------------------------- ### POST /api/v3/order/test Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/trading.md Test new order creation and signature/recvWindow. Creates and validates a new order but does not send it into the matching engine. ```APIDOC ## POST /api/v3/order/test ### Description Test new order creation and signature/recvWindow. Creates and validates a new order but does not send it into the matching engine. ### Method POST ### Endpoint /api/v3/order/test ### Parameters #### Query Parameters - **symbol** (STRING) - Required - Trading symbol - **side** (ENUM) - Required - BUY or SELL - **type** (ENUM) - Required - Order type: LIMIT, MARKET, LIMIT_MAKER - **timeInForce** (ENUM) - Optional - GTC, IOC, FOK - **quantity** (DECIMAL) - Required - Order quantity - **price** (DECIMAL) - Optional - Order price - **newClientOrderId** (STRING) - Optional - Unique order ID - **recvWindow** (LONG) - Optional - Request timeout in milliseconds ### Response #### Success Response (200) Empty object #### Response Example ```json {} ``` ``` -------------------------------- ### GET /api/v3/sub-account/list Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/account.md Retrieves a list of sub-accounts with optional filtering and pagination. ```APIDOC ## GET /api/v3/sub-account/list ### Description Get list of sub-accounts. ### Method GET ### Endpoint /api/v3/sub-account/list ### Parameters #### Query Parameters - **subAccountId** (STRING) - Optional - Sub-account ID - **page** (INT) - Optional - Default 1 - **limit** (INT) - Optional - Default 10, max 50 - **recvWindow** (LONG) - Optional - Request timeout in milliseconds ### Response #### Success Response (200) - **subAccounts** (ARRAY) - List of sub-accounts - **subAccountId** (STRING) - Sub-account ID - **note** (STRING) - Note for the sub-account - **createTime** (LONG) - Creation timestamp - **status** (STRING) - Status of the sub-account - **total** (INT) - Total number of sub-accounts #### Response Example { "subAccounts": [ { "subAccountId": "123456", "note": "Trading account", "createTime": 1499865549590, "status": "ACTIVE" } ], "total": 1 } ``` -------------------------------- ### Create Sub-Account API Key - POST /api/v3/sub-account/apiKey Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/account.md Creates an API key for a sub-account. Requires subAccountId. Response includes apiKey, secretKey, note, permissions, and createTime. ```http POST /api/v3/sub-account/apiKey ``` ```json { "subAccountId": "123456", "apiKey": "vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A", "secretKey": "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j", "note": "API key for trading", "permissions": ["SPOT"], "createTime": 1499865549590 } ``` -------------------------------- ### GET /api/v1/exchangeInfo Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/futures/market.md Current exchange trading rules and symbol information. ```APIDOC ## GET /api/v1/exchangeInfo ### Description Current exchange trading rules and symbol information. ### Method GET ### Endpoint /api/v1/exchangeInfo ### Parameters None ### Response #### Success Response (200) - **timezone** (string) - The timezone of the exchange. - **serverTime** (number) - The current server time in milliseconds. - **rateLimits** (array) - Rate limit definitions. - **symbols** (array) - List of symbol information. - **symbol** (string) - The symbol name. - **status** (string) - The trading status. - **baseAsset** (string) - The base asset. - **baseAssetPrecision** (number) - The precision of the base asset. - **quoteAsset** (string) - The quote asset. - **quotePrecision** (number) - The precision of the quote asset. - **orderTypes** (array) - Supported order types. - **filters** (array) - Symbol filters. #### Response Example ```javascript { "timezone": "UTC", "serverTime": 1565246363776, "rateLimits": [ { // These are defined in the `ENUM definitions` section under `Rate Limiters (rateLimitType)` // All limits are optional } ], "symbols": [ { "symbol": "BTCUSDT", "status": "TRADING", "baseAsset": "BTC", "baseAssetPrecision": 8, "quoteAsset": "USDT", "quotePrecision": 8, "orderTypes": [ "LIMIT", "MARKET", "STOP" ], "filters": [ // Filters are defined in the `ENUM definitions` section ] } ] } ``` ``` -------------------------------- ### GET /api/v3/avgPrice Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/market.md Retrieves the current average price for a specified trading symbol. ```APIDOC ## GET /api/v3/avgPrice ### Description Get current average price for a symbol. ### Method GET ### Endpoint /api/v3/avgPrice ### Parameters #### Query Parameters - **symbol** (STRING) - Required - Trading symbol ### Response #### Success Response (200) - **mins** (INT) - Number of minutes - **price** (STRING) - Average price #### Response Example ```json { "mins": 5, "price": "9.35751834" } ``` ``` -------------------------------- ### Fetch Market Data Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/nodejs.md Retrieve exchange information, symbol price, and order book depth using the Spot client. ```javascript // Get Exchange Information client.exchangeInfo() .then(response => console.log(response)) .catch(error => console.error(error)); // Get Symbol Price client.price('BTC-USDT') .then(response => console.log(response)) .catch(error => console.error(error)); // Get Order Book client.depth('BTC-USDT', { limit: 10 }) .then(response => console.log(response)) .catch(error => console.error(error)); ```