Base Info
The base url
Time zone
The time zone for all times is UTC+0
WebSocket Overview
WebSocket is a new protocol for HTML5, which enables full-duplex communication between the client and the server, allowing data to travel in both directions quickly. The client and server connections can be established through a simple handshake, and the server can actively push information to the client according to the business rules. The advantages are as follows:
When the client and the server perform data transmission, the request header information is relatively small, about 2 bytes.
Both the client and the server can actively send data to the other party.
There is no need to create TCP requests and destroy multiple times, saving bandwidth and server resources.
Market Endpoint
Contract info
Exchange trading rules and symbol information
Limit:
Speed limit: 1 times/second, Speed limit rule: IP
Request Url:
Parameters:
Response:
Example:
Copy {
"code" : 0 ,
"message" : "OK" ,
"result" : [
{
"lotSize" : 1.0 ,
"symbol" : "MASKUSDT" ,
"tick" : 0.001 ,
"type" : "PERP"
}
]
}
Klines
Obtain K line by from and step
Limit:
Speed limit: 15 times/1min, Speed limit rule: IP
Request URL:
Parameters:
Response:
Example:
Copy {
"code" : 0 ,
"message" : "OK" ,
"result" : [
[
"25559.4" ,
"25559.7" ,
"1686905040" ,
"25553.2" ,
"25554.1" ,
"1" ,
"7.08" ,
"181074.0"
]
]
}
Klines By Time
Obtain K line by time and step
Limit:
Speed limit: 15 times/1min, Speed limit rule: IP
Request URL:
Parameters:
Response:
Example:
Copy {
"code" : 0 ,
"message" : "OK" ,
"result" : [
[
"25559.4" ,
"25559.7" ,
"1686905040" ,
"25553.2" ,
"25554.1" ,
"1" ,
"7.08" ,
"181074.0"
]
]
}
Index
Index price of underlying asset
Limit:
Speed limit: 10 times/second, Speed limit rule: IP
Request Url:
Copy GET /basic/indexPrice
Parameters:
Response:
Example:
Copy {
"code" : 0 ,
"message" : "OK" ,
"result" : [
{
"symbol" : "BTCUSDT" ,
"price" : 26442.32666666667 ,
"time" : 1686209050099
}
]
}
Last Price
Query last price of instrument(s)
Limit:
Speed limit: 1 times/second, Speed limit rule: IP
Request Url:
Parameters:
Response:
Example:
Copy {
"code" : 0 ,
"message" : "OK" ,
"result" : [
{
"price" : 26627.7 ,
"symbol" : "BTCUSDT" ,
"time" : 1686304783617
}
]
}
Mark Price
Query mark price of instrument(s)
Limit:
Speed limit: 10 times/second, Speed limit rule: IP
Request Url:
Parameters:
Response:
Example:
Copy {
"code" : 0 ,
"message" : "OK" ,
"result" : [
{
"price" : 26627.7 ,
"symbol" : "BTCUSDT" ,
"time" : 1686304783617
}
]
}
Funding Rate
Obtain funding rate of instrument
Limit:
Speed limit: 5 times/second, Speed limit rule: IP
Request Url:
Copy GET /kLine/fundingRate
Parameters:
Response:
Example:
Copy {
"code" : 0 ,
"message" : "OK" ,
"result" : [
{
"symbol" : "BTCUSDT" ,
"rate" : 0.0001 ,
"date" : "2023-06-08T08:00:00.000+00:00" ,
"timestamp" : 1686207600020
}
]
}
Depth
Query market depth Snapshot & trades of instrument
Limit:
Speed limit: 10 times/second, Speed limit rule: IP
Request Url:
Parameters:
Response:
Example:
Copy {
"code" : 0 ,
"message" : "OK" ,
"result" : {
"buyDepth" : [
{
"price" : 26418.5 ,
"qty" : 50056.0 ,
"count" : 6 ,
"iceCount" : 0
} ,
{
"price" : 26418.4 ,
"qty" : 80489.0 ,
"count" : 6 ,
"iceCount" : 0
} ,
{
"price" : 26418.1 ,
"qty" : 58500.0 ,
"count" : 4 ,
"iceCount" : 0
}
] ,
"sellDepth" : [
{
"price" : 26418.8 ,
"qty" : 7797.0 ,
"count" : 2 ,
"iceCount" : 0
} ,
{
"price" : 26418.9 ,
"qty" : 9891.0 ,
"count" : 2 ,
"iceCount" : 0
} ,
{
"price" : 26419.0 ,
"qty" : 17483.0 ,
"count" : 5 ,
"iceCount" : 0
} ,
{
"price" : 26419.1 ,
"qty" : 19006.0 ,
"count" : 6 ,
"iceCount" : 0
} ,
{
"price" : 26419.2 ,
"qty" : 17266.0 ,
"count" : 6 ,
"iceCount" : 0
}
] ,
"trades" : null
}
}
trades
Retrieve the latest trades that have occurred for a specific contract.
Limit:
Speed limit: 10 times/second, Speed limit rule: IP
Request URL:
Parameters:
Response:
Example:
Copy {
"code" : 0 ,
"message" : "OK" ,
"result" : [
{
"id" : "1686213904404000035" ,
"symbol" : "BTCUSDT" ,
"price" : 26428.9 ,
"qty" : 1295.0 ,
"buyActive" : false ,
"timestamp" : "2023-06-08T08:45:04.404+00:00" ,
"tms" : "1686213904404"
} ,
{
"id" : "1686213899234000003" ,
"symbol" : "BTCUSDT" ,
"price" : 26438.2 ,
"qty" : 2000.0 ,
"buyActive" : false ,
"timestamp" : "2023-06-08T08:44:59.234+00:00" ,
"tms" : "1686213899234"
} ,
{
"id" : "1686213884863000003" ,
"symbol" : "BTCUSDT" ,
"price" : 26433.3 ,
"qty" : 9100.0 ,
"buyActive" : true ,
"timestamp" : "2023-06-08T08:44:44.863+00:00" ,
"tms" : "1686213884863"
}
]
}
Trade Statistics in latest 24 hours
Trade Statistics in latest 24 hours
Limit:
Speed limit: 10 times/second, Speed limit rule: IP
Request URL:
Copy GET /kLine/tradeStatistics
Parameters:
Response:
Example:
Copy {
"code" : 0 ,
"message" : "OK" ,
"result" : [
{
"lastPrice" : 25971.3 ,
"maxPrice" : 26420.9 ,
"minPrice" : 25713.4 ,
"priceChange" : - 142.0 ,
"priceChangeRatio" : - 0.005437842019200944 ,
"symbol" : "BTCUSDT" ,
"turnover" : 16171.504782381482 ,
"volume" : 4.19809141E8
}
]
}
Open Position In Exchange
Total Open Position In Exchange
Limit:
Speed limit: 5 times/second, Speed limit rule: IP
Request URL:
Copy GET /kLine/openInterest
Parameters:
Response:
Example:
Copy {
"code" : 0 ,
"message" : "OK" ,
"result" : {
"symbol" : "BTCUSDT" ,
"value" : 41.035743951380205 ,
"date" : "2023-06-19T02:37:53.617+00:00" ,
"qty" : 1084388.0
}
}
Public Websocket Endpoints
Receiving data requires an event subscription
Kline
Parameters:
Example:
Copy {
"op" : "subscribe" ,
"key" : "BTCUSDT" ,
"type" : "1M" ,
"channel" : "kLine"
}
Response:
Example:
Copy {
"hisPrice" : [
"25557.4" ,
"25557.7" ,
"1686905100" ,
"25557.4" ,
"25557.5" ,
"1" ,
"0.69" ,
"17681.0"
] ,
"isNew" : false ,
"key" : "MEXO_BTCUSDT_1M"
}
Depth
Parameters:
Example:
Copy {
"buyDepth" : [
{
"price" : 25916.1 ,
"qty" : 26144.0 ,
"count" : 4 ,
"iceCount" : 0
} ,
{
"price" : 25915.9 ,
"qty" : 82419.0 ,
"count" : 7 ,
"iceCount" : 0
}
] ,
"sellDepth" : [
{
"price" : 25916.4 ,
"qty" : 6233.0 ,
"count" : 2 ,
"iceCount" : 0
} ,
{
"price" : 25917.3 ,
"qty" : 33746.0 ,
"count" : 5 ,
"iceCount" : 0
}
] ,
"trades" : [
{
"id" : "1686733223325000025" ,
"symbol" : "BTCUSDT" ,
"price" : 25916.4 ,
"qty" : 3648.0 ,
"buyActive" : true ,
"timestamp" : "Jun 14, 2023 09:00:23 AM" ,
"tms" : "1686733223325"
} ,
{
"id" : "1686733223325000023" ,
"symbol" : "BTCUSDT" ,
"price" : 25916.4 ,
"qty" : 4289.0 ,
"buyActive" : true ,
"timestamp" : "Jun 14, 2023 09:00:23 AM" ,
"tms" : "1686733223325"
}
] ,
"key" : "BTCUSDT"
}
Trade Statistics
Parameters:
Example:
Copy {
"op" : "subscribe" ,
"key" : "BTCUSDT" ,
"channel" : "tradeStatistics"
}
Response:
Example:
Copy {
"tradeStatistics" : {
"symbol" : "BTCUSDT" ,
"maxPrice" : 26081.8 ,
"minPrice" : 24800.2 ,
"priceChange" : -919.1000000000022 ,
"priceChangeRatio" : -0.03533002494743365 ,
"volume" : 4.55661746E8 ,
"turnover" : 17834.7449180242 ,
"lastPrice" : 25095.6
} ,
"key" : "BTCUSDT"
}
Open Interest
Total Open Position In Exchange
Parameters:
Example:
Copy {
"op" : "subscribe" ,
"key" : "BTCUSDT" ,
"channel" : "openInterest"
}
Response:
Example:
Copy {
"key" : "BTCUSDT" ,
"event" : "openInterest" ,
"value" : 45.36721464659362 ,
"date" : "Jun 19, 2023 03:06:10 AM" ,
"qty" : 1199212.0
}
Trade Http Endpoints
Trade Endpoints Check signature. Check parameters are passed in header
Place order for a contract. This API endpoint requires your signed request.
Request Weight:
Speed limit: 20 times/second Speed limit rule: apiKey
Request URL:
Copy POST /trade/enterOrder
Parameters:
NOTE For Market Orders , you need to set orderType
as Market
.
You can get contract price and quantity precision configuration data in the exchange
endpoint.
Note: if your balance does not meet the margin requirement (which is the minimum margin requirement + open position fee + close position fee), "insufficient balance " error message will be returned.
Response:
Example:
Copy {
"code" : 0 ,
"message" : "OK" ,
"result" : {
"ordStatus" : "PENDING_NEW" ,
"symbol" : "BTCUSDT" ,
"clientOrderId" : "213443" ,
"showQty" : 0.0 ,
"side" : "Sell" ,
"created" : 1685699501000 ,
"fee" : 0.0 ,
"cumQty" : 0.0 ,
"source" : "Normal" ,
"type" : "Market" ,
"pnl" : 0.0 ,
"tif" : "GOOD_TILL_CANCEL" ,
"openPosition" : true ,
"uid" : "1323056886107491328" ,
"avgPx" : 0.0 ,
"price" : 0.0 ,
"qty" : 100.0 ,
"iceberg" : false ,
"modified" : 1685699501000 ,
"currency" : "BTC" ,
"id" : "O101-20230602-095141-711-1878"
}
}
Query Order
Request order by id
Limit:
Speed limit: 20 times/second, Speed limit rule: apiKey
Request URL:
Copy GET /trade/queryOrderById
Parameters:
NOTE orderId and clientOrderId must pick one of two
Response:
Example:
Copy {
"code" : 0 ,
"message" : "OK" ,
"result" : {
"id" : "O101-20230531-040439-546-1837" ,
"uid" : "1323056886107491328" ,
"symbol" : "BTCUSDT" ,
"created" : 1685505879000 ,
"modified" : 1685505879000 ,
"side" : "Buy" ,
"type" : "Market" ,
"tif" : "GOOD_TILL_CANCEL" ,
"currency" : "BTC" ,
"price" : 0.0 ,
"qty" : 100.0 ,
"openPosition" : false ,
"cumQty" : 100.0 ,