MEXC Official Market and trade api sdk, easy to connection and send request to MEXC open api !
- To use our SDK you have to install nodejs LTS (https://aws.github.io/jsii/user-guides/lib-user/)
git clone https://github.com/mxcdevelop/mexc-api-sdk.git
- cd dist/{language} and unzip the file
- we offer five language : dotnet, go, java, js, python
//Javascriptimport*asMexcfrom'mexc-sdk';constapiKey='apiKey'constapiSecret='apiSecret'constclient=newMexc.Spot(apiKey,apiSecret);// Gopackage main
import (
"fmt""mexc-sdk/mexcsdk"
)
funcmain() {
apiKey:="apiKey"apiSecret:="apiSecret"spot:=mexcsdk.NewSpot(apiKey, apiSecret)
}# pythonfrommexc_sdkimportSpotspot=Spot(api_key='apiKey', api_secret='apiSecret')// javaimportMexc.Sdk.*; classMyClass {
publicstaticvoidmain(String[] args) {
StringapiKey= "apiKey";
StringapiSecret= "apiSecret";
SpotmySpot = newSpot(apiKey, apiSecret);
}
}// dotnetusingSystem;usingSystem.Collections.Generic;usingMxc.Sdk;namespacedotnet{classProgram{staticvoidMain(string[]args){stringapiKey="apiKey";stringapiSecret="apiSecret";varspot=newSpot(apiKey,apiSecret);}}}client.ping()client.time()client.exchangeInfo(options: any)
options:{symbol,symbols}/** * choose one parameter * * symbol : * example "BNBBTC"; * * symbols : * array of symbol * example ["BTCUSDT","BNBBTC"]; * */client.trades(symbol: string,options: any={limit: 500})
options:{limit}/** * * limit : * Number of returned data * Default 500; * max 1000; * */client.depth(symbol: string,options: any={limit: 100})
options:{limit}/** * limit : * Number of returned data * Default 100; * max 5000; * Valid:[5, 10, 20, 50, 100, 500, 1000, 5000] * */client.historicalTrades(symbol: string,options: any={limit: 500})
options:{limit,fromId}/** * * limit : * Number of returned data * Default 500; * max 1000; * * fromId: * Trade id to fetch from. Default gets most recent trades * */client.aggTrades(symbol: string,options: any={limit: 500})
options:{fromId,startTime,endTime,limit}/** * * fromId : * id to get aggregate trades from INCLUSIVE * * startTime: * start at * * endTime: * end at * * limit : * Number of returned data * Default 500; * max 1000; * */client.klines(symbol: string,interval: string,options: any={limit: 500})
options:{startTime,endTime,limit}/** * * interval : * m :minute; * h :Hour; * d :day; * w :week; * M :month * example : "1m" * * startTime : * start at * * endTime : * end at * * limit : * Number of returned data * Default 500; * max 1000; * */client.avgPrice(symbol: string)client.ticker24hr(symbol?: string)client.tickerPrice(symbol?: string)client.bookTicker(symbol?: string)client.newOrderTest(symbol: string,side: string,orderType: string,options: any={})
options:{timeInForce,quantity,quoteOrderQty,price,newClientOrderId,stopPrice,icebergQty,newOrderRespType,recvWindow}/** * * side: * Order side * ENUM: * BUY * SELL * * orderType: * Order type * ENUM: * LIMIT * MARKET * STOP_LOSS * STOP_LOSS_LIMIT * TAKE_PROFIT * TAKE_PROFIT_LIMIT * LIMIT_MAKER * * timeInForce : * How long an order will be active before expiration. * GTC: Active unless the order is canceled * IOC: Order will try to fill the order as much as it can before the order expires * FOK: Active unless the full order cannot be filled upon execution. * * quantity : * target quantity * * quoteOrderQty : * Specify the total spent or received * * price : * target price * * newClientOrderId : * A unique id among open orders. Automatically generated if not sent * * stopPrice : * sed with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders * * icebergQty : * Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order * * newOrderRespType : * Set the response JSON. ACK, RESULT, or FULL; * MARKET and LIMIT order types default to FULL, all other orders default to ACK * * recvWindow : * Delay accept time * The value cannot be greater than 60000 * defaults: 5000 * */client.newOrder(symbol: string,side: string,orderType: string,options: any={})
options:{timeInForce,quantity,quoteOrderQty,price,newClientOrderId,stopPrice,icebergQty,newOrderRespType,recvWindow}/** * * side: * Order side * ENUM: * BUY * SELL * * orderType: * Order type * ENUM: * LIMIT * MARKET * STOP_LOSS * STOP_LOSS_LIMIT * TAKE_PROFIT * TAKE_PROFIT_LIMIT * LIMIT_MAKER * * timeInForce : * How long an order will be active before expiration. * GTC: Active unless the order is canceled * IOC: Order will try to fill the order as much as it can before the order expires * FOK: Active unless the full order cannot be filled upon execution. * * quantity : * target quantity * * quoteOrderQty : * Specify the total spent or received * * price : * target price * * newClientOrderId : * A unique id among open orders. Automatically generated if not sent * * stopPrice : * sed with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders * * icebergQty : * Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order * * newOrderRespType : * Set the response JSON. ACK, RESULT, or FULL; * MARKET and LIMIT order types default to FULL, all other orders default to ACK * * recvWindow : * Delay accept time * The value cannot be greater than 60000 * defaults: 5000 * */client.cancelOrder(symbol: string,options:any={})
options:{orderId,origClientOrderId,newClientOrderId}/** * * Either orderId or origClientOrderId must be sent * * orderId: * target orderId * * origClientOrderId: * target origClientOrderId * * newClientOrderId: * Used to uniquely identify this cancel. Automatically generated by default. * */client.cancelOpenOrders(symbol: string)client.queryOrder(symbol: string,options:any={})
options:{orderId,origClientOrderId}/** * * Either orderId or origClientOrderId must be sent * * orderId: * target orderId * * origClientOrderId: * target origClientOrderId * */client.openOrders(symbol: string)client.allOrders(symbol: string,options: any={limit: 500})
options:{orderId,startTime,endTime,limit}/** * * orderId: * target orderId * * startTime: * start at * * endTime: * end at * * limit : * Number of returned data * Default 500; * max 1000; * */client.accountInfo()client.accountTradeList(symbol: string,options:any={limit: 500})
options:{orderId,startTime,endTime,fromId,limit}/** * * orderId: * target orderId * * startTime: * start at * * endTime: * end at * * fromId: * TradeId to fetch from. Default gets most recent trades * * limit : * Number of returned data * Default 500; * max 1000; * */