### Install MEXC Python SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/python.md Instructions to clone the repository and navigate to the Python SDK directory. This is the initial setup step before using the SDK. ```bash git clone https://github.com/mexcdevelop/mexc-api-demo.git cd mexc-api-demo/python ``` -------------------------------- ### Install MEXC Go SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/go.md Instructions to clone the MEXC API demo repository and install Go module dependencies for the Go SDK. ```bash # Clone the repository git clone https://github.com/mexcdevelop/mexc-api-demo.git cd mexc-api-demo/go # Install dependencies go mod download ``` -------------------------------- ### Place, Cancel Orders, and Get Account Info (Python) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/python.md Provides examples of placing a limit order, canceling an order by its ID, and retrieving account information using the MEXC Python SDK. Assumes a client instance is already created. ```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) ``` -------------------------------- ### Install MEXC Node.js SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/nodejs.md Instructions to clone the repository and install the MEXC Node.js SDK dependencies using npm. This sets up the necessary packages for interacting with the MEXC API. ```bash git clone https://github.com/mexcdevelop/mexc-api-demo.git cd mexc-api-demo/node.js npm install ``` -------------------------------- ### Create Sub-account Response Example (JavaScript) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/broker/subaccount.md Example JSON response for creating a sub-account. It includes the 'code', 'message', and 'data' fields, with 'data' containing the 'subAccount' name, 'note', and 'timestamp'. ```javascript { "code": "0", "message": "", "data": { "subAccount": "testAccount", "note": "test account", "timestamp": "1597026383085" } } ``` -------------------------------- ### Get Market Data with MEXC SDK (JavaScript) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/nodejs.md Examples of fetching market data using the MEXC Node.js SDK, including exchange information, symbol price, and order book details. Uses Promises for asynchronous operations. ```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)); ``` -------------------------------- ### Create API Key for Sub-account Response Example (JavaScript) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/broker/subaccount.md Example JSON response when creating an API key for a sub-account. It returns the 'subAccount' name, 'permissions', 'note', the generated 'apikey', 'secretKey', and 'createTime'. ```javascript { "subAccount": "4Eb8rPPhpsAL", "permissions": "SPOT_ACCOUNT_READ,SPOT_ACCOUNT_WRITE", "note": "note2", "apikey": "mx0npKfh57kEEVmyLa", "secretKey": "51f38875ebe0475dad6236783a95cc19", "createTime": 1646291300120 } ``` -------------------------------- ### Query Sub-account List Response Example (JavaScript) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/broker/subaccount.md Example JSON response for querying a list of sub-accounts. The 'data' field is an array of objects, each containing 'subAccount' name, 'note', and 'timestamp'. ```javascript { "code": "0", "message": "", "data": [{ "subAccount": "mexc1", "note": "1", "timestamp": "1597026383085" }, { "subAccount": "mexc2", "note": "2", "timestamp": "1597026383787" }] } ``` -------------------------------- ### Check Server Time Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/market.md Get the current server time. ```APIDOC ## GET /api/v3/time ### Description Gets the current server time. ### Method GET ### Endpoint /api/v3/time ### Parameters #### Path Parameters None #### Query Parameters None ### Request Example None ### Response #### Success Response (200) - **serverTime** (LONG) - Current timestamp in milliseconds. #### Response Example ```json { "serverTime": 1499827319559 } ``` ``` -------------------------------- ### Fetch Market Data (Ticker Price) (.NET) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/dotnet.md Example C# code to get the ticker price for a specific symbol using the MexcService. It includes error handling for API requests and logs the price or any exceptions. ```csharp 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}"); } } ``` -------------------------------- ### Project Setup using Git Clone Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/java.md Instructions to clone the MEXC API demo repository and navigate to the Java directory. This sets up your local environment for using the SDK. ```bash # Clone the repository git clone https://github.com/mexcdevelop/mexc-api-demo.git cd mexc-api-demo/Java ``` -------------------------------- ### Install MEXC .NET SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/dotnet.md Instructions for cloning the MEXC API demo repository and building the .NET project. This sets up the necessary files for using the SDK. ```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 Client Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/go.md Example of how to configure the MEXC Go SDK client with API keys, secret keys, and the base URL. ```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", } } ``` -------------------------------- ### Query Sub-account Trading Summary Response (JavaScript) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/broker/account.md Example JavaScript object for the response of a sub-account trading summary query. It includes the total number of trades, total trading volume, total commission earned, the asset used for commission, and the start and end times of the summary period. ```javascript { "totalTrades": 100, "totalVolume": "1000.0", "totalCommission": "1.5", "commissionAsset": "USDT", "startTime": 1656408193478, "endTime": 1656494593478 } ``` -------------------------------- ### Query Sub-account Trading Summary (HTTP) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/broker/account.md This GET endpoint fetches the trading summary for a specific sub-account. It requires the sub-account identifier and optionally accepts start and end times. A timestamp and HMAC SHA256 signature are necessary for authentication. The response provides trading statistics like total trades, volume, and commission. ```http GET /api/v3/broker/sub-account/tradingSummary (HMAC SHA256) ``` -------------------------------- ### Execute Trades using MEXC Go SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/go.md Illustrates placing a limit order and retrieving account information using the MEXC Go SDK. Requires SDK configuration and valid order parameters. ```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) } ``` -------------------------------- ### Query Sub-account Transfer History (HTTP) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/broker/account.md This GET endpoint retrieves the transfer history for sub-accounts. Optional parameters include source account, target account, asset, start and end times, and pagination controls (page, limit). A timestamp and HMAC SHA256 signature are required for authentication. The response contains a list of transfers and the total count. ```http GET /api/v3/broker/sub-account/transfer/history (HMAC SHA256) ``` -------------------------------- ### Initialize MEXC Spot Client (JavaScript) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/nodejs.md Demonstrates how to initialize the Spot client from the MEXC Node.js SDK. Requires API key and secret for authenticated requests. ```javascript const { Spot } = require('./src/modules'); const client = new Spot({ apiKey: 'your_api_key', apiSecret: 'your_api_secret' }); ``` -------------------------------- ### Fetch Market Data using MEXC Go SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/go.md Demonstrates fetching exchange information, symbol prices, and order book data using the MEXC Go SDK. Requires SDK configuration. ```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 /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. This endpoint provides a summary of trading activities for a specified sub-account within a given time range. ```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 earned - **commissionAsset** (STRING) - The asset in which commission is paid - **startTime** (LONG) - The start time of the summary period - **endTime** (LONG) - The end time of the summary period #### Response Example ```json { "totalTrades": 100, "totalVolume": "1000.0", "totalCommission": "1.5", "commissionAsset": "USDT", "startTime": 1656408193478, "endTime": 1656494593478 } ``` ``` -------------------------------- ### Get Trade History (Bash) Source: https://context7.com/suenot/mexc-docs-markdown/llms.txt Retrieves historical trades for a given symbol and account using a REST API GET request. Authentication is required through specific headers. ```bash curl -X GET 'https://api.mexc.com/api/v3/myTrades?symbol=BTCUSDT&limit=10' \ -H "X-MEXC-APIKEY: your_api_key" \ -H "X-MEXC-SIGNATURE: generated_signature" \ -H "X-MEXC-TIMESTAMP: 1499827319559" ``` -------------------------------- ### Initialize MEXC API Clients in Java Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/java.md Demonstrates how to initialize MarketDataClient and UserDataClient for interacting with MEXC's market data and user-specific trading endpoints. Requires API key and secret for user data operations. ```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); } } ``` -------------------------------- ### Spot Trading API v3 Overview Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/introduction.md The Spot Trading API v3 offers full functionality for spot trading on MEXC, including access to market data, execution of trades, account management, and real-time data via WebSocket streams. ```APIDOC ## Spot Trading API v3 ### Description Provides complete functionality for spot trading, including market data access, trading operations, account management, and WebSocket streams for real-time data. ### Base URL `https://api.mexc.com/api/v3` ### WebSocket URL `wss://wss.mexc.com/ws` ``` -------------------------------- ### Implement WebSocket Communication with MEXC Go SDK Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/go.md Provides a Go implementation for a WebSocket client to connect to MEXC, subscribe to channels, and listen for messages. Requires the gorilla/websocket library. ```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() } ``` -------------------------------- ### Get Current Price Source: https://context7.com/suenot/mexc-docs-markdown/llms.txt Fetches the latest trading price for one or more trading symbols. This is a simple endpoint to get real-time price information for quick checks. Requires the trading symbol as a parameter. ```bash curl -X GET 'https://api.mexc.com/api/v3/ticker/price?symbol=BTCUSDT' ``` -------------------------------- ### Get Exchange Information and Price (Python) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/python.md Demonstrates how to initialize the MEXC Spot v3 client and retrieve exchange information, symbol prices, and order book data using the Python SDK. Requires API key and secret. ```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) ``` -------------------------------- ### Initialize MEXC Service Client (.NET) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/dotnet.md Demonstrates how to create a basic MEXCService class in C#. This class requires API key and secret for authentication and sets the base URL for API requests. ```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"; } } ``` -------------------------------- ### Query Current Open Orders (HTTP GET) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/trading.md Fetches a list of all currently open orders for a given trading symbol. This endpoint is useful for getting an overview of your active orders and their statuses. The response is an array of order objects. ```http GET /api/v3/openOrders ``` -------------------------------- ### MEXC Spot Trading API Calls in Java Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/java.md Demonstrates Java methods for placing orders and retrieving account information using the UserDataClient. Requires proper authentication with API key and secret. Handles potential exceptions. ```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(); } } ``` -------------------------------- ### Example API Response (JSON) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/futures/market.md Illustrative JSON responses for Mexc API endpoints, demonstrating the structure for ping, time, and exchange information. ```json {} ``` ```json { "serverTime": 1499827319559 } ``` ```json { "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 ] } ] } ``` -------------------------------- ### Kline/Candlestick Data Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/market.md Get kline/candlestick bars for a symbol. ```APIDOC ## GET /api/v3/klines ### Description Retrieves kline/candlestick data for a specified trading symbol and interval. ### Method GET ### Endpoint /api/v3/klines ### Parameters #### Path Parameters None #### Query Parameters - **symbol** (STRING) - Required - The trading symbol (e.g., "BTCUSDT"). - **interval** (ENUM) - Required - The interval for the klines. Accepted values: `1m`, `3m`, `5m`, `15m`, `30m`, `1h`, `2h`, `4h`, `6h`, `8h`, `12h`, `1d`, `3d`, `1w`, `1M`. - **startTime** (LONG) - Optional - Get klines starting from this time. (Timestamp in ms) - **endTime** (LONG) - Optional - Get klines ending before this time. (Timestamp in ms) - **limit** (INT) - Optional - The number of klines to retrieve. Default is 500, maximum is 1000. ### Request Example None ### Response #### Success Response (200) An array of kline data arrays, where each inner array represents a kline: - **[0]** (LONG) - Open time. - **[1]** (STRING) - Open price. - **[2]** (STRING) - High price. - **[3]** (STRING) - Low price. - **[4]** (STRING) - Close price. - **[5]** (STRING) - Volume. - **[6]** (LONG) - Close time. - **[7]** (STRING) - Quote asset volume. - **[8]** (INTEGER) - Number of trades. - **[9]** (STRING) - Taker buy base asset volume. - **[10]** (STRING) - Taker buy quote asset volume. - **[11]** (STRING) - Ignore. #### Response Example ```json [ [ 1499040000000, // Open time "0.01634790", // Open "0.80000000", // High "0.01575800", // Low "0.01577100", // Close "148976.11427815", // Volume 1499644799999, // Close time "2434.19055334", // Quote asset volume 308, // Number of trades "1756.87402397", // Taker buy base asset volume "28.46694368", // Taker buy quote asset volume "0" // Ignore ] ] ``` ``` -------------------------------- ### Order Book Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/market.md Get order book for a symbol. ```APIDOC ## GET /api/v3/depth ### Description Retrieves the order book for a specified trading symbol. ### Method GET ### Endpoint /api/v3/depth ### Parameters #### Path Parameters None #### Query Parameters - **symbol** (STRING) - Required - The trading symbol (e.g., "BTCUSDT"). - **limit** (INT) - Optional - The number of entries to retrieve. Default is 100, maximum is 5000. ### Request Example None ### Response #### Success Response (200) - **lastUpdateId** (LONG) - The last update ID of the order book. - **bids** (Array) - An array of bid orders, each represented as `[price, quantity]`. - **asks** (Array) - An array of ask orders, each represented as `[price, quantity]`. #### Response Example ```json { "lastUpdateId": 1027024, "bids": [ ["4.00000000", "431.00000000"] ], "asks": [ ["4.00000200", "12.00000000"] ] } ``` ``` -------------------------------- ### Execute Spot Trading (Place Order) (.NET) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/dotnet.md Example C# code for placing a limit order on the MEXC spot market. It defines order parameters like symbol, side, type, quantity, and price, then sends the request via the MexcService, logging the response or any errors. ```csharp 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}"); } } ``` -------------------------------- ### Aggregate Trades List Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/market.md Get compressed, aggregate trades. ```APIDOC ## GET /api/v3/aggTrades ### Description Retrieves compressed, aggregate trades for a symbol. ### Method GET ### Endpoint /api/v3/aggTrades ### Parameters #### Path Parameters None #### Query Parameters - **symbol** (STRING) - Required - The trading symbol (e.g., "BTCUSDT"). - **fromId** (LONG) - Optional - Aggregate trades ID to get trades starting from this ID. - **startTime** (LONG) - Optional - Get trades before this time. (Timestamp in ms) - **endTime** (LONG) - Optional - Get trades after this time. (Timestamp in ms) - **limit** (INT) - Optional - The number of aggregate trades to retrieve. Default is 500, maximum is 1000. ### Request Example None ### Response #### Success Response (200) An array of aggregate trade objects, each containing: - **a** (LONG) - Aggregate trade ID. - **p** (STRING) - Price. - **q** (STRING) - Quantity. - **f** (LONG) - First trade ID. - **l** (LONG) - Last trade ID. - **T** (LONG) - Timestamp in milliseconds. - **m** (BOOLEAN) - Whether the buyer was the maker. - **M** (BOOLEAN) - Whether the trade was the best price match. #### Response Example ```json [ { "a": 26129, // Aggregate trade ID "p": "0.01633102", // Price "q": "4.70443515", // Quantity "f": 27781, // First trade ID "l": 27781, // Last trade ID "T": 1498793709153, // Timestamp "m": true, // Was the buyer the maker? "M": true // Was the trade the best price match? } ] ``` ``` -------------------------------- ### MEXC API Request Example (Bash) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/authentication.md Demonstrates how to make a signed request to the MEXC API using cURL. It includes the necessary 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" ``` -------------------------------- ### Recent Trades List Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/market.md Get recent trades for a symbol. ```APIDOC ## GET /api/v3/trades ### Description Retrieves a list of recent trades for a specified trading symbol. ### Method GET ### Endpoint /api/v3/trades ### Parameters #### Path Parameters None #### Query Parameters - **symbol** (STRING) - Required - The trading symbol (e.g., "BTCUSDT"). - **limit** (INT) - Optional - The number of trades to retrieve. Default is 500, maximum is 1000. ### Request Example None ### Response #### Success Response (200) An array of trade objects, each containing: - **id** (LONG) - The trade ID. - **price** (STRING) - The price of the trade. - **qty** (STRING) - The quantity of the trade. - **time** (LONG) - The timestamp of the trade in milliseconds. - **isBuyerMaker** (BOOLEAN) - Whether the buyer was the maker. - **isBestMatch** (BOOLEAN) - Whether the trade was the best price match. #### Response Example ```json [ { "id": 28457, "price": "4.00000100", "qty": "12.00000000", "time": 1499865549590, "isBuyerMaker": true, "isBestMatch": true } ] ``` ``` -------------------------------- ### Place New Order (HTTP POST) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/trading.md Submits a new order to the Mexc trading system. This endpoint requires order details such as symbol, side, type, and quantity, and returns the order information upon successful placement. The response includes details like orderId, clientOrderId, and status. ```http POST /api/v3/order ``` -------------------------------- ### Current Average Price Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/market.md Get current average price for a symbol. ```APIDOC ## GET /api/v3/avgPrice ### Description Retrieves the current average price for a specified trading symbol. ### Method GET ### Endpoint /api/v3/avgPrice ### Parameters #### Path Parameters None #### Query Parameters - **symbol** (STRING) - Required - The trading symbol (e.g., "BTCUSDT"). ### Request Example None ### Response #### Success Response (200) - **mins** (INTEGER) - The number of minutes the average price is calculated over. - **price** (STRING) - The current average price. #### Response Example ```json { "mins": 5, "price": "9.35751834" } ``` ``` -------------------------------- ### GET /api/v3/sub-account/list Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/account.md Retrieves a list of all sub-accounts associated with the main account. ```APIDOC ## GET /api/v3/sub-account/list ### Description Get list of sub-accounts. ### Method GET ### Endpoint /api/v3/sub-account/list #### 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) - Array of sub-account objects. - **subAccountId** (STRING) - The ID of the sub-account. - **note** (STRING) - The note associated with the sub-account. - **createTime** (LONG) - The timestamp when the sub-account was created. - **status** (STRING) - The status of the sub-account (e.g., "ACTIVE"). - **total** (INTEGER) - The total number of sub-accounts. #### Response Example ```json { "subAccounts": [ { "subAccountId": "123456", "note": "Trading account", "createTime": 1499865549590, "status": "ACTIVE" } ], "total": 1 } ``` ``` -------------------------------- ### Spot Trading (v3) - Account Source: https://github.com/suenot/mexc-docs-markdown/blob/main/readme.md Endpoints for retrieving account information, balance, and trade history. ```APIDOC ## GET /api/v3/account ### Description Retrieves account balance and information. ### Method GET ### Endpoint /api/v3/account ### Parameters #### Query Parameters - **recvWindow** (integer) - Optional. The maximum time in ms that the request is valid. - **timestamp** (integer) - Required. UTC timestamp in ms. ### Request Example None ### Response #### Success Response (200) - **makerCommission** (integer) - Maker commission rate. - **takerCommission** (integer) - Taker commission rate. - **buyerCommission** - Buyer commission rate. - **sellerCommission** - Seller commission rate. - **canTrade** (boolean) - Whether trading is enabled. - **canWithdraw** (boolean) - Whether withdrawal is enabled. - **canDeposit** (boolean) - Whether deposit is enabled. - **updateTime** (integer) - Last account update time. - **accountType** (string) - Account type. - **balances** (array) - Array of asset balances. - **permissions** (array) - Account permissions. #### Response Example { "makerCommission": 10, "takerCommission": 10, "buyerCommission": 0, "sellerCommission": 0, "canTrade": true, "canWithdraw": true, "canDeposit": true, "updateTime": 1678886400000, "accountType": "SPOT", "balances": [ { "asset": "USDT", "free": "1000.00000000", "locked": "0.00000000" }, { "asset": "BTC", "free": "0.50000000", "locked": "0.10000000" } ], "permissions": ["SPOT"] } ``` ```APIDOC ## GET /api/v3/myTrades ### Description Retrieves all trades for a specific account. ### Method GET ### Endpoint /api/v3/myTrades ### Parameters #### Query Parameters - **symbol** (string) - Optional. The trading symbol (e.g., BTCUSDT). - **orderId** (integer) - Optional. Filter by orderId. - **startTime** (integer) - Optional. Query by start time (in ms). - **endTime** (integer) - Optional. Query by end time (in ms). - **fromId** (integer) - Optional. "fromId" is the TradeId above which the ordered list will be returned. - **limit** (integer) - Optional. Default 500; Max 1000. - **recvWindow** (integer) - Optional. The maximum time in ms that the request is valid. - **timestamp** (integer) - Required. UTC timestamp in ms. ### Request Example None ### Response #### Success Response (200) - Returns an array of trades, with the same structure as the /api/v3/trades response, plus orderId and isBestMatch. #### Response Example [ { "symbol": "BTCUSDT", "id": 123456, "orderId": 100000001, "price": "24990.00", "qty": "0.10000000", "quoteQty": "2499.00", "time": 1678886400000, "isBuyerMaker": true, "isBestMatch": true } ] ``` -------------------------------- ### Exchange Information Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/market.md Get current exchange trading rules and symbol information. ```APIDOC ## GET /api/v3/exchangeInfo ### Description Retrieves current exchange trading rules and symbol information. ### Method GET ### Endpoint /api/v3/exchangeInfo ### Parameters #### Path Parameters None #### Query Parameters - **symbol** (STRING) - Optional - Trading symbol, e.g. "BTCUSDT". - **symbols** (Array) - Optional - Array of trading symbols. ### Request Example None ### Response #### Success Response (200) - **timezone** (STRING) - The exchange's timezone. - **serverTime** (LONG) - The exchange's current server time in milliseconds. - **rateLimits** (Array) - Rate limit rules. - **symbols** (Array) - Information about each trading symbol. - **symbol** (STRING) - Trading symbol. - **status** (STRING) - Trading status of the symbol. - **baseAsset** (STRING) - The base asset of the trading pair. - **baseAssetPrecision** (INTEGER) - Precision for the base asset. - **quoteAsset** (STRING) - The quote asset of the trading pair. - **quotePrecision** (INTEGER) - Precision for the quote asset. - **orderTypes** (Array) - Allowed order types for the symbol. - **filters** (Array) - Trading rules and filters for the symbol. #### 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" } ] } ] } ``` ``` -------------------------------- ### Market Data WebSocket Subscription (Python) Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/sdk/python.md Illustrates how to set up a WebSocket connection using the MEXC Python SDK to subscribe to real-time market data streams, such as deals and order book updates for a specific symbol. Requires API key and secret. ```python # Market Data WebSocket from spot.websocket import WebSocket def message_handler(message): print(f"Received message: {message}") ws = WebSocket( api_key='your_api_key', api_secret='your_api_secret' ) # Subscribe to ticker ws.subscribe( channel='spot@public.deals.v3.api@BTCUSDT', callback=message_handler ) # Subscribe to order book ws.subscribe( channel='spot@public.depth.v3.api@BTCUSDT', callback=message_handler ) ``` -------------------------------- ### GET /api/v3/myTrades Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/account.md Retrieves a list of trades associated with a specific account and symbol. ```APIDOC ## GET /api/v3/myTrades ### Description Get trades for a specific account and symbol. ### Method GET ### Endpoint /api/v3/myTrades #### Query Parameters - **symbol** (STRING) - Required - Trading symbol - **orderId** (LONG) - Optional - Order ID to fetch trades for - **startTime** (LONG) - Optional - Start time in milliseconds - **endTime** (LONG) - Optional - End time in milliseconds - **fromId** (LONG) - Optional - Trade ID to fetch from - **limit** (INT) - Optional - Default 500; max 1000 - **recvWindow** (LONG) - Optional - Request timeout in milliseconds ### Response #### Success Response (200) - **symbol** (STRING) - The trading symbol. - **id** (LONG) - The trade ID. - **orderId** (LONG) - The order ID associated with the trade. - **price** (STRING) - The price of the trade. - **qty** (STRING) - The quantity traded. - **commission** (STRING) - The commission paid for the trade. - **commissionAsset** (STRING) - The asset used for commission payment. - **time** (LONG) - The time the trade occurred in milliseconds. - **isBuyer** (BOOLEAN) - Whether the account was the buyer in the trade. - **isMaker** (BOOLEAN) - Whether the account was the maker in the trade. - **isBestMatch** (BOOLEAN) - Whether this trade was the best match. #### Response Example ```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 } ] ``` ``` -------------------------------- ### Market API Overview Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/introduction.md The Market API provides access to market data across various trading types, including real-time and historical data, as well as WebSocket streams for live market updates. ```APIDOC ## Market API ### Description Provides market data access across different trading types, including real-time market data, historical market data, and WebSocket streams for live market updates. ### Base URL `https://api.mexc.com/api/market` ### WebSocket URL `wss://wss.mexc.com/market/ws` ``` -------------------------------- ### GET /api/v3/account Source: https://github.com/suenot/mexc-docs-markdown/blob/main/docs/spot/account.md Retrieves current account information, including trading permissions and balances. ```APIDOC ## GET /api/v3/account ### Description Get current account information. ### Method GET ### Endpoint /api/v3/account #### Query Parameters - **recvWindow** (LONG) - Optional - Request timeout in milliseconds ### Response #### Success Response (200) - **makerCommission** (INTEGER) - Maker commission rate. - **takerCommission** (INTEGER) - Taker commission rate. - **buyerCommission** (INTEGER) - Buyer commission rate. - **sellerCommission** (INTEGER) - Seller commission rate. - **canTrade** (BOOLEAN) - Whether the account can trade. - **canWithdraw** (BOOLEAN) - Whether the account can withdraw. - **canDeposit** (BOOLEAN) - Whether the account can deposit. - **updateTime** (LONG) - The last update time of the account. - **accountType** (STRING) - The type of the account (e.g., "SPOT"). - **balances** (ARRAY) - Array of account balances. - **asset** (STRING) - The asset symbol. - **free** (STRING) - The free balance of the asset. - **locked** (STRING) - The locked balance of the asset. - **permissions** (ARRAY) - Array of account permissions. #### Response Example ```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" ] } ``` ```