A node API wrapper for Binance. Latest version: 0.12.0, last published: 17 days ago. Start using binance-api-node in your project by running ...
binance-api-node0.12.0 • Public • Published17daysagoReadmeExploreBETA7Dependencies35Dependents171Versionsbinance-api-node
AcompleteAPIwrapperfortheBinanceAPI.
Note:ThiswrapperusesPromises,iftheyarenotsupportedinyourenvironment,youmight
wanttoaddapolyfillforthem.
ForPRsorissues,headovertothesourcerepository.
Installation
yarnaddbinance-api-node
Gettingstarted
Importthemoduleandcreateanewclient.Passingapikeysisoptionalonlyif
youdon'tplanondoingauthenticatedcalls.Youcancreateanapikey
here.
importBinancefrom'binance-api-node'
constclient=Binance()
//Authenticatedclient,canmakesignedcalls
constclient2=Binance({
apiKey:'xxx',
apiSecret:'xxx',
getTime:xxx,
})
client.time().then(time=>console.log(time))
Ifyoudonothaveanappropriatebabelconfig,youwillneedtousethebasiccommonjsrequires.
constBinance=require('binance-api-node').default
EveryRESTmethodreturnsaPromise,makingthislibraryasyncawaitready.
Followingexampleswillusetheawaitform,whichrequiressomeconfigurationyouwillhavetolookup.
TableofContents
Init
PublicRESTEndpoints
ping
time
exchangeInfo
book
candles
aggTrades
trades
dailyStats
avgPrice
prices
allBookTickers
FuturesPublicRESTEndpoints
futuresping
futurestime
futuresexchangeInfo
futuresbook
futurescandles
futuresaggTrades
futurestrades
futuresdailyStats
futuresavgPrice
futuresprices
futuresallBookTickers
futuresmarkPrice
futuresallForceOrders
DeliveryPublicRESTEndpoints
deliveryping
deliverytime
deliveryexchangeInfo
deliverybook
deliverycandles
deliveryaggTrades
deliverytrades
deliverydailyStats
deliveryavgPrice
deliveryprices
deliveryallBookTickers
deliverymarkPrice
AuthenticatedRESTEndpoints
order
orderTest
orderOco
getOrder
getOrderOco
cancelOrder
cancelOrderOco
cancelOpenOrders
openOrders
allOrders
allOrdersOCO
accountInfo
myTrades
dailyAccountSnapshot
tradesHistory
depositHistory
withdrawHistory
withdraw
depositAddress
tradeFee
capitalConfigs
universalTransfer
universalTransferHistory
assetDetail
getBnbBurn
setBnbBurn
dustLog
dustTransfer
accountCoins
lendingAccount
fundingWallet
apiPermission
Margin
marginAccountInfo
marginLoan
marginRepay
marginIsolatedAccount
marginMaxBorrow
marginCreateIsolated
marginIsolatedTransfer
marginIsolatedTransferHistory
marginOrder
marginOrderOco
marginGetOrder
disableMarginAccount
enableMarginAccount
PortfolioMargin
getPortfolioMarginAccountInfo
FuturesAuthenticatedRESTEndpoints
futuresBatchOrders
futuresGetOrder
futuresCancelBatchOrders
futuresAccountBalance
futuresUserTrades
futuresLeverageBracket
futuresLeverage
futuresMarginType
futuresPositionMargin
futuresMarginHistory
futuresIncome
DeliveryAuthenticatedRESTEndpoints
deliveryBatchOrders
deliveryGetOrder
deliveryCancelBatchOrders
deliveryAccountBalance
deliveryUserTrades
deliveryLeverageBracket
deliveryLeverage
deliveryMarginType
deliveryPositionMargin
deliveryMarginHistory
deliveryIncome
Websockets
depth
partialDepth
ticker
allTickers
miniTicker
allMiniTickers
bookTicker
candles
aggTrades
trades
user
customSubStream
FuturesWebsockets
futuresDepth
futuresPartialDepth
futuresTicker
futuresAllTickers
futuresCandles
futuresAggTrades
futuresLiquidations
futuresAllLiquidations
futuresUser
futuresCustomSubStream
DeliveryWebsockets
deliveryDepth
deliveryPartialDepth
deliveryTicker
deliveryAllTickers
deliveryCandles
deliveryAggTrades
deliveryLiquidations
deliveryAllLiquidations
deliveryUser
deliveryCustomSubStream
Common
getInfo
ErrorCodes
Init
Param
Type
Required
Info
apiKey
String
false
Requiredwhenmakingprivatecalls
apiSecret
String
false
Requiredwhenmakingprivatecalls
getTime
Function
false
Timegenerator,defaultsto()=>Date.now()
httpBase
String
false
Changesthedefaultendpoint
httpFutures
String
false
Changesthedefaultendpoint
wsBase
String
false
Changesthedefaultendpoint
wsFutures
String
false
Changesthedefaultendpoint
PublicRESTEndpoints
ping
TestconnectivitytotheAPI.
console.log(awaitclient.ping())
time
TestconnectivitytotheRestAPIandgetthecurrentservertime.
console.log(awaitclient.time())
Output
1508478457643
exchangeInfo
Getthecurrentexchangetradingrulesandsymbolinformation.Youcanoptionally
passasymboltoonlyretrieveinfoofthisspecificone.
console.log(awaitclient.exchangeInfo())
Param
Type
Required
Default
symbol
String
false
Output
{
"timezone":"UTC",
"serverTime":1508631584636,
"rateLimits":[
{
"rateLimitType":"REQUEST_WEIGHT",
"interval":"MINUTE",
"intervalNum":1,
"limit":1200
},
{
"rateLimitType":"ORDERS",
"interval":"SECOND",
"intervalNum":1,
"limit":10
},
{
"rateLimitType":"ORDERS",
"interval":"DAY",
"intervalNum":1,
"limit":100000
}
],
"exchangeFilters":[],
"symbols":[{
"symbol":"ETHBTC",
"status":"TRADING",
"baseAsset":"ETH",
"baseAssetPrecision":8,
"quoteAsset":"BTC",
"quotePrecision":8,
"orderTypes":["LIMIT","MARKET"],
"icebergAllowed":false,
"filters":[{
"filterType":"PRICE_FILTER",
"minPrice":"0.00000100",
"maxPrice":"100000.00000000",
"tickSize":"0.00000100"
},{
"filterType":"LOT_SIZE",
"minQty":"0.00100000",
"maxQty":"100000.00000000",
"stepSize":"0.00100000"
},{
"filterType":"MIN_NOTIONAL",
"minNotional":"0.00100000"
}]
}]
}
book
Gettheorderbookforasymbol.
console.log(awaitclient.book({symbol:'ETHBTC'}))
Param
Type
Required
Default
symbol
String
true
limit
Number
false
100
Output
{
lastUpdateId:17647759,
asks:
[
{price:'0.05411500',quantity:'5.55000000'},
{price:'0.05416700',quantity:'11.80100000'}
],
bids:
[
{price:'0.05395500',quantity:'2.70000000'},
{price:'0.05395100',quantity:'11.84100000'}
]
}
candles
RetrievesCandlestickforasymbol.Candlesticksareuniquelyidentifiedbytheiropentime.
console.log(awaitclient.candles({symbol:'ETHBTC'}))
Param
Type
Required
Default
Description
symbol
String
true
interval
String
false
5m
1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w,1M
limit
Number
false
500
Max1000
startTime
Number
false
endTime
Number
false
Output
;[
{
openTime:1508328900000,
open:'0.05655000',
high:'0.05656500',
low:'0.05613200',
close:'0.05632400',
volume:'68.88800000',
closeTime:1508329199999,
quoteAssetVolume:'2.29500857',
trades:85,
baseAssetVolume:'40.61900000',
},
]
aggTrades
Getcompressed,aggregatetrades.Tradesthatfillatthetime,fromthesameorder,withthesamepricewillhavethequantityaggregated.
console.log(awaitclient.aggTrades({symbol:'ETHBTC'}))
Param
Type
Required
Default
Description
symbol
String
true
fromId
String
false
IDtogetaggregatetradesfromINCLUSIVE.
startTime
Number
false
TimestampinmstogetaggregatetradesfromINCLUSIVE.
endTime
Number
false
TimestampinmstogetaggregatetradesuntilINCLUSIVE.
limit
Number
false
500
Max500
Note:IfbothstartTimeandendTimearesent,limitshouldnotbesentANDthedistancebetweenstartTimeandendTimemustbelessthan24hours.
Note:IffrondId,startTime,andendTimearenotsent,themostrecentaggregatetradeswillbereturned.
Output
;[
{
aggId:2107132,
symbol:'ETHBTC',
price:'0.05390400',
quantity:'1.31000000',
firstId:2215345,
lastId:2215345,
timestamp:1508478599481,
isBuyerMaker:true,
wasBestPrice:true,
},
]
trades
Getrecenttradesofasymbol.
console.log(awaitclient.trades({symbol:'ETHBTC'}))
Param
Type
Required
Default
Description
symbol
String
true
limit
Number
false
500
Max500
Output
;[
{
id:28457,
price:'4.00000100',
qty:'12.00000000',
time:1499865549590,
isBuyerMaker:true,
isBestMatch:true,
},
]
dailyStats
24hourpricechangestatistics,notprovidingasymbolwillreturnalltickersandisresource-expensive.
console.log(awaitclient.dailyStats({symbol:'ETHBTC'}))
Param
Type
Required
symbol
String
false
Output
{
symbol:'ETHBTC',
priceChange:'-0.00112000',
priceChangePercent:'-1.751',
weightedAvgPrice:'0.06324784',
prevClosePrice:'0.06397400',
lastPrice:'0.06285500',
lastQty:'0.63500000',
bidPrice:'0.06285500',
bidQty:'0.81900000',
askPrice:'0.06291900',
askQty:'2.93800000',
openPrice:'0.06397500',
highPrice:'0.06419100',
lowPrice:'0.06205300',
volume:'126240.37200000',
quoteVolume:'7984.43091340',
openTime:1521622289427,
closeTime:1521708689427,
firstId:45409308,//FirsttradeId
lastId:45724293,//LasttradeId
count:314986//Tradecount
}
avgPrice
Currentaveragepriceforasymbol.
console.log(awaitclient.avgPrice({symbol:'ETHBTC'}))
Param
Type
Required
symbol
String
true
Output
{
"mins":5,
"price":"9.35751834"
}
prices
Latestpriceforasymbol,notprovidingthesymbolwillreturnpricesforallsymbols.
console.log(awaitclient.prices())
Param
Type
Required
symbol
String
false
Output
{
ETHBTC:'0.05392500',
LTCBTC:'0.01041100',
...
}
allBookTickers
Bestprice/qtyontheorderbookforallsymbols.
console.log(awaitclient.allBookTickers())
Output
{
DASHBTC:{
symbol:'DASHBTC',
bidPrice:'0.04890400',
bidQty:'0.74100000',
askPrice:'0.05230000',
askQty:'0.79900000'
},
DASHETH:{
symbol:'DASHETH',
bidPrice:'0.89582000',
bidQty:'0.63300000',
askPrice:'1.02328000',
askQty:'0.99900000'
}
...
}
FuturesPublicRESTEndpoints
futuresping
TestconnectivitytotheAPI.
console.log(awaitclient.futuresPing())
futurestime
TestconnectivitytotheRestAPIandgetthecurrentservertime.
console.log(awaitclient.futuresTime())
Output
1508478457643
futuresexchangeInfo
Getthecurrentexchangetradingrulesandsymbolinformation.
console.log(awaitclient.futuresExchangeInfo())
Output
{
"timezone":"UTC",
"serverTime":1508631584636,
"rateLimits":[
{
"rateLimitType":"REQUEST_WEIGHT",
"interval":"MINUTE",
"intervalNum":1,
"limit":1200
},
{
"rateLimitType":"ORDERS",
"interval":"SECOND",
"intervalNum":1,
"limit":10
},
{
"rateLimitType":"ORDERS",
"interval":"DAY",
"intervalNum":1,
"limit":100000
}
],
"exchangeFilters":[],
"symbols":[...]
}
futuresbook
Gettheorderbookforasymbol.
console.log(awaitclient.futuresBook({symbol:'BTCUSDT'}))
Param
Type
Required
Default
symbol
String
true
limit
Number
false
100
Output
{
lastUpdateId:17647759,
asks:
[
{price:'8000.05411500',quantity:'54.55000000'},
{price:'8000.05416700',quantity:'1111.80100000'}
],
bids:
[
{price:'8000.05395500',quantity:'223.70000000'},
{price:'8000.05395100',quantity:'1134.84100000'}
]
}
futurescandles
RetrievesCandlestickforasymbol.Candlesticksareuniquelyidentifiedbytheiropentime.
console.log(awaitclient.futuresCandles({symbol:'BTCUSDT'}))
Param
Type
Required
Default
Description
symbol
String
true
interval
String
false
5m
1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w,1M
limit
Number
false
500
Max1000
startTime
Number
false
endTime
Number
false
Output
;[
{
openTime:1508328900000,
open:'0.05655000',
high:'0.05656500',
low:'0.05613200',
close:'0.05632400',
volume:'68.88800000',
closeTime:1508329199999,
quoteAssetVolume:'2.29500857',
trades:85,
baseAssetVolume:'40.61900000',
},
]
futuresaggTrades
Getcompressed,aggregatetrades.Tradesthatfillatthetime,fromthesameorder,withthesamepricewillhavethequantityaggregated.
console.log(awaitclient.futuresAggTrades({symbol:'ETHBTC'}))
Param
Type
Required
Default
Description
symbol
String
true
fromId
String
false
IDtogetaggregatetradesfromINCLUSIVE.
startTime
Number
false
TimestampinmstogetaggregatetradesfromINCLUSIVE.
endTime
Number
false
TimestampinmstogetaggregatetradesuntilINCLUSIVE.
limit
Number
false
500
Max500
Note:IfbothstartTimeandendTimearesent,limitshouldnotbesentANDthedistancebetweenstartTimeandendTimemustbelessthan24hours.
Note:IffrondId,startTime,andendTimearenotsent,themostrecentaggregatetradeswillbereturned.
Output
;[
{
aggId:2107132,
price:'0.05390400',
quantity:'1.31000000',
firstId:2215345,
lastId:2215345,
timestamp:1508478599481,
isBuyerMaker:true,
wasBestPrice:true,
},
]
futurestrades
Getrecenttradesofasymbol.
console.log(awaitclient.futuresTrades({symbol:'ETHBTC'}))
Param
Type
Required
Default
Description
symbol
String
true
limit
Number
false
500
Max500
Output
;[
{
id:28457,
price:'4.00000100',
qty:'12.00000000',
time:1499865549590,
isBuyerMaker:true,
isBestMatch:true,
},
]
futuresdailyStats
24hourpricechangestatistics,notprovidingasymbolwillreturnalltickersandisresource-expensive.
console.log(awaitclient.futuresDailyStats({symbol:'ETHBTC'}))
Param
Type
Required
symbol
String
false
Output
{
symbol:'BTCUSDT',
priceChange:'-0.00112000',
priceChangePercent:'-1.751',
weightedAvgPrice:'0.06324784',
prevClosePrice:'0.06397400',
lastPrice:'0.06285500',
lastQty:'0.63500000',
bidPrice:'0.06285500',
bidQty:'0.81900000',
askPrice:'0.06291900',
askQty:'2.93800000',
openPrice:'0.06397500',
highPrice:'0.06419100',
lowPrice:'0.06205300',
volume:'126240.37200000',
quoteVolume:'7984.43091340',
openTime:1521622289427,
closeTime:1521708689427,
firstId:45409308,//FirsttradeId
lastId:45724293,//LasttradeId
count:314986//Tradecount
}
futuresprices
Latestpriceforallsymbols.
console.log(awaitclient.futuresPrices())
Output
{
BTCUSDT:'8590.05392500',
ETHUSDT:'154.1100',
...
}
futuresallBookTickers
Bestprice/qtyontheorderbookforallsymbols.
console.log(awaitclient.futuresAllBookTickers())
Output
{
BTCUSDT:{
symbol:'BTCUSDT',
bidPrice:'0.04890400',
bidQty:'0.74100000',
askPrice:'0.05230000',
askQty:'0.79900000'
},
ETHUSDT:{
symbol:'ETHUSDT',
bidPrice:'0.89582000',
bidQty:'0.63300000',
askPrice:'1.02328000',
askQty:'0.99900000'
}
...
}
futuresmarkPrice
MarkPriceandFundingRate.
console.log(awaitclient.futuresMarkPrice())
Output
{
"symbol":"BTCUSDT",
"markPrice":"11012.80409769",
"lastFundingRate":"-0.03750000",
"nextFundingTime":1562569200000,
"time":1562566020000
}
futuresAllForceOrders
GetallLiquidationOrders.
console.log(awaitclient.futuresAllForceOrders())
Param
Type
Required
symbol
String
false
startTime
Long
false
endTime
Long
false
limit
Long
false
Output
;[
{
symbol:'BTCUSDT',//SYMBOL
price:'7918.33',//ORDER_PRICE
origQty:'0.014',//ORDER_AMOUNT
executedQty:'0.014',//FILLED_AMOUNT
avragePrice:'7918.33',//AVG_PRICE
status:'FILLED',//STATUS
timeInForce:'IOC',//TIME_IN_FORCE
type:'LIMIT',
side:'SELL',//DIRECTION
time:1568014460893,
},
]
DeliveryPublicRESTEndpoints
deliveryping
TestconnectivitytotheAPI.
console.log(awaitclient.deliveryPing())
deliverytime
TestconnectivitytotheRestAPIandgetthecurrentservertime.
console.log(awaitclient.deliveryTime())
Output
1508478457643
deliveryexchangeInfo
Getthecurrentexchangetradingrulesandsymbolinformation.
console.log(awaitclient.deliveryExchangeInfo())
Output
{
timezone:'UTC',
serverTime:1663099219744,
rateLimits:[
{
rateLimitType:'REQUEST_WEIGHT',
interval:'MINUTE',
intervalNum:1,
limit:2400
},
{
rateLimitType:'ORDERS',
interval:'MINUTE',
intervalNum:1,
limit:1200
}
],
exchangeFilters:[],
symbols:[...]
}
deliverybook
Gettheorderbookforasymbol.
console.log(awaitclient.deliveryBook({symbol:'TRXUSD_PERP'}))
Param
Type
Required
Default
symbol
String
true
limit
Number
false
500
Output
{
lastUpdateId:17647759,
asks:
[
{price:'8000.05411500',quantity:'54.55000000'},
{price:'8000.05416700',quantity:'1111.80100000'}
],
bids:
[
{price:'8000.05395500',quantity:'223.70000000'},
{price:'8000.05395100',quantity:'1134.84100000'}
]
}
deliverycandles
RetrievesCandlestickforasymbol.Candlesticksareuniquelyidentifiedbytheiropentime.
console.log(awaitclient.deliveryCandles({symbol:'TRXUSD_PERP'}))
Param
Type
Required
Default
Description
symbol
String
true
interval
String
false
5m
1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w,1M
limit
Number
false
500
Max1000
startTime
Number
false
endTime
Number
false
Output
[
{
openTime:1663104600000,
open:'0.06091',
high:'0.06091',
low:'0.06086',
close:'0.06090',
volume:'7927',
closeTime:1663104899999,
baseVolume:'1302212.12820796',
trades:75,
quoteAssetVolume:'386',
baseAssetVolume:'63382.78318786'
}
]
deliveryaggTrades
Getcompressed,aggregatetrades.Tradesthatfillatthetime,fromthesameorder,withthesamepricewillhavethequantityaggregated.
console.log(awaitclient.deliveryAggTrades({symbol:'TRXUSD_PERP'}))
Param
Type
Required
Default
Description
symbol
String
true
fromId
String
false
IDtogetaggregatetradesfromINCLUSIVE.
startTime
Number
false
TimestampinmstogetaggregatetradesfromINCLUSIVE.
endTime
Number
false
TimestampinmstogetaggregatetradesuntilINCLUSIVE.
limit
Number
false
500
Max1000
Note:IfbothstartTimeandendTimearesent,limitshouldnotbesentANDthedistancebetweenstartTimeandendTimemustbelessthan24hours.
Note:IffromId,startTime,andendTimearenotsent,themostrecentaggregatetradeswillbereturned.
Note:Onlymarkettradeswillbeaggregatedandreturned,whichmeanstheinsurancefundtradesandADLtradeswon'tbeaggregated.
Output
[
{
aggId:14642023,
symbol:'TRXUSD_PERP',
price:'0.06087',
quantity:'50',
firstId:26319898,
lastId:26319898,
timestamp:1663105187120,
isBuyerMaker:false,
}
]
deliverytrades
Getrecenttradesofasymbol.
console.log(awaitclient.deliveryTrades({symbol:'TRXUSD_PERP'}))
Param
Type
Required
Default
Description
symbol
String
true
limit
Number
false
500
Max1000
Output
;[
{
id:26319660,
price:'0.06097',
qty:'28',
baseQty:'4592.42250287',
time:1663103746267,
isBuyerMaker:true
},
]
deliverydailyStats
24hourpricechangestatistics,notprovidingasymbolwillreturnalltickersandisresource-expensive.
console.log(awaitclient.deliveryDailyStats({symbol:'TRXUSD_PERP'}))
Param
Type
Required
symbol
String
false
pair
String
false
Output
{
symbol:'TRXUSD_PERP',
pair:'TRXUSD',
priceChange:'-0.00277',
priceChangePercent:'-4.353',
weightedAvgPrice:'0.06248010',
lastPrice:'0.06087',
lastQty:'4',
openPrice:'0.06364',
highPrice:'0.06395',
lowPrice:'0.06069',
volume:'545316',
baseVolume:'87278342.48218514',
openTime:1663019640000,
closeTime:1663106045576,
firstId:26308774,
lastId:26320065,
count:11292
}
deliveryprices
Latestpriceforallsymbols.
console.log(awaitclient.futuresPrices())
Output
{
BTCUSDT:'8590.05392500',
ETHUSDT:'154.1100',
...
}
deliveryallBookTickers
Bestprice/qtyontheorderbookforallsymbols.
console.log(awaitclient.deliveryAllBookTickers())
Output
{
BTCUSD_PERP:{
symbol:'BTCUSD_PERP',
pair:'BTCUSD',
bidPrice:'20120.9',
bidQty:'13673',
askPrice:'20121.0',
askQty:'2628',
time:1663106372658
},
ETHUSD_PERP:{
symbol:'ETHUSD_PERP',
pair:'ETHUSD',
bidPrice:'1593.63',
bidQty:'7210',
askPrice:'1593.64',
askQty:'27547',
time:1663106372667
}
...
}
deliverymarkPrice
MarkPriceandFundingRate.
console.log(awaitclient.deliveryMarkPrice())
Output
[
{
symbol:'BTCUSD_221230',
pair:'BTCUSD',
markPrice:'20158.81560758',
indexPrice:'20152.05327273',
estimatedSettlePrice:'20147.96717735',
lastFundingRate:'',
interestRate:'',
nextFundingTime:0,
time:1663106459005
},
{
symbol:'FILUSD_PERP',
pair:'FILUSD',
markPrice:'5.88720470',
indexPrice:'5.89106242',
estimatedSettlePrice:'5.89377086',
lastFundingRate:'0.00010000',
interestRate:'0.00010000',
nextFundingTime:1663113600000,
time:1663106459005
}
...
]
AuthenticatedRESTEndpoints
Notethatforallauthenticatedendpoints,youcanpassanextraparameter
useServerTimesettotrueinordertofetchtheservertimebeforemaking
therequest.
order
Createsaneworder.
console.log(
awaitclient.order({
symbol:'XLMETH',
side:'BUY',
quantity:'100',
price:'0.0002',
}),
)
Param
Type
Required
Default
Description
symbol
String
true
side
String
true
BUY,SELL
type
String
false
LIMIT
LIMIT,MARKET
quantity
String
true
price
String
true
OptionalforMARKETorders
timeInForce
String
false
GTC
FOK,GTC,IOC
newClientOrderId
String
false
Auniqueidfortheorder.Automaticallygeneratedifnotsent.
stopPrice
Number
false
Usedwithstoporders
activationPrice
Number
false
UsedwithTRAILING_STOP_MARKET
callbackRate
Number
false
UsedwithTRAILING_STOP_MARKET
newOrderRespType
String
false
RESULT
Returnsmorecompleteinfooftheorder.ACK,RESULT,orFULL
icebergQty
Number
false
Usedwithicebergorders
recvWindow
Number
false
Additionalmandatoryparametersbasedontype:
Type
Additionalmandatoryparameters
LIMIT
timeInForce,quantity,price
MARKET
quantity
STOP
quantity,price,stopPrice
STOP_LOSS_LIMIT
timeInForce,quantity,price,stopPrice
STOP_LOSS_MARKET
stopPrice
TAKE_PROFIT
quantity,price,stopPrice
TAKE_PROFIT_MARKET
stopPrice
STOP_PROFIT_LIMIT
timeInForce,quantity,price,stopPrice
LIMIT_MAKER
quantity,price
TRAILING_STOP_MARKET
callbackRate,activationPrice
LIMIT_MAKERareLIMITordersthatwillberejectediftheywouldimmediatelymatchandtradeasataker.
STOPandTAKE_PROFITwillexecuteaMARKETorderwhenthestopPriceisreached.
AnyLIMITorLIMIT_MAKERtypeordercanbemadeanicebergorderbysendinganicebergQty.
AnyorderwithanicebergQtyMUSThavetimeInForcesettoGTC.
Output
{
symbol:'XLMETH',
orderId:1740797,
clientOrderId:'1XZTVBTGS4K1e',
transactTime:1514418413947,
price:'0.00020000',
origQty:'100.00000000',
executedQty:'0.00000000',
status:'NEW',
timeInForce:'GTC',
type:'LIMIT',
side:'BUY'
}
orderTest
Testnewordercreationandsignature/recvWindow.Createsandvalidatesaneworderbutdoesnotsenditintothematchingengine.
SameAPIasabove,butdoesnotreturnanyoutputonsuccess.
orderOco
CreatesanewOCOorder.
console.log(
awaitclient.orderOco({
symbol:'XLMETH',
side:'SELL',
quantity:100,
price:0.0002,
stopPrice:0.0001,
stopLimitPrice:0.0001,
}),
)
Param
Type
Required
Description
symbol
String
true
listClientOrderId
String
false
AuniqueIdfortheentireorderList
side
String
true
BUY,SELL
quantity
Number
true
limitClientOrderId
String
false
AuniqueIdforthelimitorder
price
Number
true
limitIcebergQty
Number
false
UsedtomaketheLIMIT_MAKERleganicebergorder.
stopClientOrderId
String
false
AuniqueIdforthestoploss/stoplosslimitleg
stopPrice
Number
true
stopLimitPrice
Number
false
Ifprovided,stopLimitTimeInForceisrequired.
stopIcebergQty
Number
false
UsedwithSTOP_LOSS_LIMITlegtomakeanicebergorder.
stopLimitTimeInForce
String
false
FOK,GTC,IOC
newOrderRespType
String
false
Returnsmorecompleteinfooftheorder.ACK,RESULT,orFULL
recvWindow
Number
false
Thevaluecannotbegreaterthan60000
AdditionalInfo:
PriceRestrictions:
SELL:LimitPrice>LastPrice>StopPrice
BUY:LimitPrice=thatorderId.Otherwisemostrecentordersarereturned.
limit
Number
false
500
Max500
recvWindow
Number
false
Output
;[
{
symbol:'ENGETH',
orderId:191938,
clientOrderId:'1XZTVBTGS4K1e',
price:'0.00138000',
origQty:'1.00000000',
executedQty:'1.00000000',
status:'FILLED',
timeInForce:'GTC',
type:'LIMIT',
side:'SELL',
stopPrice:'0.00000000',
icebergQty:'0.00000000',
time:1508611114735,
isWorking:true,
},
]
allOrdersOCO
RetrievesallOCObasedonprovidedoptionalparameters
console.log(
awaitclient.allOrdersOCO({
timestamp:1565245913483,
}),
)
Param
Type
Required
Default
Description
timestamp
Number
true
startTime
Number
false
endTime
Number
false
limit
Integer
false
500
Max1000
recvWindow
Number
false
Thevaluecannotbegreaterthan60000
formId
Number
false
Ifsupplied,neitherstartTimeorendTimecanbeprovided
Output
;[
{
"orderListId":29,
"contingencyType":"OCO",
"listStatusType":"EXEC_STARTED",
"listOrderStatus":"EXECUTING",
"listClientOrderId":"amEEAXryFzFwYF1FeRpUoZ",
"transactionTime":1565245913483,
"symbol":"LTCBTC",
"orders":[
{
"symbol":"LTCBTC",
"orderId":4,
"clientOrderId":"oD7aesZqjEGlZrbtRpy5zB"
},
{
"symbol":"LTCBTC",
"orderId":5,
"clientOrderId":"Jr1h6xirOxgeJOUuYQS7V3"
}
]
},
{
"orderListId":28,
"contingencyType":"OCO",
"listStatusType":"EXEC_STARTED",
"listOrderStatus":"EXECUTING",
"listClientOrderId":"hG7hFNxJV6cZy3Ze4AUT4d",
"transactionTime":1565245913407,
"symbol":"LTCBTC",
"orders":[
{
"symbol":"LTCBTC",
"orderId":2,
"clientOrderId":"j6lFOfbmFMRjTYA7rRJ0LP"
},
{
"symbol":"LTCBTC",
"orderId":3,
"clientOrderId":"z0KCjOdditiLS5ekAFtK81"
}
]
}
]
accountInfo
Getcurrentaccountinformation.
console.log(awaitclient.accountInfo())
Param
Type
Required
recvWindow
Number
false
Output
{
makerCommission:10,
takerCommission:10,
buyerCommission:0,
sellerCommission:0,
canTrade:true,
canWithdraw:true,
canDeposit:true,
balances:[
{asset:'BTC',free:'0.00000000',locked:'0.00000000'},
{asset:'LTC',free:'0.00000000',locked:'0.00000000'},
]
}
myTrades
Gettradesforthecurrentauthenticatedaccountandsymbol.
console.log(
awaitclient.myTrades({
symbol:'ETHBTC',
}),
)
Param
Type
Required
Default
Description
symbol
String
true
limit
Number
false
500
Max1000
fromId
Number
false
TradeIdtofetchfrom.Defaultgetsmostrecenttrades.
orderId
Number
false
Thiscanonlybeusedincombinationwithsymbol.
startTime
Number
false
endTime
Number
false
recvWindow
Number
false
5000
Thevaluecannotbegreaterthan60000.
Output
;[
{
id:9960,
orderId:191939,
price:'0.00138000',
qty:'10.00000000',
commission:'0.00001380',
commissionAsset:'ETH',
time:1508611114735,
isBuyer:false,
isMaker:false,
isBestMatch:true,
},
]
dailyAccountSnapshot
Getassetsnapshotforthecurrentauthenticatedaccount.
console.log(
awaitclient.accountSnapshot({
"type":"SPOT"
});
)
Param
Type
Required
Default
Description
type
String
true
startTime
Number
false
endTime
Number
false
limit
Number
false
5
min5,max30,default5
recvWindow
Number
false
Output
{
"code":200,//200forsuccess;othersareerrorcodes
"msg":"",//errormessage
"snapshotVos":[
{
"data":{
"balances":[
{
"asset":"BTC",
"free":"0.09905021",
"locked":"0.00000000"
},
{
"asset":"USDT",
"free":"1.89109409",
"locked":"0.00000000"
}
],
"totalAssetOfBtc":"0.09942700"
},
"type":"spot",
"updateTime":1576281599000
}
]
}
tradesHistory
Lookupsymboltradeshistory.
console.log(awaitclient.tradesHistory({symbol:'ETHBTC'}))
Param
Type
Required
Default
Description
symbol
String
true
limit
Number
false
500
Max500
fromId
Number
false
null
TradeIdtofetchfrom.Defaultgetsmostrecenttrades.
Output
;[
{
id:28457,
price:'4.00000100',
qty:'12.00000000',
time:1499865549590,
isBuyerMaker:true,
isBestMatch:true,
},
]
withdrawHistory
Gettheaccountwithdrawhistory.
console.log(awaitclient.withdrawHistory())
Param
Type
Required
Description
asset
String
false
status
Number
false
0(0:EmailSent,1:Cancelled2:AwaitingApproval,3:Rejected,4:Processing,5:Failure,6:Completed)
offset
Number
false
limit
Number
false
startTime
Number
false
endTime
Number
false
recvWindow
Number
false
Output
[
{
"address":"0x94df8b352de7f46f64b01d3666bf6e936e44ce60",
"amount":"8.91000000",
"applyTime":"2019-10-1211:12:02",
"coin":"USDT",
"id":"b6ae22b3aa844210a7041aee7589627c",
"withdrawOrderId":"WITHDRAWtest123",//willnotbereturnedifthere'snowithdrawOrderIdforthiswithdraw.
"network":"ETH",
"transferType":0,//1forinternaltransfer,0forexternaltransfer
"status":6,
"txId":"0xb5ef8c13b968a406cc62a93a8bd80f9e9a906ef1b3fcf20a2e48573c17659268"
},
{
"address":"1FZdVHtiBqMrWdjPyRPULCUceZPJ2WLCsB",
"amount":"0.00150000",
"applyTime":"2019-09-2412:43:45",
"coin":"BTC",
"id":"156ec387f49b41df8724fa744fa82719",
"network":"BTC",
"status":6,
"txId":"60fd9007ebfddc753455f95fafa808c4302c836e4d1eebc5a132c36c1d8ac354"
}
]
withdraw
Triggersthewithdrawprocess(untestedfornow).
console.log(
awaitclient.withdraw({
asset:'ETH',
address:'0xfa97c22a03d8522988c709c24283c0918a59c795',
amount:100,
}),
)
Param
Type
Required
Description
asset
String
true
address
String
true
amount
Number
true
name
String
false
Descriptionoftheaddress
recvWindow
Number
false
Output
{
"id":"7213fea8e94b4a5593d507237e5a555b"
}
depositAddress
Fetchdepositaddresswithnetwork.
console.log(awaitclient.depositAddress({coin:'NEO'}))
Param
Type
Required
Description
coin
String
true
Thecoinname
network
String
false
Thenetworkname
Output
{
address:'AM6ytPW78KYxQCmU2pHYGcee7GypZ7Yhhc',
coin:'NEO',
tag:'',
url:'https://neoscan.io/address/AM6ytPW78KYxQCmU2pHYGcee7GypZ7Yhhc'
}
depositHistory
Fetchdepositaddresswithnetwork.
console.log(awaitclient.depositHistory())
Param
Type
Required
Description
coin
String
false
Thecoinname
status
Number
false
0(0:pending,6:creditedbutcannotwithdraw,1:success)
startTime
Number
false
Default:90daysfromcurrenttimestamp
endTime
Number
false
Default:presenttimestamp
offset
Number
false
default:0
limit
Number
false
recvWindow
Number
false
Output
[
{
"amount":"0.00999800",
"coin":"PAXG",
"network":"ETH",
"status":1,
"address":"0x788cabe9236ce061e5a892e1a59395a81fc8d62c",
"addressTag":"",
"txId":"0xaad4654a3234aa6118af9b4b335f5ae81c360b2394721c019b5d1e75328b09f3",
"insertTime":1599621997000,
"transferType":0,
"confirmTimes":"12/12"
},
{
"amount":"0.50000000",
"coin":"IOTA",
"network":"IOTA",
"status":1,
"address":"SIZ9VLMHWATXKV99LH99CIGFJFUMLEHGWVZVNNZXRJJVWBPHYWPPBOSDORZ9EQSHCZAMPVAPGFYQAUUV9DROOXJLNW",
"addressTag":"",
"txId":"ESBFVQUTPIWQNJSPXFNHNYHSQNTGKRVKPRABQWTAXCDWOAKDKYWPTVG9BGXNVNKTLEJGESAVXIKIZ9999",
"insertTime":1599620082000,
"transferType":0,
"confirmTimes":"1/1"
}
]
tradeFee
RetrievetheaccounttradeFeeperasset.
console.log(awaitclient.tradeFee())
Output
[
{
"symbol":"ADABNB",
"makerCommission":0.9000,
"takerCommission":1.0000
},
{
"symbol":"BNBBTC",
"makerCommission":0.3000,
"takerCommission":0.3000
}
]
capitalConfigs
Getinformationofcoins(availablefordepositandwithdraw)foruser.
console.log(awaitclient.capitalConfigs())
Output
[
{
'coin':'CTR',
'depositAllEnable':false,
'free':'0.00000000',
'freeze':'0.00000000',
'ipoable':'0.00000000',
'ipoing':'0.00000000',
'isLegalMoney':false,
'locked':'0.00000000',
'name':'Centra',
'networkList':[
{
'addressRegex':'^(0x)[0-9A-Fa-f]{40}$',
'coin':'CTR',
'depositDesc':'Delisted,DepositSuspended',
'depositEnable':false,
'isDefault':true,
'memoRegex':'',
'minConfirm':12,
'name':'ERC20',
'network':'ETH',
'resetAddressStatus':false,
'specialTips':'',
'unLockConfirm':0,
'withdrawDesc':'',
'withdrawEnable':true,
'withdrawFee':'35.00000000',
'withdrawIntegerMultiple':'0.00000001',
'withdrawMax':'0.00000000',
'withdrawMin':'70.00000000'
}
],
'storage':'0.00000000',
'trading':false,
'withdrawAllEnable':true,
'withdrawing':'0.00000000'
}
]
universalTransfer
YouneedtoenablePermitsUniversalTransferoptionfortheapikeywhichrequeststhisendpoint.
console.log(awaitclient.universalTransfer({type:'MAIN_C2C',asset:'USDT',amount:'1000'}))
Param
Type
Required
Description
type
String
true
asset
String
true
amount
String
true
recvWindow
Number
false
Output
{
tranId:13526853623
}
universalTransferHistory
console.log(awaitclient.universalTransferHistory({type:'MAIN_C2C'}))
Param
Type
Required
Description
type
String
true
startTime
Number
false
endTime
Number
false
current
Number
false
Default1
size
Number
false
Default10,Max100
recvWindow
Number
false
Output
{
"total":2,
"rows":[
{
"asset":"USDT",
"amount":"1",
"type":"MAIN_C2C"
"status":"CONFIRMED",
"tranId":11415955596,
"timestamp":1544433328000
},
{
"asset":"USDT",
"amount":"2",
"type":"MAIN_C2C",
"status":"CONFIRMED",
"tranId":11366865406,
"timestamp":1544433328000
}
]
}
assetDetail
console.log(awaitclient.assetDetail())
Param
Type
Required
Description
recvWindow
Number
false
Output
{
"CTR":{
"minWithdrawAmount":"70.00000000",//minwithdrawamount
"depositStatus":false,//depositstatus(falseifALLofnetworks'arefalse)
"withdrawFee":35,//withdrawfee
"withdrawStatus":true,//withdrawstatus(falseifALLofnetworks'arefalse)
"depositTip":"Delisted,DepositSuspended"//reason
},
"SKY":{
"minWithdrawAmount":"0.02000000",
"depositStatus":true,
"withdrawFee":0.01,
"withdrawStatus":true
}
}
getBnbBurn
console.log(awaitclient.getBnbBurn())
Param
Type
Required
Description
recvWindow
Number
false
Nomorethan60000
Output
{
"spotBNBBurn":true,
"interestBNBBurn":false
}
setBnbBurn
console.log(awaitclient.setBnbBurn({spotBNBBurn:"true"}))
Param
Type
Required
Description
spotBNBBurn
String
false
"true"or"false";DetermineswhethertouseBNBtopayfortradingfeesonSPOT
interestBNBBurn
String
false
"true"or"false";DetermineswhethertouseBNBtopayformarginloan'sinterest
recvWindow
Number
false
Nomorethan60000
Output
{
"spotBNBBurn":true,
"interestBNBBurn":false
}
dustLog
console.log(awaitclient.dustLog())
Param
Type
Required
Description
startTime
Number
false
endTime
Number
false
recvWindow
Number
false
Output
{
"total":8,//Totalcountsofexchange
"userAssetDribblets":[
{
"operateTime":1615985535000,
"totalTransferedAmount":"0.00132256",
"totalServiceChargeAmount":"0.00002699",
"transId":45178372831,
"userAssetDribbletDetails":[
{
"transId":4359321,
"serviceChargeAmount":"0.000009",
"amount":"0.0009",
"operateTime":1615985535000,
"transferedAmount":"0.000441",
"fromAsset":"USDT"
},
{
"transId":4359321,
"serviceChargeAmount":"0.00001799",
"amount":"0.0009",
"operateTime":1615985535000,
"transferedAmount":"0.00088156",
"fromAsset":"ETH"
}
]
},
{
"operateTime":1616203180000,
"totalTransferedAmount":"0.00058795",
"totalServiceChargeAmount":"0.000012",
"transId":4357015,
"userAssetDribbletDetails":[
{
"transId":4357015,
"serviceChargeAmount":"0.00001",
"amount":"0.001",
"operateTime":1616203180000,
"transferedAmount":"0.00049",
"fromAsset":"USDT"
},
{
"transId":4357015,
"serviceChargeAmount":"0.000002",
"amount":"0.0001",
"operateTime":1616203180000,
"transferedAmount":"0.00009795",
"fromAsset":"ETH"
}
]
}
]
}
}
dustTransfer
console.log(awaitclient.dustTransfer({asset:['ETH','LTC','TRX']}))
Param
Type
Required
Description
asset
[String]
true
recvWindow
Number
false
Output
{
"totalServiceCharge":"0.02102542",
"totalTransfered":"1.05127099",
"transferResult":[
{
"amount":"0.03000000",
"fromAsset":"ETH",
"operateTime":1563368549307,
"serviceChargeAmount":"0.00500000",
"tranId":2970932918,
"transferedAmount":"0.25000000"
},
{
"amount":"0.09000000",
"fromAsset":"LTC",
"operateTime":1563368549404,
"serviceChargeAmount":"0.01548000",
"tranId":2970932918,
"transferedAmount":"0.77400000"
},
{
"amount":"248.61878453",
"fromAsset":"TRX",
"operateTime":1563368549489,
"serviceChargeAmount":"0.00054542",
"tranId":2970932918,
"transferedAmount":"0.02727099"
}
]
}
accountCoins
Retrieveaccountcoinsrelatedinformation.ImplementedasgetAllinBinanceDocs.
console.log(awaitclient.accountCoins())
Param
Type
Required
Description
recvWindow
Number
false
Output
[
{
"coin":"BTC",
"depositAllEnable":true,
"free":"0.08074558",
"freeze":"0.00000000",
"ipoable":"0.00000000",
"ipoing":"0.00000000",
"isLegalMoney":false,
"locked":"0.00000000",
"name":"Bitcoin",
"networkList":[
{
"addressRegex":"^(bnb1)[0-9a-z]{38}$",
"coin":"BTC",
"depositDesc":"WalletMaintenance,DepositSuspended",//shownonlywhen"depositEnable"isfalse.
"depositEnable":false,
"isDefault":false,
"memoRegex":"^[0-9A-Za-z\\-_]{1,120}$",
"minConfirm":1,//minnumberforbalanceconfirmation
"name":"BEP2",
"network":"BNB",
"resetAddressStatus":false,
"specialTips":"BothaMEMOandanAddressarerequiredtosuccessfullydeposityourBEP2-BTCBtokenstoBinance.",
"unLockConfirm":0,//confirmationnumberforbalanceunlock
"withdrawDesc":"WalletMaintenance,WithdrawalSuspended",//shownonlywhen"withdrawEnable"isfalse.
"withdrawEnable":false,
"withdrawFee":"0.00000220",
"withdrawMin":"0.00000440"
},
{
"addressRegex":"^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bc1)[0-9A-Za-z]{39,59}$",
"coin":"BTC",
"depositEnable":true,
"insertTime":1563532929000,
"isDefault":true,
"memoRegex":"",
"minConfirm":1,
"name":"BTC",
"network":"BTC",
"resetAddressStatus":false,
"specialTips":"",
"unLockConfirm":2,
"updateTime":1571014804000,
"withdrawEnable":true,
"withdrawFee":"0.00050000",
"withdrawIntegerMultiple":"0.00000001",
"withdrawMin":"0.00100000"
}
],
"storage":"0.00000000",
"trading":true,
"withdrawAllEnable":true,
"withdrawing":"0.00000000"
}
]
lendingAccount
Getinformationoflendingassetsforuser.
console.log(awaitclient.lendingAccount())
Output
{
"positionAmountVos":[
{
"amount":"75.46000000",
"amountInBTC":"0.01044819",
"amountInUSDT":"75.46000000",
"asset":"USDT"
},
{
"amount":"1.67072036",
"amountInBTC":"0.00023163",
"amountInUSDT":"1.67289230",
"asset":"BUSD"
}
],
"totalAmountInBTC":"0.01067982",
"totalAmountInUSDT":"77.13289230",
"totalFixedAmountInBTC":"0.00000000",
"totalFixedAmountInUSDT":"0.00000000",
"totalFlexibleInBTC":"0.01067982",
"totalFlexibleInUSDT":"77.13289230"
}
fundingWallet
Queryfundingwallet,includesBinancePay,BinanceCard,BinanceGiftCard,StockToken.
console.log(awaitclient.fundingWallet())
Param
Type
Required
Description
asset
String
false
needBtcValuation
String
false
'true'or'false'
Output
[
{
"asset":"USDT",
"free":"1",
"locked":"0",
"freeze":"0",
"withdrawing":"0",
"btcValuation":"0.00000091"
}
]
apiPermission
GetAPIKeyPermission.
console.log(awaitclient.apiPermission())
Param
Type
Required
Description
recvWindow
Number
false
Output
{
"ipRestrict":false,
"createTime":1623840271000,
"enableWithdrawals":false,//ThisoptionallowsyoutowithdrawviaAPI.YoumustapplytheIPAccessRestrictionfilterinordertowithdrawals
"enableInternalTransfer":true,//Thisoptionauthorizesthiskeytotransferfundsbetweenyourmasteraccountandyoursubaccountinstantly
"permitsUniversalTransfer":true,//AuthorizesthiskeytobeusedforadedicateduniversaltransferAPItotransfermultiplesupportedcurrencies.Eachbusiness'sowntransferAPIrightsarenotaffectedbythisauthorization
"enableVanillaOptions":false,//AuthorizesthiskeytoVanillaoptionstrading
"enableReading":true,
"enableFutures":false,//APIKeycreatedbeforeyourfuturesaccountopeneddoesnotsupportfuturesAPIservice
"enableMargin":false,//ThisoptioncanbeadjustedaftertheCrossMarginaccounttransferiscompleted
"enableSpotAndMarginTrading":false,//Spotandmargintrading
"tradingAuthorityExpirationTime":1628985600000//Expirationtimeforspotandmargintradingpermission
}
Margin
marginAccountInfo
Querycrossmarginaccountdetails(USER_DATA)
console.log(awaitclient.marginAccountInfo());
Param
Type
Required
Description
recvWindow
Number
false
Nomorethan60000
Output
{
"borrowEnabled":true,
"marginLevel":"11.64405625",
"totalAssetOfBtc":"6.82728457",
"totalLiabilityOfBtc":"0.58633215",
"totalNetAssetOfBtc":"6.24095242",
"tradeEnabled":true,
"transferEnabled":true,
"userAssets":[
{
"asset":"BTC",
"borrowed":"0.00000000",
"free":"0.00499500",
"interest":"0.00000000",
"locked":"0.00000000",
"netAsset":"0.00499500"
},
{
"asset":"BNB",
"borrowed":"201.66666672",
"free":"2346.50000000",
"interest":"0.00000000",
"locked":"0.00000000",
"netAsset":"2144.83333328"
},
{
"asset":"ETH",
"borrowed":"0.00000000",
"free":"0.00000000",
"interest":"0.00000000",
"locked":"0.00000000",
"netAsset":"0.00000000"
},
{
"asset":"USDT",
"borrowed":"0.00000000",
"free":"0.00000000",
"interest":"0.00000000",
"locked":"0.00000000",
"netAsset":"0.00000000"
}
]
}
marginLoan
Createaloanformarginaccount.
console.log(awaitclient.marginLoan({asset:'BTC',amount:'0.0001'}));
Param
Type
Required
Description
asset
String
true
Theassetname
amount
Number
true
Output
{
"tranId":100000001//transactionid
}
marginRepay
Repayloanformarginaccount.
console.log(awaitclient.marginRepay({asset:'BTC',amount:'0.0001'}));
Param
Type
Required
Description
asset
String
true
Theassetname
amount
Number
true
Output
{
"tranId":100000001//transactionid
}
marginIsolatedAccount
QueryIsolatedMarginAccountInfo
console.log(awaitclient.marginIsolatedAccount({symbols:'BTCUSDT'}));
Param
Type
Required
Description
symbols
String
false
Max5symbolscanbesent;separatedby","
recvWindow
Number
false
Nomorethan60000
Output
{
"assets":[
{
"baseAsset":
{
"asset":"BTC",
"borrowEnabled":true,
"borrowed":"0.00000000",
"free":"0.00000000",
"interest":"0.00000000",
"locked":"0.00000000",
"netAsset":"0.00000000",
"netAssetOfBtc":"0.00000000",
"repayEnabled":true,
"totalAsset":"0.00000000"
},
"quoteAsset":
{
"asset":"USDT",
"borrowEnabled":true,
"borrowed":"0.00000000",
"free":"0.00000000",
"interest":"0.00000000",
"locked":"0.00000000",
"netAsset":"0.00000000",
"netAssetOfBtc":"0.00000000",
"repayEnabled":true,
"totalAsset":"0.00000000"
},
"symbol":"BTCUSDT"
"isolatedCreated":true,
"marginLevel":"0.00000000",
"marginLevelStatus":"EXCESSIVE",//"EXCESSIVE","NORMAL","MARGIN_CALL","PRE_LIQUIDATION","FORCE_LIQUIDATION"
"marginRatio":"0.00000000",
"indexPrice":"10000.00000000"
"liquidatePrice":"1000.00000000",
"liquidateRate":"1.00000000"
"tradeEnabled":true
}
],
"totalAssetOfBtc":"0.00000000",
"totalLiabilityOfBtc":"0.00000000",
"totalNetAssetOfBtc":"0.00000000"
}
disableMarginAccount
InactiveIsolatedMargintradingpairforsymbol
console.log(awaitclient.disableMarginAccount({symbol:'BTCUSDT'}));
Param
Type
Required
Description
symbol
String
true
recvWindow
Number
false
Nomorethan60000
Output
{
"success":true,
"symbol":"BTCUSDT"
}
####enableMarginAccount
ActiveIsolatedMargintradingpairforsymbol
console.log(awaitclient.enableMarginAccount({symbol:'BTCUSDT'}));
Param
Type
Required
Description
symbol
String
true
recvWindow
Number
false
Nomorethan60000
Output
{
"success":true,
"symbol":"BTCUSDT"
}
marginMaxBorrow
IfisolatedSymbolisnotsent,crossedmargindatawillbesent.
console.log(awaitclient.marginMaxBorrow({asset:'BTC',isolatedSymbol:'BTCUSDT'}));
Param
Type
Required
Description
asset
String
true
isolatedSymbol
String
false
recvWindow
Number
false
Nomorethan60000
Output
{
"amount":"1.69248805",//account'scurrentlymaxborrowableamountwithsufficientsystemavailability
"borrowLimit":"60"//maxborrowableamountlimitedbytheaccountlevel
}
marginCreateIsolated
console.log(awaitclient.marginCreateIsolated({base:'BTC',quote:'USDT'}));
Param
Type
Required
Description
base
String
true
Baseassetofsymbol
quote
String
true
Quoteassetofsymbol
recvWindow
Number
false
Nomorethan60000
Output
{
"success":true,
"symbol":"BTCUSDT"
}
marginIsolatedTransfer
console.log(awaitclient.marginIsolatedTransfer({asset:'USDT',symbol:'BNBUSDT',transFrom:'ISOLATED_MARGIN',transTo:'SPOT',amount:1}));
Param
Type
Required
Description
asset
String
true
asset,suchasBTC
symbol
String
true
transFrom
String
true
"SPOT","ISOLATED_MARGIN"
transTo
String
true
"SPOT","ISOLATED_MARGIN"
amount
Number
true
recvWindow
Number
false
Nomorethan60000
Output
{
//transactionid
"tranId":100000001
}
marginIsolatedTransferHistory
console.log(awaitclient.marginIsolatedTransferHistory({symbol:'BNBUSDT'}));
Param
Type
Required
Description
asset
String
false
asset,suchasBTC
symbol
String
true
transFrom
String
false
"SPOT","ISOLATED_MARGIN"
transTo
String
false
"SPOT","ISOLATED_MARGIN"
startTime
Number
false
endTime
Number
false
current
Number
false
Currentpage,default1
size
Number
false
Default10,max100
recvWindow
Number
false
Nomorethan60000
Output
{
"rows":[
{
"amount":"0.10000000",
"asset":"BNB",
"status":"CONFIRMED",
"timestamp":1566898617000,
"txId":5240372201,
"transFrom":"SPOT",
"transTo":"ISOLATED_MARGIN"
},
{
"amount":"5.00000000",
"asset":"USDT",
"status":"CONFIRMED",
"timestamp":1566888436123,
"txId":5239810406,
"transFrom":"ISOLATED_MARGIN",
"transTo":"SPOT"
}
],
"total":2
}
marginOrder
console.log(awaitclient.marginOrder({
symbol:'BTCUSDT',
type:'MARKET',
side:'SELL',
quantity:'10',
}));
Param
Type
Required
Description
symbol
String
true
asset,suchasBTC
isIsolated
String
false
forisolatedmarginornot,TRUE,FALSE,defaultFALSE
side
String
true
BUYSELL
type
String
true
quantity
String
false
quoteOrderQty
String
false
price
String
false
stopPrice
String
false
UsedwithSTOP_LOSS,STOP_LOSS_LIMIT,TAKE_PROFIT,andTAKE_PROFIT_LIMITorders.
newClientOrderId
String
false
Auniqueidamongopenorders.Automaticallygeneratedifnotsent.
icebergQty
Boolean
false
UsedwithLIMIT,STOP_LOSS_LIMIT,andTAKE_PROFIT_LIMITtocreateanicebergorder.
newOrderRespType
String
false
SettheresponseJSON.ACK,RESULT,orFULL;MARKETandLIMITordertypesdefaulttoFULL,allotherordersdefaulttoACK.
sideEffectType
String
false
NO_SIDE_EFFECT,MARGIN_BUY,AUTO_REPAY;defaultNO_SIDE_EFFECT.
timeInForce
String
false
GTC,IOC,FOK
recvWindow
Number
false
Nomorethan60000
Output
{
"symbol":"BTCUSDT",
"orderId":28,
"clientOrderId":"6gCrw2kRUAF9CvJDGP16IP",
"transactTime":1507725176595,
"price":"1.00000000",
"origQty":"10.00000000",
"executedQty":"10.00000000",
"cummulativeQuoteQty":"10.00000000",
"status":"FILLED",
"timeInForce":"GTC",
"type":"MARKET",
"side":"SELL",
"marginBuyBorrowAmount":5,//willnotreturnifnomargintradehappens
"marginBuyBorrowAsset":"BTC",//willnotreturnifnomargintradehappens
"isIsolated":true,//ifisolatedmargin
"fills":[
{
"price":"4000.00000000",
"qty":"1.00000000",
"commission":"4.00000000",
"commissionAsset":"USDT"
},
{
"price":"3999.00000000",
"qty":"5.00000000",
"commission":"19.99500000",
"commissionAsset":"USDT"
},
{
"price":"3998.00000000",
"qty":"2.00000000",
"commission":"7.99600000",
"commissionAsset":"USDT"
},
{
"price":"3997.00000000",
"qty":"1.00000000",
"commission":"3.99700000",
"commissionAsset":"USDT"
},
{
"price":"3995.00000000",
"qty":"1.00000000",
"commission":"3.99500000",
"commissionAsset":"USDT"
}
]
}
marginOrderOco
console.log(awaitclient.marginOrderOco({
symbol:'AUDIOUSDT',
type:'MARKET',
side:'SELL',
quantity:'10',
}));
Param
Type
Required
Description
symbol
String
true
asset,suchasBTC
isIsolated
String
false
forisolatedmarginornot,TRUE,FALSE,defaultFALSE
side
String
true
BUYSELL
type
String
true
quantity
String
false
quoteOrderQty
String
false
price
String
false
stopPrice
String
false
UsedwithSTOP_LOSS,STOP_LOSS_LIMIT,TAKE_PROFIT,andTAKE_PROFIT_LIMITorders.
stopLimitPrice
String
false
UsedwithSTOP_LOSS_LIMITorders.
newClientOrderId
String
false
Auniqueidamongopenorders.Automaticallygeneratedifnotsent.
icebergQty
Boolean
false
UsedwithLIMIT,STOP_LOSS_LIMIT,andTAKE_PROFIT_LIMITtocreateanicebergorder.
newOrderRespType
String
false
SettheresponseJSON.ACK,RESULT,orFULL;MARKETandLIMITordertypesdefaulttoFULL,allotherordersdefaulttoACK.
sideEffectType
String
false
NO_SIDE_EFFECT,MARGIN_BUY,AUTO_REPAY;defaultNO_SIDE_EFFECT.
timeInForce
String
false
GTC,IOC,FOK
recvWindow
Number
false
Nomorethan60000
Output
{
"orderListId":45514668,
"contingencyType":'OCO',
"listStatusType":'EXEC_STARTED',
"listOrderStatus":'EXECUTING',
"listClientOrderId":'CD9UzEJfmcGZ4kLfZT2ga2',
"transactionTime":1632192162785,
"symbol":'AUDIOUSDT',
"isIsolated":true,
"orders":[
{
"symbol":'AUDIOUSDT',
"orderId":239313661,
"clientOrderId":'ZbUwgKv6UB8eMzf2yfXENl'
},
{
"symbol":'AUDIOUSDT',
"orderId":239313662,
"clientOrderId":'f5u1RIHAPRd4W3fFhFykBo'
}
],
"orderReports":[
{
"symbol":'AUDIOUSDT',
"orderId":239313661,
"orderListId":45514668,
"clientOrderId":'ZbUwgKv6UB8eMzf2yfXENl',
"transactTime":1632192162785,
"price":'2.20000000',
"origQty":'12.80000000',
"executedQty":'0',
"cummulativeQuoteQty":'0',
"status":'NEW',
"timeInForce":'GTC',
"type":'STOP_LOSS_LIMIT',
"side":'SELL',
"stopPrice":'2.20000000'
},
{
"symbol":'AUDIOUSDT',
"orderId":239313662,
"orderListId":45514668,
"clientOrderId":'f5u1RIHAPRd4W3fFhFykBo',
"transactTime":1632192162785,
"price":'2.50000000',
"origQty":'12.80000000',
"executedQty":'0',
"cummulativeQuoteQty":'0',
"status":'NEW',
"timeInForce":'GTC',
"type":'LIMIT_MAKER',
"side":'SELL'
}
]
}
marginGetOrder
QueryMarginAccount'sOrder
console.log(awaitclient.marginGetOrder({
symbol:'BNBBTC',
orderId:'213205622',
}));
Param
Type
Required
Description
symbol
String
true
asset,suchasBTC
isIsolated
String
false
forisolatedmarginornot,TRUE,FALSE,defaultFALSE
orderId
String
false
origClientOrderId
String
false
recvWindow
Number
false
Thevaluecannotbegreaterthan60000
Output
{
"clientOrderId":"ZwfQzuDIGpceVhKW5DvCmO",
"cummulativeQuoteQty":"0.00000000",
"executedQty":"0.00000000",
"icebergQty":"0.00000000",
"isWorking":true,
"orderId":213205622,
"origQty":"0.30000000",
"price":"0.00493630",
"side":"SELL",
"status":"NEW",
"stopPrice":"0.00000000",
"symbol":"BNBBTC",
"isIsolated":true,
"time":1562133008725,
"timeInForce":"GTC",
"type":"LIMIT",
"updateTime":1562133008725
}
PortfolioMarginEndpoints
OnlyPortfolioMarginAccountisaccessibletotheseendpoints.
getPortfolioMarginAccountInfo
GetaPortfolioMarginAccountInfo.
console.log(awaitclient.getPortfolioMarginAccountInfo())
Output
{
"uniMMR":"1.87987800",//Portfoliomarginaccountmaintenancemarginrate
"accountEquity":"122607.35137903",//Accountequity,unit:USD
"accountMaintMargin":"23.72469206",//Portfoliomarginaccountmaintenancemargin,unit:USD
"accountStatus":"NORMAL"//Portfoliomarginaccountstatus:"NORMAL","MARGIN_CALL","SUPPLY_MARGIN","REDUCE_ONLY","ACTIVE_LIQUIDATION","FORCE_LIQUIDATION","BANKRUPTED"
}
FuturesAuthenticatedRESTendpoints
futuresGetOrder
Checkanorder'sstatus.
Theseorderswillnotbefound
orderstatusisCANCELEDorEXPIRED,AND
orderhasNOfilledtrade,AND
createdtime+7days=thatorderId.Otherwisemostrecentordersarereturned.
console.log(
awaitclient.futuresAllOrders({
symbol:'BNBETH',
orderId:50167927,
startTime:1579276756075,
limit:700,
})
)
Output
[
{
"avgPrice":"0.00000",
"clientOrderId":"abc",
"cumQuote":"0",
"executedQty":"0",
"orderId":1917641,
"origQty":"0.40",
"origType":"TRAILING_STOP_MARKET",
"price":"0",
"reduceOnly":false,
"side":"BUY",
"positionSide":"SHORT",
"status":"NEW",
"stopPrice":"9300",//pleaseignorewhenordertypeisTRAILING_STOP_MARKET
"closePosition":false,//ifClose-All
"symbol":"BTCUSDT",
"time":1579276756075,//ordertime
"timeInForce":"GTC",
"type":"TRAILING_STOP_MARKET",
"activatePrice":"9020",//activationprice,onlyreturnwithTRAILING_STOP_MARKETorder
"priceRate":"0.3",//callbackrate,onlyreturnwithTRAILING_STOP_MARKETorder
"updateTime":1579276756075,//updatetime
"workingType":"CONTRACT_PRICE",
"priceProtect":false//ifconditionalordertriggerisprotected
}
]
futuresBatchOrders
Placemultipleorders
Name
Type
Mandatory
Description
batchOrders
LIST
YES
orderlist.Max5orders
futuresCancelBatchOrders
Cancelmultipleorders
Name
Type
Mandatory
Description
symbol
STRING
YES
Thepairname
orderIdList
STRING
NO
maxlength10e.g.'[1234567,2345678]'
origClientOrderIdList
STRING
NO
maxlength10e.g.'["my_id_1","my_id_2"]',encodethedoublequotes.Nospaceaftercomma.
futuresLeverage
Changeuser'sinitialleverageofspecificsymbolmarket.
Name
Type
Mandatory
Description
symbol
STRING
YES
Thepairname
leverage
INT
YES
targetinitialleverage:intfrom1to125
recvWindow
LONG
NO
console.log(
awaitclient.futuresLeverage({
symbol:'BTCUSDT',
leverage:21,
})
)
Output
{
"leverage":21,
"maxNotionalValue":"1000000",
"symbol":"BTCUSDT"
}
futuresMarginType
Changemargintype.
Name
Type
Mandatory
Description
symbol
STRING
YES
Thepairname
marginType
ENUM
YES
ISOLATED,CROSSED
recvWindow
LONG
NO
console.log(
awaitclient.futuresMarginType({
symbol:'BTCUSDT',
marginType:'ISOLATED',
})
)
Output
{
"code":200,
"msg":"success"
}
futuresPositionMargin
Modifyisolatedpositionmargin.
Name
Type
Mandatory
Description
symbol
STRING
YES
Thepairname
positionSide
ENUM
NO
DefaultBOTHforOne-wayMode;LONGorSHORTforHedgeMode.ItmustbesentwithHedgeMode.
amount
DECIMAL
YES
type
INT
YES
1:Addpositionmargin,2:Reducepositionmargin
recvWindow
LONG
NO
Onlyforisolatedsymbol.
console.log(
awaitclient.futuresPositionMargin({
symbol:'BTCUSDT',
amount:100,
type:1,
})
)
Output
{
"amount":100.0,
"code":200,
"msg":"Successfullymodifypositionmargin.",
"type":1
}
futuresMarginHistory
Getpositionmarginchangehistory.
Name
Type
Mandatory
Description
symbol
STRING
YES
Thepairname
type
INT
NO
1:Addpositionmargin,2:Reducepositionmargin
startTime
LONG
NO
endTime
LONG
NO
limit
INT
NO
Default500;
recvWindow
LONG
NO
console.log(
awaitclient.futuresMarginHistory({
symbol:'BTCUSDT',
type:1,
startTime:1579276756075,
limit:700,
})
)
Output
[
{
"amount":"23.36332311",
"asset":"USDT",
"symbol":"BTCUSDT",
"time":1578047897183,
"type":1,
"positionSide":"BOTH"
},
{
"amount":"100",
"asset":"USDT",
"symbol":"BTCUSDT",
"time":1578047900425,
"type":1,
"positionSide":"LONG"
}
]
futuresIncome
Getincomehistory.
Name
Type
Mandatory
Description
symbol
STRING
NO
Thepairname
incomeType
STRING
NO
"TRANSFER","WELCOME_BONUS","REALIZED_PNL","FUNDING_FEE","COMMISSION",and"INSURANCE_CLEAR"
startTime
LONG
NO
TimestampinmstogetfundingfromINCLUSIVE.
endTime
LONG
NO
TimestampinmstogetfundinguntilINCLUSIVE.
limit
INT
NO
Default100;max1000
recvWindow
LONG
NO
IfincomeTypeisnotsent,allkindsofflowwillbereturned
"trandId"isuniqueinthesameincomeTypeforauser
console.log(
awaitclient.futuresIncome({
symbol:'BTCUSDT',
startTime:1579276756075,
limit:700,
})
)
Output
[
{
"symbol":"",//tradesymbol,ifexisting
"incomeType":"TRANSFER",//incometype
"income":"-0.37500000",//incomeamount
"asset":"USDT",//incomeasset
"info":"TRANSFER",//extrainformation
"time":1570608000000,
"tranId":"9689322392",//transactionid
"tradeId":""//tradeid,ifexisting
},
{
"symbol":"BTCUSDT",
"incomeType":"COMMISSION",
"income":"-0.01000000",
"asset":"USDT",
"info":"COMMISSION",
"time":1570636800000,
"tranId":"9689322392",
"tradeId":"2059192"
}
]
futuresAccountBalance
Getfuturesaccountbalance
console.log(awaitclient.futuresAccountBalance());
Output
[
{
"accountAlias":"SgsR",//uniqueaccountcode
"asset":"USDT",//assetname
"balance":"122607.35137903",//walletbalance
"crossWalletBalance":"23.72469206",//crossedwalletbalance
"crossUnPnl":"0.00000000"//unrealizedprofitofcrossedpositions
"availableBalance":"23.72469206",//availablebalance
"maxWithdrawAmount":"23.72469206"//maximumamountfortransferout
}
]
futuresUserTrades
Gettradesforaspecificaccountandsymbol.
console.log(
awaitclient.futuresUserTrades({
symbol:'ETHBTC',
}),
)
Param
Type
Mandatory
Description
symbol
STRING
YES
startTime
LONG
NO
endTime
LONG
NO
limit
INT
NO
Default500;max1000.
fromId
LONG
NO
Tradeidtofetchfrom.Defaultgetsmostrecenttrades.
recvWindow
LONG
NO
Output
[
{
"buyer":false,
"commission":"-0.07819010",
"commissionAsset":"USDT",
"id":698759,
"maker":false,
"orderId":25851813,
"price":"7819.01",
"qty":"0.002",
"quoteQty":"15.63802",
"realizedPnl":"-0.91539999",
"side":"SELL",
"positionSide":"SHORT",
"symbol":"BTCUSDT",
"time":1569514978020
}
]
futuresLeverageBracket
Getnotionalandleveragebrackets.
console.log(
awaitclient.futuresLeverageBracket({
symbol:'ETHBTC',//Optional
}),
)
Param
Type
Mandatory
Description
symbol
STRING
NO
Useifyouareonlyinterestedinbracketsforonesymbol
recvWindow
LONG
NO
Output
[
{
"symbol":"ETHUSDT",
"brackets":[
{
"bracket":1,//Notionalbracket
"initialLeverage":75,//Maxinitialleverageforthisbracket
"notionalCap":10000,//Capnotionalofthisbracket
"notionalFloor":0,//Notionalthresholdofthisbracket
"maintMarginRatio":0.0065,//Maintenanceratioforthisbracket
"cum":0//Auxiliarynumberforquickcalculation
},
]
}
]
DeliveryAuthenticatedRESTendpoints
deliveryGetOrder
Checkanorder'sstatus.
Theseorderswillnotbefound
orderstatusisCANCELEDorEXPIRED,AND
orderhasNOfilledtrade,AND
createdtime+7days=thatorderId.Otherwisemostrecentordersarereturned.
console.log(
awaitclient.deliveryAllOrders({symbol:'BTCUSD_200925'})
)
Output
[
{
"avgPrice":"0.0",
"clientOrderId":"abc",
"cumBase":"0",
"executedQty":"0",
"orderId":1917641,
"origQty":"0.40",
"origType":"TRAILING_STOP_MARKET",
"price":"0",
"reduceOnly":false,
"side":"BUY",
"positionSide":"SHORT",
"status":"NEW",
"stopPrice":"9300",//pleaseignorewhenordertypeisTRAILING_STOP_MARKET
"closePosition":false,//ifClose-All
"symbol":"BTCUSD_200925",
"pair":"BTCUSD",
"time":1579276756075,//ordertime
"timeInForce":"GTC",
"type":"TRAILING_STOP_MARKET",
"activatePrice":"9020",//activationprice,onlyreturnwithTRAILING_STOP_MARKETorder
"priceRate":"0.3",//callbackrate,onlyreturnwithTRAILING_STOP_MARKETorder
"updateTime":1579276756075,//updatetime
"workingType":"CONTRACT_PRICE",
"priceProtect":false//ifconditionalordertriggerisprotected
}
...
]
deliveryBatchOrders
Placemultipleorders
Name
Type
Mandatory
Description
batchOrders
LIST
YES
orderlist.Max5orders
deliveryCancelBatchOrders
Cancelmultipleorders
Name
Type
Mandatory
Description
symbol
STRING
YES
Thepairname
orderIdList
STRING
NO
maxlength10e.g.'[1234567,2345678]'
origClientOrderIdList
STRING
NO
maxlength10e.g.'["my_id_1","my_id_2"]',encodethedoublequotes.Nospaceaftercomma.
deliveryLeverage
Changeuser'sinitialleverageofspecificsymbolmarket.
Name
Type
Mandatory
Description
symbol
STRING
YES
Thepairname
leverage
INT
YES
targetinitialleverage:intfrom1to125
recvWindow
LONG
NO
console.log(
awaitclient.deliveryLeverage({
symbol:'BTCUSD_200925',
leverage:21,
})
)
Output
{
"leverage":21,
"maxQty":"1000",//maximumquantityofbaseasset
"symbol":"BTCUSD_200925"
}
deliveryMarginType
Changemargintype.
Name
Type
Mandatory
Description
symbol
STRING
YES
Thepairname
marginType
ENUM
YES
ISOLATED,CROSSED
recvWindow
LONG
NO
console.log(
awaitclient.futuresMarginType({
symbol:'BTCUSD_200925',
marginType:'ISOLATED',
})
)
Output
{
"code":200,
"msg":"success"
}
deliveryPositionMargin
Modifyisolatedpositionmargin.
Name
Type
Mandatory
Description
symbol
STRING
YES
Thepairname
positionSide
ENUM
NO
DefaultBOTHforOne-wayMode;LONGorSHORTforHedgeMode.ItmustbesentwithHedgeMode.
amount
DECIMAL
YES
type
INT
YES
1:Addpositionmargin,2:Reducepositionmargin
recvWindow
LONG
NO
Onlyforisolatedsymbol.
console.log(
awaitclient.deliveryPositionMargin({
symbol:'BTCUSD_200925',
amount:100,
type:1,
})
)
Output
{
"amount":100.0,
"code":200,
"msg":"Successfullymodifypositionmargin.",
"type":1
}
deliveryMarginHistory
Getpositionmarginchangehistory.
Name
Type
Mandatory
Description
symbol
STRING
YES
Thepairname
type
INT
NO
1:Addpositionmargin,2:Reducepositionmargin
startTime
LONG
NO
endTime
LONG
NO
limit
INT
NO
Default50;
recvWindow
LONG
NO
console.log(
awaitclient.deliveryMarginHistory({
symbol:'BTCUSD_200925',
type:1,
startTime:1578047897180,
limit:10,
})
)
Output
[
{
"amount":"23.36332311",
"asset":"BTC",
"symbol":"BTCUSD_200925",
"time":1578047897183,
"type":1,
"positionSide":"BOTH"
},
{
"amount":"100",
"asset":"BTC",
"symbol":"BTCUSD_200925",
"time":1578047900425,
"type":1,
"positionSide":"LONG"
}
...
]
deliveryIncome
Getincomehistory.
Name
Type
Mandatory
Description
symbol
STRING
NO
Thepairname
incomeType
STRING
NO
"TRANSFER","WELCOME_BONUS","REALIZED_PNL","FUNDING_FEE","COMMISSION",and"INSURANCE_CLEAR"
startTime
LONG
NO
TimestampinmstogetfundingfromINCLUSIVE.
endTime
LONG
NO
TimestampinmstogetfundinguntilINCLUSIVE.
limit
INT
NO
Default100;max1000
recvWindow
LONG
NO
IfincomeTypeisnotsent,allkindsofflowwillbereturned
trandIdisuniqueinthesameincomeTypeforauser
TheintervalbetweenstartTimeandendTimecannotexceed200days:
IfstartTimeandendTimearenotsent,thelast200dayswillbereturned
console.log(
awaitclient.deliveryIncome({
symbol:'BTCUSD_200925',
startTime:1570608000000,
limit:700,
})
)
Output
[
{
"symbol":"",//tradesymbol,ifexisting
"incomeType":"TRANSFER",//incometype
"income":"-0.37500000",//incomeamount
"asset":"BTC",//incomeasset
"info":"WITHDRAW",//extrainformation
"time":1570608000000,
"tranId":"9689322392",//transactionid
"tradeId":""//tradeid,ifexisting
},
{
"symbol":"BTCUSD_200925",
"incomeType":"COMMISSION",
"income":"-0.01000000",
"asset":"BTC",
"info":"",
"time":1570636800000,
"tranId":"9689322392",
"tradeId":"2059192"
}
]
deliveryAccountBalance
Getdeliveryaccountbalance
console.log(awaitclient.deliveryAccountBalance());
Output
[
{
"accountAlias":"SgsR",//uniqueaccountcode
"asset":"BTC",
"balance":"0.00250000",
"withdrawAvailable":"0.00250000",
"crossWalletBalance":"0.00241969",
"crossUnPnl":"0.00000000",
"availableBalance":"0.00241969",
"updateTime":1592468353979
}
...
]
deliveryUserTrades
Gettradesforaspecificaccountandsymbol.
console.log(
awaitclient.deliveryUserTrades({
symbol:'BTCUSD_200626',
}),
)
Param
Type
Mandatory
Description
symbol
STRING
NO
pair
STRING
NO
startTime
LONG
NO
endTime
LONG
NO
limit
INT
NO
Default50;max1000.
fromId
LONG
NO
Tradeidtofetchfrom.Defaultgetsmostrecenttrades.
recvWindow
LONG
NO
Eithersymbolorpairmustbesent
Symbolandpaircannotbesenttogether
PairandfromIdcannotbesenttogether
Ifapairissent,tickersforallsymbolsofthepairwillbereturned
TheparameterfromIdcannotbesentwithstartTimeorendTime
Output
[
{
'symbol':'BTCUSD_200626',
'id':6,
'orderId':28,
'pair':'BTCUSD',
'side':'SELL',
'price':'8800',
'qty':'1',
'realizedPnl':'0',
'marginAsset':'BTC',
'baseQty':'0.01136364',
'commission':'0.00000454',
'commissionAsset':'BTC',
'time':1590743483586,
'positionSide':'BOTH',
'buyer':false,
'maker':false
}
...
]
deliveryLeverageBracket
Getthepair'sdefaultnotionalbracketlist.
console.log(
awaitclient.deliveryLeverageBracket({
pair:'BTCUSD',//Optional
}),
)
Param
Type
Mandatory
Description
symbol
STRING
NO
Useifyouareonlyinterestedinbracketsforonesymbol
recvWindow
LONG
NO
Output
[
{
"pair":"BTCUSD",
"brackets":[
{
"bracket":1,//bracketlevel
"initialLeverage":125,//themaximumleverage
"qtyCap":50,//upperedgeofbaseassetquantity
"qtylFloor":0,//loweredgeofbaseassetquantity
"maintMarginRatio":0.004//maintenancemarginrate
"cum":0.0//Auxiliarynumberforquickcalculation
},
]
}
]
WebSockets
Everywebsocketutilityreturnsafunctionyoucancalltoclosetheopened
connectionandavoidmemoryissues.
constclean=client.ws.depth('ETHBTC',depth=>{
console.log(depth)
})
//Afteryou'redone
clean()
depth
Livedepthmarketdatafeed.Thefirstparametercaneither
beasinglesymbolstringoranarrayofsymbols.Ifyouwish
tospecifytheupdatespeed(caneitherbe1000msor100ms)
ofthestreamthenappendthespeedattheendofthesymbol
stringasfollows:ETHBTC@100ms
client.ws.depth('ETHBTC',depth=>{
console.log(depth)
})
Output
{
eventType:'depthUpdate',
eventTime:1508612956950,
symbol:'ETHBTC',
firstUpdateId:18331140,
finalUpdateId:18331145,
bidDepth:[
{price:'0.04896500',quantity:'0.00000000'},
{price:'0.04891100',quantity:'15.00000000'},
{price:'0.04891000',quantity:'0.00000000'}],
askDepth:[
{price:'0.04910600',quantity:'0.00000000'},
{price:'0.04910700',quantity:'11.24900000'}
]
}
customSubStream
Youcanaddcustomsubstreamsbyviewdocs
client.ws.customSubStream('!markPrice@arr@1s',console.log)
partialDepth
Toplevelsbidsandasks,pushedeverysecond.Validlevelsare5,10,or20.
Acceptsanarrayofobjectsformultipledepths.Ifyouwish
tospecifytheupdatespeed(caneitherbe1000msor100ms)
ofthestreamthenappendthespeedattheendofthesymbol
stringasfollows:ETHBTC@100ms
client.ws.partialDepth({symbol:'ETHBTC',level:10},depth=>{
console.log(depth)
})
Output
{
symbol:'ETHBTC',
level:10,
bids:[
{price:'0.04896500',quantity:'0.00000000'},
{price:'0.04891100',quantity:'15.00000000'},
{price:'0.04891000',quantity:'0.00000000'}
],
asks:[
{price:'0.04910600',quantity:'0.00000000'},
{price:'0.04910700',quantity:'11.24900000'}
]
}
ticker
24hrTickerstatisticsforasymbolpushedeverysecond.Acceptsanarrayofsymbols.
client.ws.ticker('HSRETH',ticker=>{
console.log(ticker)
})
Output
{
eventType:'24hrTicker',
eventTime:1514670820924,
symbol:'HSRETH',
priceChange:'-0.00409700',
priceChangePercent:'-11.307',
weightedAvg:'0.03394946',
prevDayClose:'0.03623500',
curDayClose:'0.03213800',
closeTradeQuantity:'7.02000000',
bestBid:'0.03204200',
bestBidQnt:'78.00000000',
bestAsk:'0.03239800',
bestAskQnt:'7.00000000',
open:'0.03623500',
high:'0.03659900',
low:'0.03126000',
volume:'100605.15000000',
volumeQuote:'3415.49097353',
openTime:1514584420922,
closeTime:1514670820922,
firstTradeId:344803,
lastTradeId:351380,
totalTrades:6578
}
allTickers
Retrievesallthetickers.
client.ws.allTickers(tickers=>{
console.log(tickers)
})
miniTicker
24hrMiniTickerstatisticsforasymbolpushedeverysecond.Acceptsanarrayofsymbols.
client.ws.miniTicker('HSRETH',ticker=>{
console.log(ticker)
})
Output
{
eventType:'24hrMiniTicker',
eventTime:1514670820924,
symbol:'HSRETH',
curDayClose:'0.03213800',
open:'0.03623500',
high:'0.03659900',
low:'0.03126000',
volume:'100605.15000000',
volumeQuote:'3415.49097353'
}
allMiniTickers
Retrievesalltheminitickers.
client.ws.allMiniTickers(tickers=>{
console.log(tickers)
})
bookTicker
Pushesanyupdatetothebestbidorask'spriceorquantityinreal-timeforaspecifiedsymbol.Acceptsasinglesymboloranarrayofsymbols.
client.ws.bookTicker('BTCUSDT',ticker=>{
console.log(ticker)
})
Output
{
updateId:23099391508,
symbol:'BTCUSDT',
bestBid:'21620.03000000',
bestBidQnt:'0.09918000',
bestAsk:'21621.65000000',
bestAskQnt:'0.06919000'
}
candles
Livecandledatafeedforagiveninterval.Youcanpasseitherasymbolstring
orasymbolarray.
client.ws.candles('ETHBTC','1m',candle=>{
console.log(candle)
})
Output
{
eventType:'kline',
eventTime:1508613366276,
symbol:'ETHBTC',
open:'0.04898000',
high:'0.04902700',
low:'0.04898000',
close:'0.04901900',
volume:'37.89600000',
trades:30,
interval:'5m',
isFinal:false,
quoteVolume:'1.85728874',
buyVolume:'21.79900000',
quoteBuyVolume:'1.06838790'
}
trades
Livetradedatafeed.Passeitherasinglesymbolstringoranarrayofsymbols.Thetradestreamspushrawtradeinformation;eachtradehasauniquebuyerandseller.
client.ws.trades(['ETHBTC','BNBBTC'],trade=>{
console.log(trade)
})
Output
{
eventType:'trade',
eventTime:1508614495052,
tradeTime:1508614495050,
symbol:'ETHBTC',
price:'0.04923600',
quantity:'3.43500000',
isBuyerMaker:true,
maker:true,
tradeId:2148226,
buyerOrderId:390876,
sellerOrderId:390752
}
aggTrades
Livetradedatafeed.Passeitherasinglesymbolstringoranarrayofsymbols.Theaggregatetradestreamspushtradeinformationthatisaggregatedforasingletakerorder.
client.ws.aggTrades(['ETHBTC','BNBBTC'],trade=>{
console.log(trade)
})
Output
{
eventType:'aggTrade',
eventTime:1508614495052,
aggId:2148226,
price:'0.04923600',
quantity:'3.43500000',
firstId:37856,
lastId:37904,
timestamp:1508614495050,
symbol:'ETHBTC',
isBuyerMaker:false,
wasBestPrice:true
}
user
Liveusermessagesdatafeed.
Requiresauthentication
constclean=awaitclient.ws.user(msg=>{
console.log(msg)
})
Thereisalsoequivalentfunctiontoquerythemarginwallet:
client.ws.marginUser()
Notethatthismethodreturnapromisewhichwillresolvethecleancallback.
Output
{
eventType:'account',
eventTime:1508614885818,
balances:{
'123':{available:'0.00000000',locked:'0.00000000'},
'456':{available:'0.00000000',locked:'0.00000000'},
BTC:{available:'0.00000000',locked:'0.00000000'},
}
}
FuturesWebSockets
Everywebsocketutilityreturnsafunctionyoucancalltoclosetheopened
connectionandavoidmemoryissues.
constclean=client.ws.futuresDepth('ETHBTC',depth=>{
console.log(depth)
})
//Afteryou'redone
clean()
Eachwebsocketutilitysupportstheabilitytogetacleancallbackwithoutdatatransformation,forthis,passthethirdattributeFALSE.
constclean=client.ws.futuresDepth('ETHBTC',depth=>{
console.log(depth)
},false)
Output
{
"e":"depthUpdate",//Eventtype
"E":123456789,//Eventtime
"T":123456788,//transactiontime
"s":"BTCUSDT",//Symbol
"U":157,//FirstupdateIDinevent
"u":160,//FinalupdateIDinevent
"pu":149,//FinalupdateIdinlaststream(ie`u`inlaststream)
"b":[//Bidstobeupdated
[
"0.0024",//Priceleveltobeupdated
"10"//Quantity
]
],
"a":[//Askstobeupdated
[
"0.0026",//Priceleveltobeupdated
"100"//Quantity
]
]
}
futuresDepth
LivefuturesDepthmarketdatafeed.Thefirstparametercaneither
beasinglesymbolstringoranarrayofsymbols.
client.ws.futuresDepth('ETHBTC',depth=>{
console.log(depth)
})
Output
{
eventType:'depthUpdate',
eventTime:1508612956950,
symbol:'ETHBTC',
firstUpdateId:18331140,
finalUpdateId:18331145,
bidDepth:[
{price:'0.04896500',quantity:'0.00000000'},
{price:'0.04891100',quantity:'15.00000000'},
{price:'0.04891000',quantity:'0.00000000'}],
askDepth:[
{price:'0.04910600',quantity:'0.00000000'},
{price:'0.04910700',quantity:'11.24900000'}
]
}
futuresPartialDepth
Toplevelsbidsandasks,pushedeverysecond.Validlevelsare5,10,or20.
Acceptsanarrayofobjectsformultipledepths.
client.ws.futuresPartialDepth({symbol:'ETHBTC',level:10},depth=>{
console.log(depth)
})
Output
{
eventType:'depthUpdate',
eventTime:1508612956950,
symbol:'ETHBTC',
level:10,
firstUpdateId:18331140,
finalUpdateId:18331145,
bidDepth:[
{price:'0.04896500',quantity:'0.00000000'},
{price:'0.04891100',quantity:'15.00000000'},
{price:'0.04891000',quantity:'0.00000000'}],
askDepth:[
{price:'0.04910600',quantity:'0.00000000'},
{price:'0.04910700',quantity:'11.24900000'}
]
}
futuresTicker
24hrTickerstatisticsforasymbolpushedevery500ms.Acceptsanarrayofsymbols.
client.ws.futuresTicker('HSRETH',ticker=>{
console.log(ticker)
})
Output
{
eventType:'24hrTicker',
eventTime:123456789,
symbol:'BTCUSDT',
priceChange:'0.0015',
priceChangePercent:'250.00',
weightedAvg:'0.0018',
curDayClose:'0.0025',
closeTradeQuantity:'10',
open:'0.0010',
high:'0.0025',
low:'0.0010',
volume:'10000',
volumeQuote:'18',
openTime:0,
closeTime:86400000,
firstTradeId:0,
lastTradeId:18150,
totalTrades:18151,
}
futuresAllTickers
Retrievesallthetickers.
client.ws.futuresAllTickers(tickers=>{
console.log(tickers)
})
futuresCandles
Livecandledatafeedforagiveninterval.Youcanpasseitherasymbolstring
orasymbolarray.
client.ws.futuresCandles('ETHBTC','1m',candle=>{
console.log(candle)
})
Output
{
eventType:'kline',
eventTime:1508613366276,
symbol:'ETHBTC',
open:'0.04898000',
high:'0.04902700',
low:'0.04898000',
close:'0.04901900',
volume:'37.89600000',
trades:30,
interval:'5m',
isFinal:false,
quoteVolume:'1.85728874',
buyVolume:'21.79900000',
quoteBuyVolume:'1.06838790'
}
futuresAggTrades
Livetradedatafeed.Passeitherasinglesymbolstringoranarrayofsymbols.TheAggregateTradeStreamspushtradeinformationthatisaggregatedforasingletakerorderevery100milliseconds.
client.ws.futuresAggTrades(['ETHBTC','BNBBTC'],trade=>{
console.log(trade)
})
Output
{
eventType:'aggTrade',
eventTime:1508614495052,
aggId:2148226,
price:'0.04923600',
quantity:'3.43500000',
firstId:37856,
lastId:37904,
timestamp:1508614495050,
symbol:'ETHBTC',
isBuyerMaker:false,
}
futuresLiquidations
Liveliquidationdatafeed.Passeitherasinglesymbolstringoranarrayofsymbols.TheLiquidationOrderStreamspushforceliquidationorderinformationforspecificsymbol(s).
client.ws.futuresLiquidations(['ETHBTC','BNBBTC'],liquidation=>{
console.log(liquidation)
})
Output
{
symbol:string
price:'0.04923600',
origQty:'3.43500000',
lastFilledQty:'3.43500000',
accumulatedQty:'3.43500000',
averagePrice:'0.04923600',
status:'FILLED',
timeInForce:'IOC',
type:'LIMIT',
side:'SELL',
time:1508614495050
}
futuresAllLiquidations
Liveliquidationdatafeed.Passeitherasinglesymbolstringoranarrayofsymbols.TheAllLiquidationOrderStreamspushforceliquidationorderinformationforallsymbolsinthemarket.
client.ws.futuresAllLiquidations(liquidation=>{
console.log(liquidation)
})
Output
{
symbol:string
price:'0.04923600',
origQty:'3.43500000',
lastFilledQty:'3.43500000',
accumulatedQty:'3.43500000',
averagePrice:'0.04923600',
status:'FILLED',
timeInForce:'IOC',
type:'LIMIT',
side:'SELL',
time:1508614495050
}
futuresCustomSubStream
Youcanaddcustomsubstreamsbyviewdocs
client.ws.futuresCustomSubStream(['!markPrice@arr','ETHBTC@markPrice@1s'],console.log)
futuresUser
Liveusermessagesdatafeed.
Requiresauthentication
constfuturesUser=awaitclient.ws.futuresUser(msg=>{
console.log(msg)
})
Output
{
eventTime:1564745798939,
transactionTime:1564745798938,
eventType:'ACCOUNT_UPDATE',
eventReasonType:'ORDER',
balances:[
{
asset:'USDT',
walletBalance:'122624.12345678',
crossWalletBalance:'100.12345678'
},
{
asset:'BNB',
walletBalance:'1.00000000',
crossWalletBalance:'0.00000000'
}
],
positions:[
{
symbol:'BTCUSDT',
positionAmount:'0',
entryPrice:'0.00000',
accumulatedRealized:'200',
unrealizedPnL:'0',
marginType:'isolated',
isolatedWallet:'0.00000000',
positionSide:'BOTH'
},
{
symbol:'BTCUSDT',
positionAmount:'20',
entryPrice:'6563.66500',
accumulatedRealized:'0',
unrealizedPnL:'2850.21200',
marginType:'isolated',
isolatedWallet:'13200.70726908',
positionSide:'LONG'
}
],
}
DeliveryWebSockets
Everywebsocketutilityreturnsafunctionyoucancalltoclosetheopened
connectionandavoidmemoryissues.
constclean=client.ws.deliveryDepth('BTCUSD_200626',depth=>{
console.log(depth)
})
//Afteryou'redone
clean()
Eachwebsocketutilitysupportstheabilitytogetacleancallbackwithoutdatatransformation,forthis,passthethirdattributeFALSE.
constclean=client.ws.deliveryDepth('BTCUSD_200626',depth=>{
console.log(depth)
},false)
Output
{
"e":"depthUpdate",//Eventtype
"E":1591270260907,//Eventtime
"T":1591270260891,//Transctiontime
"s":"BTCUSD_200626",//Symbol
"ps":"BTCUSD",//Pair
"U":17285681,//FirstupdateIDinevent
"u":17285702,//FinalupdateIDinevent
"pu":17285675,//FinalupdateIdinlaststream(ie`u`inlaststream)
"b":[//Bidstobeupdated
[
"9517.6",//Priceleveltobeupdated
"10"//Quantity
]
],
"a":[//Askstobeupdated
[
"9518.5",//Priceleveltobeupdated
"45"//Quantity
]
]
}
deliveryDepth
LivefuturesDepthmarketdatafeed.Thefirstparametercaneither
beasinglesymbolstringoranarrayofsymbols.
client.ws.deliveryDepth('TRXUSD_PERP',depth=>{
console.log(depth)
})
Output
{
eventType:'depthUpdate',
eventTime:1663111254317,
transactionTime:1663111254138,
symbol:'TRXUSD_PERP',
pair:'TRXUSD',
firstUpdateId:558024151999,
finalUpdateId:558024152633,
prevFinalUpdateId:558024150524,
bidDepth:[
{price:'0.06052',quantity:'1805'},
{price:'0.06061',quantity:'313'}
],
askDepth:[
{price:'0.06062',quantity:'314'},
{price:'0.06063',quantity:'790'},
{price:'0.06065',quantity:'1665'},
{price:'0.06066',quantity:'2420'}
]
}
deliveryPartialDepth
Topbidsandasks.Validlevelsare5,10,or20.
UpdateSpeed:250ms,500msor100ms.
Acceptsanarrayofobjectsformultipledepths.
client.ws.deliveryPartialDepth({symbol:'TRXUSD_PERP',level:10},depth=>{
console.log(depth)
})
Output
{
level:10,
eventType:'depthUpdate',
eventTime:1663111554598,
transactionTime:1663111554498,
symbol:'TRXUSD_PERP',
pair:'TRXUSD',
firstUpdateId:558027933795,
finalUpdateId:558027935097,
prevFinalUpdateId:558027932895,
bidDepth:[
{price:'0.06063',quantity:'604'},
{price:'0.06062',quantity:'227'},
{price:'0.06061',quantity:'327'}
],
askDepth:[
{price:'0.06064',quantity:'468'},
{price:'0.06065',quantity:'131'}
]
}
deliveryTicker
24hrrollwingwindowtickerstatisticsforasinglesymbol.TheseareNOTthestatisticsoftheUTCday,buta24hrrollingwindowfromrequestTimeto24hrsbefore.
Acceptsanarrayofsymbols.
client.ws.deliveryTicker('BNBUSD_PERP',ticker=>{
console.log(ticker)
})
Output
{
eventType:'24hrTicker',
eventTime:1664834148221,
symbol:'BNBUSD_PERP',
pair:'BNBUSD',
priceChange:'0.130',
priceChangePercent:'0.046',
weightedAvg:'286.02648763',
curDayClose:'285.745',
closeTradeQuantity:'1',
open:'285.615',
high:'289.050',
low:'282.910',
volume:'9220364',
volumeBase:'322360.49452795',
openTime:1664747700000,
closeTime:1664834148215,
firstTradeId:179381113,
lastTradeId:179462069,
totalTrades:80957
}
deliveryAllTickers
Retrievesallthetickers.
client.ws.deliveryAllTickers(tickers=>{
console.log(tickers)
})
deliveryCandles
Livecandledatafeedforagiveninterval.Youcanpasseitherasymbolstring
orasymbolarray.
client.ws.deliveryCandles('ETHUSD_PERP','1m',candle=>{
console.log(candle)
})
Output
{
eventType:'kline',
eventTime:1664834318306,
symbol:'ETHUSD_PERP',
startTime:1664834280000,
closeTime:1664834339999,
firstTradeId:545784425,
lastTradeId:545784494,
open:'1317.68',
high:'1317.91',
low:'1317.68',
close:'1317.91',
volume:'6180',
trades:70,
interval:'1m',
isFinal:false,
baseVolume:'46.89730466',
buyVolume:'5822',
baseBuyVolume:'44.18040830'
}
deliveryAggTrades
Livetradedatafeed.Passeitherasinglesymbolstringoranarrayofsymbols.TheAggregateTradeStreamspushtradeinformationthatisaggregatedforasingletakerorderevery100milliseconds.
client.ws.deliveryAggTrades(['ETHUSD_PERP','BNBUSD_PERP'],trade=>{
console.log(trade)
})
Output
{
eventType:'aggTrade',
eventTime:1664834403682,
symbol:'ETHUSD_PERP',
aggId:216344302,
price:'1317.57',
quantity:'1318',
firstId:545784591,
lastId:545784591,
timestamp:1664834403523,
isBuyerMaker:false
}
deliveryCustomSubStream
Youcanaddcustomsubstreamsbyviewdocs
client.ws.deliveryCustomSubStream(['!miniTicker@arr','ETHUSD_PERP@markPrice@1s'],console.log)
deliveryUser
Liveusermessagesdatafeed.
Fordifferenteventtypes,seeofficialdocumentation
Requiresauthentication
constdeliveryUser=awaitclient.ws.deliveryUser(msg=>{
console.log(msg)
})
Output
{
eventTime:1664834883117,
transactionTime:1664834883101,
eventType:'ACCOUNT_UPDATE',
eventReasonType:'ORDER',
balances:[
{
asset:'BUSD',
walletBalance:'123.45678901',
crossWalletBalance:'123.45678901',
balanceChange:'0'
},
{
asset:'BNB',
walletBalance:'0.12345678',
crossWalletBalance:'0.12345678',
balanceChange:'0'
}
],
positions:[
{
symbol:'ETHBUSD',
positionAmount:'420.024',
entryPrice:'1234.56789',
accumulatedRealized:'9000.12345678',
unrealizedPnL:'0.38498800',
marginType:'cross',
isolatedWallet:'0',
positionSide:'BOTH'
}
]
}
Common
getInfo
TogetinformationaboutlimitsfromresponseheaderscallgetInfo()
console.log(client.getInfo())
Output
{
futures:{
futuresLatency:"2ms",
orderCount1m:"10",
usedWeigh1m:"1",
},
spot:{
orderCount1d:"347",
orderCount10s:"1",
usedWeigh1m:"15",
},
delivery:{
usedWeight1m:'13',
responseTime:'4ms',
orderCount1m:'1'
}
}
ErrorCodes
Anutilityerrorcodemapisalsobeingexportedbythepackageinorderforyoutomakereadable
conditionalsuponspecificerrorsthatcouldoccurwhileusingtheAPI.
importBinance,{ErrorCodes}from'binance-api-node'
console.log(ErrorCodes.INVALID_ORDER_TYPE)//-1116
KeywordsnoneInstallnpmibinance-api-nodeRepositoryGitgithub.com/Ashlar/binance-api-nodeHomepagegithub.com/Ashlar/binance-api-nodeDownloadsWeeklyDownloads6,830Version0.12.0LicenseMITUnpackedSize275kBTotalFiles7Lastpublish17daysagoCollaboratorsTryonRunKitReportmalware