Gathering detailed insights and metrics for binance-api-node
Gathering detailed insights and metrics for binance-api-node
Gathering detailed insights and metrics for binance-api-node
Gathering detailed insights and metrics for binance-api-node
binance-api-node-isolated-margin-user-data-stream
This is a fork of binance-api-node package with a single feature added
node-binance-api
Binance API for node https://github.com/jaggedsoft/node-binance-api
node-addon-api
Node.js API (Node-API)
@binance/connector
This is a lightweight library that works as a connector to the Binance public API.
💹 A complete and heavily tested wrapper with typings for the Binance API.
npm install binance-api-node
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
669 Stars
510 Commits
504 Forks
23 Watching
1 Branches
104 Contributors
Updated on 26 Nov 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-0.6%
635
Compared to previous day
Last week
-1.5%
4,119
Compared to previous week
Last month
15.9%
17,143
Compared to previous month
Last year
-30.3%
255,220
Compared to previous year
7
A complete API wrapper for the Binance API.
Note: This wrapper uses Promises, if they are not supported in your environment, you might want to add a polyfill for them.
For PRs or issues, head over to the source repository.
yarn add binance-api-node
Import the module and create a new client. Passing api keys is optional only if you don't plan on doing authenticated calls. You can create an api key here.
1import Binance from 'binance-api-node' 2 3const client = Binance() 4 5// Authenticated client, can make signed calls 6const client2 = Binance({ 7 apiKey: 'xxx', 8 apiSecret: 'xxx', 9 getTime: xxx, 10}) 11 12client.time().then(time => console.log(time))
If you do not have an appropriate babel config, you will need to use the basic commonjs requires.
1const Binance = require('binance-api-node').default
Every REST method returns a Promise, making this library async await ready.
Following examples will use the await
form, which requires some configuration you will have to lookup.
Param | Type | Required | Info |
---|---|---|---|
apiKey | String | false | Required when making private calls |
apiSecret | String | false | Required when making private calls |
getTime | Function | false | Time generator, defaults to () => Date.now() |
httpBase | String | false | Changes the default endpoint |
httpFutures | String | false | Changes the default endpoint |
wsBase | String | false | Changes the default endpoint |
wsFutures | String | false | Changes the default endpoint |
Test connectivity to the API.
1console.log(await client.ping())
Test connectivity to the Rest API and get the current server time.
1console.log(await client.time())
11508478457643
Get the current exchange trading rules and symbol information. You can optionally pass a symbol to only retrieve info of this specific one.
1console.log(await client.exchangeInfo())
Param | Type | Required | Default |
---|---|---|---|
symbol | String | false |
1{ 2 "timezone": "UTC", 3 "serverTime": 1508631584636, 4 "rateLimits": [ 5 { 6 "rateLimitType": "REQUEST_WEIGHT", 7 "interval": "MINUTE", 8 "intervalNum": 1, 9 "limit": 1200 10 }, 11 { 12 "rateLimitType": "ORDERS", 13 "interval": "SECOND", 14 "intervalNum": 1, 15 "limit": 10 16 }, 17 { 18 "rateLimitType": "ORDERS", 19 "interval": "DAY", 20 "intervalNum": 1, 21 "limit": 100000 22 } 23 ], 24 "exchangeFilters": [], 25 "symbols": [{ 26 "symbol": "ETHBTC", 27 "status": "TRADING", 28 "baseAsset": "ETH", 29 "baseAssetPrecision": 8, 30 "quoteAsset": "BTC", 31 "quotePrecision": 8, 32 "orderTypes": ["LIMIT", "MARKET"], 33 "icebergAllowed": false, 34 "filters": [{ 35 "filterType": "PRICE_FILTER", 36 "minPrice": "0.00000100", 37 "maxPrice": "100000.00000000", 38 "tickSize": "0.00000100" 39 }, { 40 "filterType": "LOT_SIZE", 41 "minQty": "0.00100000", 42 "maxQty": "100000.00000000", 43 "stepSize": "0.00100000" 44 }, { 45 "filterType": "MIN_NOTIONAL", 46 "minNotional": "0.00100000" 47 }] 48 }] 49}
Get the order book for a symbol.
1console.log(await client.book({ symbol: 'ETHBTC' }))
Param | Type | Required | Default |
---|---|---|---|
symbol | String | true | |
limit | Number | false | 100 |
1{ 2 lastUpdateId: 17647759, 3 asks: 4 [ 5 { price: '0.05411500', quantity: '5.55000000' }, 6 { price: '0.05416700', quantity: '11.80100000' } 7 ], 8 bids: 9 [ 10 { price: '0.05395500', quantity: '2.70000000' }, 11 { price: '0.05395100', quantity: '11.84100000' } 12 ] 13}
Retrieves Candlestick for a symbol. Candlesticks are uniquely identified by their open time.
1console.log(await client.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 | Max 1000 |
startTime | Number | false | ||
endTime | Number | false |
1;[ 2 { 3 openTime: 1508328900000, 4 open: '0.05655000', 5 high: '0.05656500', 6 low: '0.05613200', 7 close: '0.05632400', 8 volume: '68.88800000', 9 closeTime: 1508329199999, 10 quoteAssetVolume: '2.29500857', 11 trades: 85, 12 baseAssetVolume: '40.61900000', 13 }, 14]
Get compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price will have the quantity aggregated.
1console.log(await client.aggTrades({ symbol: 'ETHBTC' }))
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
fromId | String | false | ID to get aggregate trades from INCLUSIVE. | |
startTime | Number | false | Timestamp in ms to get aggregate trades from INCLUSIVE. | |
endTime | Number | false | Timestamp in ms to get aggregate trades until INCLUSIVE. | |
limit | Number | false | 500 | Max 500 |
Note: If both startTime
and endTime
are sent, limit
should not be sent AND the distance between startTime
and endTime
must be less than 1 hour.
Note: If frondId
, startTime
, and endTime
are not sent, the most recent aggregate trades will be returned.
1;[ 2 { 3 aggId: 2107132, 4 symbol: 'ETHBTC', 5 price: '0.05390400', 6 quantity: '1.31000000', 7 firstId: 2215345, 8 lastId: 2215345, 9 timestamp: 1508478599481, 10 isBuyerMaker: true, 11 wasBestPrice: true, 12 }, 13]
Get recent trades of a symbol.
1console.log(await client.trades({ symbol: 'ETHBTC' }))
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
limit | Number | false | 500 | Max 500 |
1;[ 2 { 3 id: 28457, 4 price: '4.00000100', 5 qty: '12.00000000', 6 time: 1499865549590, 7 isBuyerMaker: true, 8 isBestMatch: true, 9 }, 10]
24 hour price change statistics, not providing a symbol will return all tickers and is resource-expensive.
1console.log(await client.dailyStats({ symbol: 'ETHBTC' }))
Param | Type | Required |
---|---|---|
symbol | String | false |
1{ 2 symbol: 'ETHBTC', 3 priceChange: '-0.00112000', 4 priceChangePercent: '-1.751', 5 weightedAvgPrice: '0.06324784', 6 prevClosePrice: '0.06397400', 7 lastPrice: '0.06285500', 8 lastQty: '0.63500000', 9 bidPrice: '0.06285500', 10 bidQty: '0.81900000', 11 askPrice: '0.06291900', 12 askQty: '2.93800000', 13 openPrice: '0.06397500', 14 highPrice: '0.06419100', 15 lowPrice: '0.06205300', 16 volume: '126240.37200000', 17 quoteVolume: '7984.43091340', 18 openTime: 1521622289427, 19 closeTime: 1521708689427, 20 firstId: 45409308, // First tradeId 21 lastId: 45724293, // Last tradeId 22 count: 314986 // Trade count 23}
Current average price for a symbol.
1console.log(await client.avgPrice({ symbol: 'ETHBTC' }))
Param | Type | Required |
---|---|---|
symbol | String | true |
1{ 2 "mins": 5, 3 "price": "9.35751834" 4}
Latest price for a symbol, not providing the symbol will return prices for all symbols.
1console.log(await client.prices())
Param | Type | Required |
---|---|---|
symbol | String | false |
1{ 2 ETHBTC: '0.05392500', 3 LTCBTC: '0.01041100', 4 ... 5}
Best price/qty on the order book for all symbols.
1console.log(await client.allBookTickers())
1{ 2 DASHBTC: { 3 symbol: 'DASHBTC', 4 bidPrice: '0.04890400', 5 bidQty: '0.74100000', 6 askPrice: '0.05230000', 7 askQty: '0.79900000' 8 }, 9 DASHETH: { 10 symbol: 'DASHETH', 11 bidPrice: '0.89582000', 12 bidQty: '0.63300000', 13 askPrice: '1.02328000', 14 askQty: '0.99900000' 15 } 16 ... 17}
Test connectivity to the API.
1console.log(await client.futuresPing())
Test connectivity to the Rest API and get the current server time.
1console.log(await client.futuresTime())
11508478457643
Get the current exchange trading rules and symbol information.
1console.log(await client.futuresExchangeInfo())
1{ 2 "timezone": "UTC", 3 "serverTime": 1508631584636, 4 "rateLimits": [ 5 { 6 "rateLimitType": "REQUEST_WEIGHT", 7 "interval": "MINUTE", 8 "intervalNum": 1, 9 "limit": 1200 10 }, 11 { 12 "rateLimitType": "ORDERS", 13 "interval": "SECOND", 14 "intervalNum": 1, 15 "limit": 10 16 }, 17 { 18 "rateLimitType": "ORDERS", 19 "interval": "DAY", 20 "intervalNum": 1, 21 "limit": 100000 22 } 23 ], 24 "exchangeFilters": [], 25 "symbols": [...] 26}
Get the order book for a symbol.
1console.log(await client.futuresBook({ symbol: 'BTCUSDT' }))
Param | Type | Required | Default |
---|---|---|---|
symbol | String | true | |
limit | Number | false | 100 |
1{ 2 lastUpdateId: 17647759, 3 asks: 4 [ 5 { price: '8000.05411500', quantity: '54.55000000' }, 6 { price: '8000.05416700', quantity: '1111.80100000' } 7 ], 8 bids: 9 [ 10 { price: '8000.05395500', quantity: '223.70000000' }, 11 { price: '8000.05395100', quantity: '1134.84100000' } 12 ] 13}
Retrieves Candlestick for a symbol. Candlesticks are uniquely identified by their open time.
1console.log(await client.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 | Max 1000 |
startTime | Number | false | ||
endTime | Number | false |
1;[ 2 { 3 openTime: 1508328900000, 4 open: '0.05655000', 5 high: '0.05656500', 6 low: '0.05613200', 7 close: '0.05632400', 8 volume: '68.88800000', 9 closeTime: 1508329199999, 10 quoteAssetVolume: '2.29500857', 11 trades: 85, 12 baseAssetVolume: '40.61900000', 13 }, 14]
Get compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price will have the quantity aggregated.
1console.log(await client.futuresAggTrades({ symbol: 'ETHBTC' }))
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
fromId | String | false | ID to get aggregate trades from INCLUSIVE. | |
startTime | Number | false | Timestamp in ms to get aggregate trades from INCLUSIVE. | |
endTime | Number | false | Timestamp in ms to get aggregate trades until INCLUSIVE. | |
limit | Number | false | 500 | Max 500 |
Note: If both startTime
and endTime
are sent, limit
should not be sent AND the distance between startTime
and endTime
must be less than 24 hours.
Note: If frondId
, startTime
, and endTime
are not sent, the most recent aggregate trades will be returned.
1;[ 2 { 3 aggId: 2107132, 4 price: '0.05390400', 5 quantity: '1.31000000', 6 firstId: 2215345, 7 lastId: 2215345, 8 timestamp: 1508478599481, 9 isBuyerMaker: true, 10 wasBestPrice: true, 11 }, 12]
Get recent trades of a symbol.
1console.log(await client.futuresTrades({ symbol: 'ETHBTC' }))
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
limit | Number | false | 500 | Max 500 |
1;[ 2 { 3 id: 28457, 4 price: '4.00000100', 5 qty: '12.00000000', 6 time: 1499865549590, 7 isBuyerMaker: true, 8 isBestMatch: true, 9 }, 10]
24 hour price change statistics, not providing a symbol will return all tickers and is resource-expensive.
1console.log(await client.futuresDailyStats({ symbol: 'ETHBTC' }))
Param | Type | Required |
---|---|---|
symbol | String | false |
1{ 2 symbol: 'BTCUSDT', 3 priceChange: '-0.00112000', 4 priceChangePercent: '-1.751', 5 weightedAvgPrice: '0.06324784', 6 prevClosePrice: '0.06397400', 7 lastPrice: '0.06285500', 8 lastQty: '0.63500000', 9 bidPrice: '0.06285500', 10 bidQty: '0.81900000', 11 askPrice: '0.06291900', 12 askQty: '2.93800000', 13 openPrice: '0.06397500', 14 highPrice: '0.06419100', 15 lowPrice: '0.06205300', 16 volume: '126240.37200000', 17 quoteVolume: '7984.43091340', 18 openTime: 1521622289427, 19 closeTime: 1521708689427, 20 firstId: 45409308, // First tradeId 21 lastId: 45724293, // Last tradeId 22 count: 314986 // Trade count 23}
Latest price for symbol, not providing a symbol will return latest price for all symbols and is resource-expensive.
1console.log(await client.futuresPrices())
Param | Type | Required |
---|---|---|
symbol | String | false |
1{ 2 BTCUSDT: '8590.05392500', 3 ETHUSDT: '154.1100', 4 ... 5}
Best price/qty on the order book for all symbols.
1console.log(await client.futuresAllBookTickers())
1{ 2 BTCUSDT: { 3 symbol: 'BTCUSDT', 4 bidPrice: '0.04890400', 5 bidQty: '0.74100000', 6 askPrice: '0.05230000', 7 askQty: '0.79900000' 8 }, 9 ETHUSDT: { 10 symbol: 'ETHUSDT', 11 bidPrice: '0.89582000', 12 bidQty: '0.63300000', 13 askPrice: '1.02328000', 14 askQty: '0.99900000' 15 } 16 ... 17}
Mark Price and Funding Rate.
1console.log(await client.futuresMarkPrice())
1{ 2 "symbol": "BTCUSDT", 3 "markPrice": "11012.80409769", 4 "lastFundingRate": "-0.03750000", 5 "nextFundingTime": 1562569200000, 6 "time": 1562566020000 7}
Get all Liquidation Orders.
1console.log(await client.futuresAllForceOrders())
Param | Type | Required |
---|---|---|
symbol | String | false |
startTime | Long | false |
endTime | Long | false |
limit | Long | false |
1;[ 2 { 3 symbol: 'BTCUSDT', // SYMBOL 4 price: '7918.33', // ORDER_PRICE 5 origQty: '0.014', // ORDER_AMOUNT 6 executedQty: '0.014', // FILLED_AMOUNT 7 avragePrice: '7918.33', // AVG_PRICE 8 status: 'FILLED', // STATUS 9 timeInForce: 'IOC', // TIME_IN_FORCE 10 type: 'LIMIT', 11 side: 'SELL', // DIRECTION 12 time: 1568014460893, 13 }, 14]
Test connectivity to the API.
1console.log(await client.deliveryPing())
Test connectivity to the Rest API and get the current server time.
1console.log(await client.deliveryTime())
11508478457643
Get the current exchange trading rules and symbol information.
1console.log(await client.deliveryExchangeInfo())
1{ 2 timezone: 'UTC', 3 serverTime: 1663099219744, 4 rateLimits: [ 5 { 6 rateLimitType: 'REQUEST_WEIGHT', 7 interval: 'MINUTE', 8 intervalNum: 1, 9 limit: 2400 10 }, 11 { 12 rateLimitType: 'ORDERS', 13 interval: 'MINUTE', 14 intervalNum: 1, 15 limit: 1200 16 } 17 ], 18 exchangeFilters: [], 19 symbols: [...] 20}
Get the order book for a symbol.
1console.log(await client.deliveryBook({ symbol: 'TRXUSD_PERP' }))
Param | Type | Required | Default |
---|---|---|---|
symbol | String | true | |
limit | Number | false | 500 |
1{ 2 lastUpdateId: 17647759, 3 asks: 4 [ 5 { price: '8000.05411500', quantity: '54.55000000' }, 6 { price: '8000.05416700', quantity: '1111.80100000' } 7 ], 8 bids: 9 [ 10 { price: '8000.05395500', quantity: '223.70000000' }, 11 { price: '8000.05395100', quantity: '1134.84100000' } 12 ] 13}
Retrieves Candlestick for a symbol. Candlesticks are uniquely identified by their open time.
1console.log(await client.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 | Max 1000 |
startTime | Number | false | ||
endTime | Number | false |
1[ 2 { 3 openTime: 1663104600000, 4 open: '0.06091', 5 high: '0.06091', 6 low: '0.06086', 7 close: '0.06090', 8 volume: '7927', 9 closeTime: 1663104899999, 10 baseVolume: '1302212.12820796', 11 trades: 75, 12 quoteAssetVolume: '386', 13 baseAssetVolume: '63382.78318786' 14 } 15]
Get compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price will have the quantity aggregated.
1console.log(await client.deliveryAggTrades({ symbol: 'TRXUSD_PERP' }))
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
fromId | String | false | ID to get aggregate trades from INCLUSIVE. | |
startTime | Number | false | Timestamp in ms to get aggregate trades from INCLUSIVE. | |
endTime | Number | false | Timestamp in ms to get aggregate trades until INCLUSIVE. | |
limit | Number | false | 500 | Max 1000 |
Note: If both startTime
and endTime
are sent, limit
should not be sent AND the distance between startTime
and endTime
must be less than 24 hours.
Note: If fromId
, startTime
, and endTime
are not sent, the most recent aggregate trades will be returned.
Note : Only market trades will be aggregated and returned, which means the insurance fund trades and ADL trades won't be aggregated.
1[ 2 { 3 aggId: 14642023, 4 symbol: 'TRXUSD_PERP', 5 price: '0.06087', 6 quantity: '50', 7 firstId: 26319898, 8 lastId: 26319898, 9 timestamp: 1663105187120, 10 isBuyerMaker: false, 11 } 12]
Get recent trades of a symbol.
1console.log(await client.deliveryTrades({ symbol: 'TRXUSD_PERP' }))
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
limit | Number | false | 500 | Max 1000 |
1;[ 2 { 3 id: 26319660, 4 price: '0.06097', 5 qty: '28', 6 baseQty: '4592.42250287', 7 time: 1663103746267, 8 isBuyerMaker: true 9 }, 10]
24 hour price change statistics, not providing a symbol will return all tickers and is resource-expensive.
1console.log(await client.deliveryDailyStats({ symbol: 'TRXUSD_PERP' }))
Param | Type | Required |
---|---|---|
symbol | String | false |
pair | String | false |
1{ 2 symbol: 'TRXUSD_PERP', 3 pair: 'TRXUSD', 4 priceChange: '-0.00277', 5 priceChangePercent: '-4.353', 6 weightedAvgPrice: '0.06248010', 7 lastPrice: '0.06087', 8 lastQty: '4', 9 openPrice: '0.06364', 10 highPrice: '0.06395', 11 lowPrice: '0.06069', 12 volume: '545316', 13 baseVolume: '87278342.48218514', 14 openTime: 1663019640000, 15 closeTime: 1663106045576, 16 firstId: 26308774, 17 lastId: 26320065, 18 count: 11292 19}
Latest price for all symbols.
1console.log(await client.futuresPrices())
1{ 2 BTCUSDT: '8590.05392500', 3 ETHUSDT: '154.1100', 4 ... 5}
Best price/qty on the order book for all symbols.
1console.log(await client.deliveryAllBookTickers())
1{ 2 BTCUSD_PERP: { 3 symbol: 'BTCUSD_PERP', 4 pair: 'BTCUSD', 5 bidPrice: '20120.9', 6 bidQty: '13673', 7 askPrice: '20121.0', 8 askQty: '2628', 9 time: 1663106372658 10 }, 11 ETHUSD_PERP: { 12 symbol: 'ETHUSD_PERP', 13 pair: 'ETHUSD', 14 bidPrice: '1593.63', 15 bidQty: '7210', 16 askPrice: '1593.64', 17 askQty: '27547', 18 time: 1663106372667 19 } 20 ... 21}
Mark Price and Funding Rate.
1console.log(await client.deliveryMarkPrice())
1[ 2 { 3 symbol: 'BTCUSD_221230', 4 pair: 'BTCUSD', 5 markPrice: '20158.81560758', 6 indexPrice: '20152.05327273', 7 estimatedSettlePrice: '20147.96717735', 8 lastFundingRate: '', 9 interestRate: '', 10 nextFundingTime: 0, 11 time: 1663106459005 12 }, 13 { 14 symbol: 'FILUSD_PERP', 15 pair: 'FILUSD', 16 markPrice: '5.88720470', 17 indexPrice: '5.89106242', 18 estimatedSettlePrice: '5.89377086', 19 lastFundingRate: '0.00010000', 20 interestRate: '0.00010000', 21 nextFundingTime: 1663113600000, 22 time: 1663106459005 23 } 24 ... 25]
Note that for all authenticated endpoints, you can pass an extra parameter
useServerTime
set to true
in order to fetch the server time before making
the request.
Creates a new order.
1console.log( 2 await client.order({ 3 symbol: 'XLMETH', 4 side: 'BUY', 5 quantity: '100', 6 price: '0.0002', 7 }), 8)
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 | Optional for MARKET orders | |
timeInForce | String | false | GTC | FOK , GTC , IOC |
newClientOrderId | String | false | A unique id for the order. Automatically generated if not sent. | |
stopPrice | Number | false | Used with stop orders | |
activationPrice | Number | false | Used with TRAILING_STOP_MARKET | |
callbackRate | Number | false | Used with TRAILING_STOP_MARKET | |
newOrderRespType | String | false | RESULT | Returns more complete info of the order. ACK , RESULT , or FULL |
icebergQty | Number | false | Used with iceberg orders | |
recvWindow | Number | false |
Additional mandatory parameters based on type
:
Type | Additional mandatory parameters |
---|---|
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_MAKER
are LIMIT
orders that will be rejected if they would immediately match and trade as a taker.STOP
and TAKE_PROFIT
will execute a MARKET
order when the stopPrice
is reached.LIMIT
or LIMIT_MAKER
type order can be made an iceberg order by sending an icebergQty
.icebergQty
MUST have timeInForce
set to GTC
.1{ 2 symbol: 'XLMETH', 3 orderId: 1740797, 4 clientOrderId: '1XZTVBTGS4K1e', 5 transactTime: 1514418413947, 6 price: '0.00020000', 7 origQty: '100.00000000', 8 executedQty: '0.00000000', 9 status: 'NEW', 10 timeInForce: 'GTC', 11 type: 'LIMIT', 12 side: 'BUY' 13}
Test new order creation and signature/recvWindow. Creates and validates a new order but does not send it into the matching engine.
Same API as above, but does not return any output on success.
Creates a new OCO order.
1console.log( 2 await client.orderOco({ 3 symbol: 'XLMETH', 4 side: 'SELL', 5 quantity: 100, 6 price: 0.0002, 7 stopPrice: 0.0001, 8 stopLimitPrice: 0.0001, 9 }), 10)
Param | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
listClientOrderId | String | false | A unique Id for the entire orderList |
side | String | true | BUY ,SELL |
quantity | Number | true | |
limitClientOrderId | String | false | A unique Id for the limit order |
price | Number | true | |
limitIcebergQty | Number | false | Used to make the LIMIT_MAKER leg an iceberg order. |
stopClientOrderId | String | false | A unique Id for the stop loss/stop loss limit leg |
stopPrice | Number | true | |
stopLimitPrice | Number | false | If provided, stopLimitTimeInForce is required. |
stopIcebergQty | Number | false | Used with STOP_LOSS_LIMIT leg to make an iceberg order. |
stopLimitTimeInForce | String | false | FOK , GTC , IOC |
newOrderRespType | String | false | Returns more complete info of the order. ACK , RESULT , or FULL |
recvWindow | Number | false | The value cannot be greater than 60000 |
Additional Info:
SELL
: Limit Price > Last Price > Stop PriceBUY
: Limit Price < Last Price < Stop PriceICEBERG
quantities however do not have to be the same1{ 2 "orderListId": 0, 3 "contingencyType": "OCO", 4 "listStatusType": "EXEC_STARTED", 5 "listOrderStatus": "EXECUTING", 6 "listClientOrderId": "JYVpp3F0f5CAG15DhtrqLp", 7 "transactionTime": 1514418413947, 8 "symbol": "XLMETH", 9 "orders": [ 10 { 11 "symbol": "XLMETH", 12 "orderId": 1740797, 13 "clientOrderId": "1XZTVBTGS4K1e" 14 }, 15 { 16 "symbol": "XLMETH", 17 "orderId": 1740798, 18 "clientOrderId": "1XZTVBTGS4K1f" 19 } 20 ], 21 "orderReports": [ 22 { 23 "symbol": "XLMETH", 24 "orderId": 1740797, 25 "orderListId": 0, 26 "clientOrderId": "1XZTVBTGS4K1e", 27 "transactTime": 1514418413947, 28 "price": "0.000000", 29 "origQty": "100", 30 "executedQty": "0.000000", 31 "cummulativeQuoteQty": "0.000000", 32 "status": "NEW", 33 "timeInForce": "GTC", 34 "type": "STOP_LOSS", 35 "side": "SELL", 36 "stopPrice": "0.0001" 37 }, 38 { 39 "symbol": "XLMETH", 40 "orderId": 1740798, 41 "orderListId": 0, 42 "clientOrderId": "1XZTVBTGS4K1f", 43 "transactTime": 1514418413947, 44 "price": "0.0002", 45 "origQty": "100", 46 "executedQty": "0.000000", 47 "cummulativeQuoteQty": "0.000000", 48 "status": "NEW", 49 "timeInForce": "GTC", 50 "type": "LIMIT_MAKER", 51 "side": "SELL" 52 } 53 ] 54}
Check an order's status.
1console.log( 2 await client.getOrder({ 3 symbol: 'BNBETH', 4 orderId: 50167927, 5 }), 6)
Param | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
orderId | Number | true | Not required if origClientOrderId is used |
origClientOrderId | String | false | |
recvWindow | Number | false |
1{ 2 clientOrderId: 'NkQnNkdBV1RGjUALLhAzNy', 3 cummulativeQuoteQty: '0.16961580', 4 executedQty: '3.91000000', 5 icebergQty: '0.00000000', 6 isWorking: true, 7 orderId: 50167927, 8 origQty: '3.91000000', 9 price: '0.04338000', 10 side: 'SELL', 11 status: 'FILLED', 12 stopPrice: '0.00000000', 13 symbol: 'BNBETH', 14 time: 1547075007821, 15 timeInForce: 'GTC', 16 type: 'LIMIT', 17 updateTime: 1547075016737 18} 19
Retrieves a specific OCO based on provided optional parameters
1console.log( 2 await client.getOrderOco({ 3 orderListId: 27, 4 }), 5)
Param | Type | Required | Description |
---|---|---|---|
orderListId | Number | true | Not required if listClientOrderId is used |
listClientOrderId | String | false | |
recvWindow | Number | false |
1{ 2 orderListId: 27, 3 contingencyType: 'OCO', 4 listStatusType: 'EXEC_STARTED', 5 listOrderStatus: 'EXECUTING', 6 listClientOrderId: 'h2USkA5YQpaXHPIrkd96xE', 7 transactionTime: 1565245656253, 8 symbol: 'LTCBTC', 9 orders: [ 10 { 11 symbol: 'LTCBTC', 12 orderId: 4, 13 clientOrderId: 'qD1gy3kc3Gx0rihm9Y3xwS' 14 }, 15 { 16 symbol: 'LTCBTC', 17 orderId: 5, 18 clientOrderId: 'ARzZ9I00CPM8i3NhmU9Ega' 19 } 20 ] 21}
Cancels an active order.
1console.log( 2 await client.cancelOrder({ 3 symbol: 'ETHBTC', 4 orderId: 1, 5 }), 6)
Param | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
orderId | Number | true | Not required if origClientOrderId is used |
origClientOrderId | String | false | |
newClientOrderId | String | false | Used to uniquely identify this cancel. Automatically generated by default. |
recvWindow | Number | false |
1{ 2 symbol: 'ETHBTC', 3 origClientOrderId: 'bnAoRHgI18gRD80FJmsfNP', 4 orderId: 1, 5 clientOrderId: 'RViSsQPTp1v3WmLYpeKT11' 6}
Cancel an entire Order List.
1console.log( 2 await client.cancelOrderOco({ 3 symbol: 'ETHBTC', 4 orderListId: 0, 5 }), 6)
Param | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
orderListId | Number | true | Not required if listClientOrderId is used |
listClientOrderId | String | false | |
newClientOrderId | String | false | Used to uniquely identify this cancel. Automatically generated by default. |
recvWindow | Number | false |
1{ 2 orderListId: 0, 3 contingencyType: 'OCO', 4 listStatusType: 'ALL_DONE', 5 listOrderStatus: 'ALL_DONE', 6 listClientOrderId: 'C3wyj4WVEktd7u9aVBRXcN', 7 transactionTime: 1574040868128, 8 symbol: 'LTCBTC', 9 orders: [ 10 { 11 symbol: 'LTCBTC', 12 orderId: 2, 13 clientOrderId: 'pO9ufTiFGg3nw2fOdgeOXa' 14 }, 15 { 16 symbol: 'LTCBTC', 17 orderId: 3, 18 clientOrderId: 'TXOvglzXuaubXAaENpaRCB' 19 } 20 ], 21 orderReports: [ 22 { 23 symbol: 'LTCBTC', 24 origClientOrderId: 'pO9ufTiFGg3nw2fOdgeOXa', 25 orderId: 2, 26 orderListId: 0, 27 clientOrderId: 'unfWT8ig8i0uj6lPuYLez6', 28 price: '1.00000000', 29 origQty: '10.00000000', 30 executedQty: '0.00000000', 31 cummulativeQuoteQty: '0.00000000', 32 status: 'CANCELED', 33 timeInForce: 'GTC', 34 type: 'STOP_LOSS_LIMIT', 35 side: 'SELL', 36 stopPrice: '1.00000000' 37 }, 38 { 39 symbol: 'LTCBTC', 40 origClientOrderId: 'TXOvglzXuaubXAaENpaRCB', 41 orderId: 3, 42 orderListId: 0, 43 clientOrderId: 'unfWT8ig8i0uj6lPuYLez6', 44 price: '3.00000000', 45 origQty: '10.00000000', 46 executedQty: '0.00000000', 47 cummulativeQuoteQty: '0.00000000', 48 status: 'CANCELED', 49 timeInForce: 'GTC', 50 type: 'LIMIT_MAKER', 51 side: 'SELL' 52 } 53 ] 54}
Cancels all active orders on a symbol. This includes OCO orders.
1console.log( 2 await client.cancelOpenOrders({ 3 symbol: 'ETHBTC' 4 }), 5)
Param | Type | Required |
---|---|---|
symbol | String | true |
1[ 2 { 3 symbol: 'ETHBTC', 4 origClientOrderId: 'bnAoRHgI18gRD80FJmsfNP', 5 orderId: 1, 6 clientOrderId: 'RViSsQPTp1v3WmLYpeKT11' 7 }, 8 { 9 symbol: 'ETHBTC', 10 origClientOrderId: 'IDbzcGmfwSCKihxILK1snu', 11 orderId: 2, 12 clientOrderId: 'HKFcuWAm9euMgRuwVGR8CL' 13 } 14]
Get all open orders on a symbol.
1console.log( 2 await client.openOrders({ 3 symbol: 'XLMBTC', 4 }), 5)
Param | Type | Required |
---|---|---|
symbol | String | true |
recvWindow | Number | false |
1;[ 2 { 3 symbol: 'XLMBTC', 4 orderId: 11271740, 5 clientOrderId: 'ekHkROfW98gBN80LTfufQZ', 6 price: '0.00001081', 7 origQty: '1331.00000000', 8 executedQty: '0.00000000', 9 status: 'NEW', 10 timeInForce: 'GTC', 11 type: 'LIMIT', 12 side: 'BUY', 13 stopPrice: '0.00000000', 14 icebergQty: '0.00000000', 15 time: 1522682290485, 16 isWorking: true, 17 }, 18]
Get all account orders on a symbol; active, canceled, or filled.
1console.log( 2 await client.allOrders({ 3 symbol: 'ETHBTC', 4 }), 5)
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
orderId | Number | false | If set, it will get orders >= that orderId. Otherwise most recent orders are returned. | |
limit | Number | false | 500 | Max 500 |
recvWindow | Number | false |
1;[ 2 { 3 symbol: 'ENGETH', 4 orderId: 191938, 5 clientOrderId: '1XZTVBTGS4K1e', 6 price: '0.00138000', 7 origQty: '1.00000000', 8 executedQty: '1.00000000', 9 status: 'FILLED', 10 timeInForce: 'GTC', 11 type: 'LIMIT', 12 side: 'SELL', 13 stopPrice: '0.00000000', 14 icebergQty: '0.00000000', 15 time: 1508611114735, 16 isWorking: true, 17 }, 18]
Retrieves all OCO based on provided optional parameters
1console.log( 2 await client.allOrdersOCO({ 3 timestamp: 1565245913483, 4 }), 5)
Param | Type | Required | Default | Description |
---|---|---|---|---|
timestamp | Number | true | ||
startTime | Number | false | ||
endTime | Number | false | ||
limit | Integer | false | 500 | Max 1000 |
recvWindow | Number | false | The value cannot be greater than 60000 | |
formId | Number | false | If supplied, neither startTime or endTime can be provided |
1;[ 2 { 3 "orderListId": 29, 4 "contingencyType": "OCO", 5 "listStatusType": "EXEC_STARTED", 6 "listOrderStatus": "EXECUTING", 7 "listClientOrderId": "amEEAXryFzFwYF1FeRpUoZ", 8 "transactionTime": 1565245913483, 9 "symbol": "LTCBTC", 10 "orders": [ 11 { 12 "symbol": "LTCBTC", 13 "orderId": 4, 14 "clientOrderId": "oD7aesZqjEGlZrbtRpy5zB" 15 }, 16 { 17 "symbol": "LTCBTC", 18 "orderId": 5, 19 "clientOrderId": "Jr1h6xirOxgeJOUuYQS7V3" 20 } 21 ] 22 }, 23 { 24 "orderListId": 28, 25 "contingencyType": "OCO", 26 "listStatusType": "EXEC_STARTED", 27 "listOrderStatus": "EXECUTING", 28 "listClientOrderId": "hG7hFNxJV6cZy3Ze4AUT4d", 29 "transactionTime": 1565245913407, 30 "symbol": "LTCBTC", 31 "orders": [ 32 { 33 "symbol": "LTCBTC", 34 "orderId": 2, 35 "clientOrderId": "j6lFOfbmFMRjTYA7rRJ0LP" 36 }, 37 { 38 "symbol": "LTCBTC", 39 "orderId": 3, 40 "clientOrderId": "z0KCjOdditiLS5ekAFtK81" 41 } 42 ] 43 } 44]
Get current account information.
1console.log(await client.accountInfo())
Param | Type | Required |
---|---|---|
recvWindow | Number | false |
1{ 2 makerCommission: 10, 3 takerCommission: 10, 4 buyerCommission: 0, 5 sellerCommission: 0, 6 canTrade: true, 7 canWithdraw: true, 8 canDeposit: true, 9 balances: [ 10 { asset: 'BTC', free: '0.00000000', locked: '0.00000000' }, 11 { asset: 'LTC', free: '0.00000000', locked: '0.00000000' }, 12 ] 13}
Get trades for the current authenticated account and symbol.
1console.log( 2 await client.myTrades({ 3 symbol: 'ETHBTC', 4 }), 5)
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
limit | Number | false | 500 | Max 1000 |
fromId | Number | false | TradeId to fetch from. Default gets most recent trades. | |
orderId | Number | false | This can only be used in combination with symbol. | |
startTime | Number | false | ||
endTime | Number | false | ||
recvWindow | Number | false | 5000 | The value cannot be greater than 60000 . |
1;[ 2 { 3 id: 9960, 4 orderId: 191939, 5 price: '0.00138000', 6 qty: '10.00000000', 7 commission: '0.00001380', 8 commissionAsset: 'ETH', 9 time: 1508611114735, 10 isBuyer: false, 11 isMaker: false, 12 isBestMatch: true, 13 }, 14]
Get asset snapshot for the current authenticated account.
1console.log( 2 await client.accountSnapshot({ 3 "type": "SPOT" 4 }); 5)
Param | Type | Required | Default | Description |
---|---|---|---|---|
type | String | true | ||
startTime | Number | false | ||
endTime | Number | false | ||
limit | Number | false | 5 | min 5 , max 30 , default 5 |
recvWindow | Number | false |
1{ 2 "code":200, // 200 for success; others are error codes 3 "msg":"", // error message 4 "snapshotVos":[ 5 { 6 "data":{ 7 "balances":[ 8 { 9 "asset":"BTC", 10 "free":"0.09905021", 11 "locked":"0.00000000" 12 }, 13 { 14 "asset":"USDT", 15 "free":"1.89109409", 16 "locked":"0.00000000" 17 } 18 ], 19 "totalAssetOfBtc":"0.09942700" 20 }, 21 "type":"spot", 22 "updateTime":1576281599000 23 } 24 ] 25}
Lookup symbol trades history.
1console.log(await client.tradesHistory({ symbol: 'ETHBTC' }))
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
limit | Number | false | 500 | Max 500 |
fromId | Number | false | null | TradeId to fetch from. Default gets most recent trades. |
1;[ 2 { 3 id: 28457, 4 price: '4.00000100', 5 qty: '12.00000000', 6 time: 1499865549590, 7 isBuyerMaker: true, 8 isBestMatch: true, 9 }, 10]
Get the account withdraw history.
1console.log(await client.withdrawHistory())
Param | Type | Required | Description |
---|---|---|---|
asset | String | false | |
status | Number | false | 0 (0: Email Sent, 1: Cancelled 2: Awaiting Approval, 3: Rejected, 4: Processing, 5: Failure, 6: Completed) |
offset | Number | false | |
limit | Number | false | |
startTime | Number | false | |
endTime | Number | false | |
recvWindow | Number | false |
1[ 2 { 3 "address": "0x94df8b352de7f46f64b01d3666bf6e936e44ce60", 4 "amount": "8.91000000", 5 "applyTime": "2019-10-12 11:12:02", 6 "coin": "USDT", 7 "id": "b6ae22b3aa844210a7041aee7589627c", 8 "withdrawOrderId": "WITHDRAWtest123", // will not be returned if there's no withdrawOrderId for this withdraw. 9 "network": "ETH", 10 "transferType": 0, // 1 for internal transfer, 0 for external transfer 11 "status": 6, 12 "txId": "0xb5ef8c13b968a406cc62a93a8bd80f9e9a906ef1b3fcf20a2e48573c17659268" 13 }, 14 { 15 "address": "1FZdVHtiBqMrWdjPyRPULCUceZPJ2WLCsB", 16 "amount": "0.00150000", 17 "applyTime": "2019-09-24 12:43:45", 18 "coin": "BTC", 19 "id": "156ec387f49b41df8724fa744fa82719", 20 "network": "BTC", 21 "status": 6, 22 "txId": "60fd9007ebfddc753455f95fafa808c4302c836e4d1eebc5a132c36c1d8ac354" 23 } 24]
Triggers the withdraw process (untested for now).
1console.log( 2 await client.withdraw({ 3 asset: 'ETH', 4 address: '0xfa97c22a03d8522988c709c24283c0918a59c795', 5 amount: 100, 6 }), 7)
Param | Type | Required | Description |
---|---|---|---|
asset | String | true | |
address | String | true | |
amount | Number | true | |
name | String | false | Description of the address |
recvWindow | Number | false |
1{ 2 "id":"7213fea8e94b4a5593d507237e5a555b" 3}
Fetch deposit address with network.
1console.log(await client.depositAddress({ coin: 'NEO' }))
Param | Type | Required | Description |
---|---|---|---|
coin | String | true | The coin name |
network | String | false | The network name |
1{ 2 address: 'AM6ytPW78KYxQCmU2pHYGcee7GypZ7Yhhc', 3 coin: 'NEO', 4 tag: '', 5 url: 'https://neoscan.io/address/AM6ytPW78KYxQCmU2pHYGcee7GypZ7Yhhc' 6}
Fetch deposit address with network.
1console.log(await client.depositHistory())
Param | Type | Required | Description |
---|---|---|---|
coin | String | false | The coin name |
status | Number | false | 0 (0:pending, 6: credited but cannot withdraw, 1:success) |
startTime | Number | false | Default: 90 days from current timestamp |
endTime | Number | false | Default: present timestamp |
offset | Number | false | default: 0 |
limit | Number | false | |
recvWindow | Number | false |
1[ 2 { 3 "amount": "0.00999800", 4 "coin": "PAXG", 5 "network": "ETH", 6 "status": 1, 7 "address": "0x788cabe9236ce061e5a892e1a59395a81fc8d62c", 8 "addressTag": "", 9 "txId": "0xaad4654a3234aa6118af9b4b335f5ae81c360b2394721c019b5d1e75328b09f3", 10 "insertTime": 1599621997000, 11 "transferType": 0, 12 "confirmTimes": "12/12" 13 }, 14 { 15 "amount": "0.50000000", 16 "coin": "IOTA", 17 "network": "IOTA", 18 "status": 1, 19 "address": "SIZ9VLMHWATXKV99LH99CIGFJFUMLEHGWVZVNNZXRJJVWBPHYWPPBOSDORZ9EQSHCZAMPVAPGFYQAUUV9DROOXJLNW", 20 "addressTag": "", 21 "txId": "ESBFVQUTPIWQNJSPXFNHNYHSQNTGKRVKPRABQWTAXCDWOAKDKYWPTVG9BGXNVNKTLEJGESAVXIKIZ9999", 22 "insertTime": 1599620082000, 23 "transferType": 0, 24 "confirmTimes": "1/1" 25 } 26]
Retrieve the account trade Fee per asset.
1console.log(await client.tradeFee())
1[ 2 { 3 "symbol": "ADABNB", 4 "makerCommission": 0.9000, 5 "takerCommission": 1.0000 6 }, 7 { 8 "symbol": "BNBBTC", 9 "makerCommission": 0.3000, 10 "takerCommission": 0.3000 11 } 12] 13
Get information of coins (available for deposit and withdraw) for user.
1console.log(await client.capitalConfigs())
1[ 2 { 3 'coin': 'CTR', 4 'depositAllEnable': false, 5 'free': '0.00000000', 6 'freeze': '0.00000000', 7 'ipoable': '0.00000000', 8 'ipoing': '0.00000000', 9 'isLegalMoney': false, 10 'locked': '0.00000000', 11 'name': 'Centra', 12 'networkList': [ 13 { 14 'addressRegex': '^(0x)[0-9A-Fa-f]{40}$', 15 'coin': 'CTR', 16 'depositDesc': 'Delisted, Deposit Suspended', 17 'depositEnable': false, 18 'isDefault': true, 19 'memoRegex': '', 20 'minConfirm': 12, 21 'name': 'ERC20', 22 'network': 'ETH', 23 'resetAddressStatus': false, 24 'specialTips': '', 25 'unLockConfirm': 0, 26 'withdrawDesc': '', 27 'withdrawEnable': true, 28 'withdrawFee': '35.00000000', 29 'withdrawIntegerMultiple': '0.00000001', 30 'withdrawMax': '0.00000000', 31 'withdrawMin': '70.00000000' 32 } 33 ], 34 'storage': '0.00000000', 35 'trading': false, 36 'withdrawAllEnable': true, 37 'withdrawing': '0.00000000' 38 } 39]
You need to enable Permits Universal Transfer option for the api key which requests this endpoint.
1console.log(await client.universalTransfer({ type: 'MAIN_C2C', asset: 'USDT', amount: '1000' }))
Param | Type | Required | Description |
---|---|---|---|
type | String | true | |
asset | String | true | |
amount | String | true | |
recvWindow | Number | false |
1{ 2 tranId:13526853623 3}
1console.log(await client.universalTransferHistory({ type: 'MAIN_C2C' }))
Param | Type | Required | Description |
---|---|---|---|
type | String | true | |
startTime | Number | false | |
endTime | Number | false | |
current | Number | false | Default 1 |
size | Number | false | Default 10, Max 100 |
recvWindow | Number | false |
1{ 2 "total": 2, 3 "rows": [ 4 { 5 "asset":"USDT", 6 "amount":"1", 7 "type":"MAIN_C2C" 8 "status": "CONFIRMED", 9 "tranId": 11415955596, 10 "timestamp":1544433328000 11 }, 12 { 13 "asset":"USDT", 14 "amount":"2", 15 "type":"MAIN_C2C", 16 "status": "CONFIRMED", 17 "tranId": 11366865406, 18 "timestamp":1544433328000 19 } 20 ] 21}
1console.log(await client.assetDetail())
Param | Type | Required | Description |
---|---|---|---|
recvWindow | Number | false |
1{ 2 "CTR": { 3 "minWithdrawAmount": "70.00000000", //min withdraw amount 4 "depositStatus": false,//deposit status (false if ALL of networks' are false) 5 "withdrawFee": 35, // withdraw fee 6 "withdrawStatus": true, //withdraw status (false if ALL of networks' are false) 7 "depositTip": "Delisted, Deposit Suspended" //reason 8 }, 9 "SKY": { 10 "minWithdrawAmount": "0.02000000", 11 "depositStatus": true, 12 "withdrawFee": 0.01, 13 "withdrawStatus": true 14 } 15}
1console.log(await client.getBnbBurn())
Param | Type | Required | Description |
---|---|---|---|
recvWindow | Number | false | No more than 60000 |
1{ 2 "spotBNBBurn":true, 3 "interestBNBBurn": false 4}
1console.log(await client.setBnbBurn({ spotBNBBurn: "true" }))
Param | Type | Required | Description |
---|---|---|---|
spotBNBBurn | String | false | "true" or "false"; Determines whether to use BNB to pay for trading fees on SPOT |
interestBNBBurn | String | false | "true" or "false"; Determines whether to use BNB to pay for margin loan's interest |
recvWindow | Number | false | No more than 60000 |
1{ 2 "spotBNBBurn":true, 3 "interestBNBBurn": false 4}
1console.log(await client.dustLog())
Param | Type | Required | Description |
---|---|---|---|
startTime | Number | false | |
endTime | Number | false | |
recvWindow | Number | false |
1{ 2 "total": 8, //Total counts of exchange 3 "userAssetDribblets": [ 4 { 5 "operateTime": 1615985535000, 6 "totalTransferedAmount": "0.00132256", 7 "totalServiceChargeAmount": "0.00002699", 8 "transId": 45178372831, 9 "userAssetDribbletDetails": [ 10 { 11 "transId": 4359321, 12 "serviceChargeAmount": "0.000009", 13 "amount": "0.0009", 14 "operateTime": 1615985535000, 15 "transferedAmount": "0.000441", 16 "fromAsset": "USDT" 17 }, 18 { 19 "transId": 4359321, 20 "serviceChargeAmount": "0.00001799", 21 "amount": "0.0009", 22 "operateTime": 1615985535000, 23 "transferedAmount": "0.00088156", 24 "fromAsset": "ETH" 25 } 26 ] 27 }, 28 { 29 "operateTime":1616203180000, 30 "totalTransferedAmount": "0.00058795", 31 "totalServiceChargeAmount": "0.000012", 32 "transId": 4357015, 33 "userAssetDribbletDetails": [ 34 { 35 "transId": 4357015, 36 "serviceChargeAmount": "0.00001", 37 "amount": "0.001", 38 "operateTime": 1616203180000, 39 "transferedAmount": "0.00049", 40 "fromAsset": "USDT" 41 }, 42 { 43 "transId": 4357015, 44 "serviceChargeAmount": "0.000002", 45 "amount": "0.0001", 46 "operateTime": 1616203180000, 47 "transferedAmount": "0.00009795", 48 "fromAsset": "ETH" 49 } 50 ] 51 } 52 ] 53 } 54}
1console.log(await client.dustTransfer({ asset: ['ETH', 'LTC', 'TRX'] }))
Param | Type | Required | Description |
---|---|---|---|
asset | [String] | true | |
recvWindow | Number | false |
1{ 2 "totalServiceCharge":"0.02102542", 3 "totalTransfered":"1.05127099", 4 "transferResult":[ 5 { 6 "amount":"0.03000000", 7 "fromAsset":"ETH", 8 "operateTime":1563368549307, 9 "serviceChargeAmount":"0.00500000", 10 "tranId":2970932918, 11 "transferedAmount":"0.25000000" 12 }, 13 { 14 "amount":"0.09000000", 15 "fromAsset":"LTC", 16 "operateTime":1563368549404, 17 "serviceChargeAmount":"0.01548000", 18 "tranId":2970932918, 19 "transferedAmount":"0.77400000" 20 }, 21 { 22 "amount":"248.61878453", 23 "fromAsset":"TRX", 24 "operateTime":1563368549489, 25 "serviceChargeAmount":"0.00054542", 26 "tranId":2970932918, 27 "transferedAmount":"0.02727099" 28 } 29 ] 30}
Retrieve account coins related information. Implemented as getAll
in Binance Docs.
1console.log(await client.accountCoins())
Param | Type | Required | Description |
---|---|---|---|
recvWindow | Number | false |
1[ 2 { 3 "coin": "BTC", 4 "depositAllEnable": true, 5 "free": "0.08074558", 6 "freeze": "0.00000000", 7 "ipoable": "0.00000000", 8 "ipoing": "0.00000000", 9 "isLegalMoney": false, 10 "locked": "0.00000000", 11 "name": "Bitcoin", 12 "networkList": [ 13 { 14 "addressRegex": "^(bnb1)[0-9a-z]{38}$", 15 "coin": "BTC", 16 "depositDesc": "Wallet Maintenance, Deposit Suspended", // shown only when "depositEnable" is false. 17 "depositEnable": false, 18 "isDefault": false, 19 "memoRegex": "^[0-9A-Za-z\\-_]{1,120}$", 20 "minConfirm": 1, // min number for balance confirmation 21 "name": "BEP2", 22 "network": "BNB", 23 "resetAddressStatus": false, 24 "specialTips": "Both a MEMO and an Address are required to successfully deposit your BEP2-BTCB tokens to Binance.", 25 "unLockConfirm": 0, // confirmation number for balance unlock 26 "withdrawDesc": "Wallet Maintenance, Withdrawal Suspended", // shown only when "withdrawEnable" is false. 27 "withdrawEnable": false, 28 "withdrawFee": "0.00000220", 29 "withdrawMin": "0.00000440" 30 }, 31 { 32 "addressRegex": "^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bc1)[0-9A-Za-z]{39,59}$", 33 "coin": "BTC", 34 "depositEnable": true, 35 "insertTime": 1563532929000, 36 "isDefault": true, 37 "memoRegex": "", 38 "minConfirm": 1, 39 "name": "BTC", 40 "network": "BTC", 41 "resetAddressStatus": false, 42 "specialTips": "", 43 "unLockConfirm": 2, 44 "updateTime": 1571014804000, 45 "withdrawEnable": true, 46 "withdrawFee": "0.00050000", 47 "withdrawIntegerMultiple": "0.00000001", 48 "withdrawMin": "0.00100000" 49 } 50 ], 51 "storage": "0.00000000", 52 "trading": true, 53 "withdrawAllEnable": true, 54 "withdrawing": "0.00000000" 55 } 56]
Get information of lending assets for user.
1console.log(await client.lendingAccount())
1{ 2 "positionAmountVos": [ 3 { 4 "amount": "75.46000000", 5 "amountInBTC": "0.01044819", 6 "amountInUSDT": "75.46000000", 7 "asset": "USDT" 8 }, 9 { 10 "amount": "1.67072036", 11 "amountInBTC": "0.00023163", 12 "amountInUSDT": "1.67289230", 13 "asset": "BUSD" 14 } 15 ], 16 "totalAmountInBTC": "0.01067982", 17 "totalAmountInUSDT": "77.13289230", 18 "totalFixedAmountInBTC": "0.00000000", 19 "totalFixedAmountInUSDT": "0.00000000", 20 "totalFlexibleInBTC": "0.01067982", 21 "totalFlexibleInUSDT": "77.13289230" 22 }
Query funding wallet, includes Binance Pay, Binance Card, Binance Gift Card, Stock Token.
1console.log(await client.fundingWallet())
Param | Type | Required | Description |
---|---|---|---|
asset | String | false | |
needBtcValuation | String | false | 'true' or 'false' |
1[ 2 { 3 "asset": "USDT", 4 "free": "1", 5 "locked": "0", 6 "freeze": "0", 7 "withdrawing": "0", 8 "btcValuation": "0.00000091" 9 } 10]
Get API Key Permission.
1console.log(await client.apiPermission())
Param | Type | Required | Description |
---|---|---|---|
recvWindow | Number | false |
1{ 2 "ipRestrict": false, 3 "createTime": 1623840271000, 4 "enableWithdrawals": false, // This option allows you to withdraw via API. You must apply the IP Access Restriction filter in order to withdrawals 5 "enableInternalTransfer": true, // This option authorizes this key to transfer funds between your master account and your sub account instantly 6 "permitsUniversalTransfer": true, // Authorizes this key to be used for a dedicated universal transfer API to transfer multiple supported currencies. Each business's own transfer API rights are not affected by this authorization 7 "enableVanillaOptions": false, // Authorizes this key to Vanilla options trading 8 "enableReading": true, 9 "enableFutures": false, // API Key created before your futures account opened does not support futures API service 10 "enableMargin": false, // This option can be adjusted after the Cross Margin account transfer is completed 11 "enableSpotAndMarginTrading": false, // Spot and margin trading 12 "tradingAuthorityExpirationTime": 1628985600000 // Expiration time for spot and margin trading permission 13}
Query cross margin account details (USER_DATA)
1console.log(await client.marginAccountInfo());
Param | Type | Required | Description |
---|---|---|---|
recvWindow | Number | false | No more than 60000 |
1{ 2 "borrowEnabled": true, 3 "marginLevel": "11.64405625", 4 "totalAssetOfBtc": "6.82728457", 5 "totalLiabilityOfBtc": "0.58633215", 6 "totalNetAssetOfBtc": "6.24095242", 7 "tradeEnabled": true, 8 "transferEnabled": true, 9 "userAssets": [ 10 { 11 "asset": "BTC", 12 "borrowed": "0.00000000", 13 "free": "0.00499500", 14 "interest": "0.00000000", 15 "locked": "0.00000000", 16 "netAsset": "0.00499500" 17 }, 18 { 19 "asset": "BNB", 20 "borrowed": "201.66666672", 21 "free": "2346.50000000", 22 "interest": "0.00000000", 23 "locked": "0.00000000", 24 "netAsset": "2144.83333328" 25 }, 26 { 27 "asset": "ETH", 28 "borrowed": "0.00000000", 29 "free": "0.00000000", 30 "interest": "0.00000000", 31 "locked": "0.00000000", 32 "netAsset": "0.00000000" 33 }, 34 { 35 "asset": "USDT", 36 "borrowed": "0.00000000", 37 "free": "0.00000000", 38 "interest": "0.00000000", 39 "locked": "0.00000000", 40 "netAsset": "0.00000000" 41 } 42 ] 43}
Create a loan for margin account.
1console.log(await client.marginLoan({ asset: 'BTC', amount:'0.0001' }));
Param | Type | Required | Description |
---|---|---|---|
asset | String | true | The asset name |
amount | Number | true |
1{ 2 "tranId": 100000001 //transaction id 3}
Repay loan for margin account.
1console.log(await client.marginRepay({ asset: 'BTC', amount:'0.0001' }));
Param | Type | Required | Description |
---|---|---|---|
asset | String | true | The asset name |
amount | Number | true |
1{ 2 "tranId": 100000001 //transaction id 3}
Query Isolated Margin Account Info
1console.log(await client.marginIsolatedAccount({ symbols: 'BTCUSDT'}));
Param | Type | Required | Description |
---|---|---|---|
symbols | String | false | Max 5 symbols can be sent; separated by "," |
recvWindow | Number | false | No more than 60000 |
1{ 2 "assets":[ 3 { 4 "baseAsset": 5 { 6 "asset": "BTC", 7 "borrowEnabled": true, 8 "borrowed": "0.00000000", 9 "free": "0.00000000", 10 "interest": "0.00000000", 11 "locked": "0.00000000", 12 "netAsset": "0.00000000", 13 "netAssetOfBtc": "0.00000000", 14 "repayEnabled": true, 15 "totalAsset": "0.00000000" 16 }, 17 "quoteAsset": 18 { 19 "asset": "USDT", 20 "borrowEnabled": true, 21 "borrowed": "0.00000000", 22 "free": "0.00000000", 23 "interest": "0.00000000", 24 "locked": "0.00000000", 25 "netAsset": "0.00000000", 26 "netAssetOfBtc": "0.00000000", 27 "repayEnabled": true, 28 "totalAsset": "0.00000000" 29 }, 30 "symbol": "BTCUSDT" 31 "isolatedCreated": true, 32 "marginLevel": "0.00000000", 33 "marginLevelStatus": "EXCESSIVE", // "EXCESSIVE", "NORMAL", "MARGIN_CALL", "PRE_LIQUIDATION", "FORCE_LIQUIDATION" 34 "marginRatio": "0.00000000", 35 "indexPrice": "10000.00000000" 36 "liquidatePrice": "1000.00000000", 37 "liquidateRate": "1.00000000" 38 "tradeEnabled": true 39 } 40 ], 41 "totalAssetOfBtc": "0.00000000", 42 "totalLiabilityOfBtc": "0.00000000", 43 "totalNetAssetOfBtc": "0.00000000" 44}
Inactive Isolated Margin trading pair for symbol
1console.log(await client.disableMarginAccount({ symbol: 'BTCUSDT' }));
Param | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
recvWindow | Number | false | No more than 60000 |
1{ 2 "success": true, 3 "symbol": "BTCUSDT" 4}
Active Isolated Margin trading pair for symbol
1console.log(await client.enableMarginAccount({ symbol: 'BTCUSDT' }));
Param | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
recvWindow | Number | false | No more than 60000 |
1{ 2 "success": true, 3 "symbol": "BTCUSDT" 4}
If isolatedSymbol is not sent, crossed margin data will be sent.
1console.log(await client.marginMaxBorrow({ asset: 'BTC', isolatedSymbol: 'BTCUSDT'}));
Param | Type | Required | Description |
---|---|---|---|
asset | String | true | |
isolatedSymbol | String | false | |
recvWindow | Number | false | No more than 60000 |
1{ 2 "amount": "1.69248805", // account's currently max borrowable amount with sufficient system availability 3 "borrowLimit": "60" // max borrowable amount limited by the account level 4}
1console.log(await client.marginCreateIsolated({ base: 'BTC', quote: 'USDT'}));
Param | Type | Required | Description |
---|---|---|---|
base | String | true | Base asset of symbol |
quote | String | true | Quote asset of symbol |
recvWindow | Number | false | No more than 60000 |
1{ 2 "success": true, 3 "symbol": "BTCUSDT" 4}
1console.log(await client.marginIsolatedTransfer({ asset: 'USDT', symbol: 'BNBUSDT', transFrom: 'ISOLATED_MARGIN', transTo: 'SPOT', amount: 1}));
Param | Type | Required | Description |
---|---|---|---|
asset | String | true | asset,such as BTC |
symbol | String | true | |
transFrom | String | true | "SPOT", "ISOLATED_MARGIN" |
transTo | String | true | "SPOT", "ISOLATED_MARGIN" |
amount | Number | true | |
recvWindow | Number | false | No more than 60000 |
1{ 2 //transaction id 3 "tranId": 100000001 4}
1console.log(await client.marginIsolatedTransferHistory({ symbol: 'BNBUSDT'}));
Param | Type | Required | Description |
---|---|---|---|
asset | String | false | asset,such as BTC |
symbol | String | true | |
transFrom | String | false | "SPOT", "ISOLATED_MARGIN" |
transTo | String | false | "SPOT", "ISOLATED_MARGIN" |
startTime | Number | false | |
endTime | Number | false | |
current | Number | false | Current page, default 1 |
size | Number | false | Default 10, max 100 |
recvWindow | Number | false | No more than 60000 |
1{ 2 "rows": [ 3 { 4 "amount": "0.10000000", 5 "asset": "BNB", 6 "status": "CONFIRMED", 7 "timestamp": 1566898617000, 8 "txId": 5240372201, 9 "transFrom": "SPOT", 10 "transTo": "ISOLATED_MARGIN" 11 }, 12 { 13 "amount": "5.00000000", 14 "asset": "USDT", 15 "status": "CONFIRMED", 16 "timestamp": 1566888436123, 17 "txId": 5239810406, 18 "transFrom": "ISOLATED_MARGIN", 19 "transTo": "SPOT" 20 } 21 ], 22 "total": 2 23}
1console.log(await client.marginOrder({ 2 symbol: 'BTCUSDT', 3 type: 'MARKET', 4 side: 'SELL', 5 quantity: '10', 6 }));
Param | Type | Required | Description |
---|---|---|---|
symbol | String | true | asset, such as BTC |
isIsolated | String | false | for isolated margin or not, TRUE , FALSE , default FALSE |
side | String | true | BUY SELL |
type | String | true | |
quantity | String | false | |
quoteOrderQty | String | false | |
price | String | false | |
stopPrice | String | false | Used with STOP_LOSS , STOP_LOSS_LIMIT , TAKE_PROFIT , and TAKE_PROFIT_LIMIT orders. |
newClientOrderId | String | false | A unique id among open orders. Automatically generated if not sent. |
icebergQty | Boolean | false | Used with LIMIT , STOP_LOSS_LIMIT , and TAKE_PROFIT_LIMIT to create an iceberg order. |
newOrderRespType | String | false | Set the response JSON. ACK , RESULT , or FULL ; MARKET and LIMIT order types default to FULL , all other orders default to ACK . |
sideEffectType | String | false | NO_SIDE_EFFECT , MARGIN_BUY , AUTO_REPAY ; default NO_SIDE_EFFECT . |
timeInForce | String | false | GTC ,IOC ,FOK |
recvWindow | Number | false | No more than 60000 |
1{ 2 "symbol": "BTCUSDT", 3 "orderId": 28, 4 "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP", 5 "transactTime": 1507725176595, 6 "price": "1.00000000", 7 "origQty": "10.00000000", 8 "executedQty": "10.00000000", 9 "cummulativeQuoteQty": "10.00000000", 10 "status": "FILLED", 11 "timeInForce": "GTC", 12 "type": "MARKET", 13 "side": "SELL", 14 "marginBuyBorrowAmount": 5, // will not return if no margin trade happens 15 "marginBuyBorrowAsset": "BTC", // will not return if no margin trade happens 16 "isIsolated": true, // if isolated margin 17 "fills": [ 18 { 19 "price": "4000.00000000", 20 "qty": "1.00000000", 21 "commission": "4.00000000", 22 "commissionAsset": "USDT" 23 }, 24 { 25 "price": "3999.00000000", 26 "qty": "5.00000000", 27 "commission": "19.99500000", 28 "commissionAsset": "USDT" 29 }, 30 { 31 "price": "3998.00000000", 32 "qty": "2.00000000", 33 "commission": "7.99600000", 34 "commissionAsset": "USDT" 35 }, 36 { 37 "price": "3997.00000000", 38 "qty": "1.00000000", 39 "commission": "3.99700000", 40 "commissionAsset": "USDT" 41 }, 42 { 43 "price": "3995.00000000", 44 "qty": "1.00000000", 45 "commission": "3.99500000", 46 "commissionAsset": "USDT" 47 } 48 ] 49}
Cancels an active margin order.
1console.log( 2 await client.marginCancelOrder({ 3 symbol: 'ETHBTC', 4 orderId: 1, 5 }), 6)
Param | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
orderId | Number | true | Not required if origClientOrderId is used |
origClientOrderId | String | false | |
newClientOrderId | String | false | Used to uniquely identify this cancel. Automatically generated by default. |
recvWindow | Number | false |
1{ 2 symbol: "LTCBTC", 3 orderId: 28, 4 origClientOrderId: "myOrder1", 5 clientOrderId: "cancelMyOrder1", 6 price: "1.00000000", 7 origQty: "10.00000000", 8 executedQty: "8.00000000", 9 cummulativeQuoteQty: "8.00000000", 10 status: "CANCELED", 11 timeInForce: "GTC", 12 type: "LIMIT", 13 side: "SELL" 14}
1console.log(await client.marginOrderOco({ 2 symbol: 'AUDIOUSDT', 3 type: 'MARKET', 4 side: 'SELL', 5 quantity: '10', 6 }));
Param | Type | Required | Description |
---|---|---|---|
symbol | String | true | asset, such as BTC |
isIsolated | String | false | for isolated margin or not, TRUE , FALSE , default FALSE |
side | String | true | BUY SELL |
type | String | true | |
quantity | String | false | |
quoteOrderQty | String | false | |
price | String | false | |
stopPrice | String | false | Used with STOP_LOSS , STOP_LOSS_LIMIT , TAKE_PROFIT , and TAKE_PROFIT_LIMIT orders. |
stopLimitPrice | String | false | Used with STOP_LOSS_LIMIT orders. |
newClientOrderId | String | false | A unique id among open orders. Automatically generated if not sent. |
icebergQty | Boolean | false | Used with LIMIT , STOP_LOSS_LIMIT , and TAKE_PROFIT_LIMIT to create an iceberg order. |
newOrderRespType | String | false | Set the response JSON. ACK , RESULT , or FULL ; MARKET and LIMIT order types default to FULL , all other orders default to ACK . |
sideEffectType | String | false | NO_SIDE_EFFECT , MARGIN_BUY , AUTO_REPAY ; default NO_SIDE_EFFECT . |
timeInForce | String | false | GTC ,IOC ,FOK |
recvWindow | Number | false | No more than 60000 |
1{ 2 "orderListId": 45514668, 3 "contingencyType": 'OCO', 4 "listStatusType": 'EXEC_STARTED', 5 "listOrderStatus": 'EXECUTING', 6 "listClientOrderId": 'CD9UzEJfmcGZ4kLfZT2ga2', 7 "transactionTime": 1632192162785, 8 "symbol": 'AUDIOUSDT', 9 "isIsolated": true, 10 "orders": [ 11 { 12 "symbol": 'AUDIOUSDT', 13 "orderId": 239313661, 14 "clientOrderId": 'ZbUwgKv6UB8eMzf2yfXENl' 15 }, 16 { 17 "symbol": 'AUDIOUSDT', 18 "orderId": 239313662, 19 "clientOrderId": 'f5u1RIHAPRd4W3fFhFykBo' 20 } 21 ], 22 "orderReports": [ 23 { 24 "symbol": 'AUDIOUSDT', 25 "orderId": 239313661, 26 "orderListId": 45514668, 27 "clientOrderId": 'ZbUwgKv6UB8eMzf2yfXENl', 28 "transactTime": 1632192162785, 29 "price": '2.20000000', 30 "origQty": '12.80000000', 31 "executedQty": '0', 32 "cummulativeQuoteQty": '0', 33 "status": 'NEW', 34 "timeInForce": 'GTC', 35 "type": 'STOP_LOSS_LIMIT', 36 "side": 'SELL', 37 "stopPrice": '2.20000000' 38 }, 39 { 40 "symbol": 'AUDIOUSDT', 41 "orderId": 239313662, 42 "orderListId": 45514668, 43 "clientOrderId": 'f5u1RIHAPRd4W3fFhFykBo', 44 "transactTime": 1632192162785, 45 "price": '2.50000000', 46 "origQty": '12.80000000', 47 "executedQty": '0', 48 "cummulativeQuoteQty": '0', 49 "status": 'NEW', 50 "timeInForce": 'GTC', 51 "type": 'LIMIT_MAKER', 52 "side": 'SELL' 53 } 54 ] 55}
Query Margin Account's Open Orders
1console.log( 2 await client.marginOpenOrders({ 3 symbol: 'XLMBTC', 4 }), 5)
Param | Type | Required |
---|---|---|
symbol | String | false |
isIsolated | String | false |
recvWindow | Number | false |
1;[ 2 { 3 clientOrderId: "qhcZw71gAkCCTv0t0k8LUK", 4 cummulativeQuoteQty: "0.00000000", 5 executedQty: "0.00000000", 6 icebergQty: "0.00000000", 7 isWorking: true, 8 orderId: 211842552, 9 origQty: "0.30000000", 10 price: "0.00475010", 11 side: "SELL", 12 status: "NEW", 13 stopPrice: "0.00000000", 14 symbol: "BNBBTC", 15 isIsolated: true, 16 time: 1562040170089, 17 timeInForce: "GTC", 18 type: "LIMIT", 19 selfTradePreventionMode: "NONE", 20 updateTime: 1562040170089 21 } 22]
Cancels all active orders on a symbol for margin account. This includes OCO orders.
1console.log( 2 await client.marginCancelOpenOrders({ 3 symbol: 'ETHBTC' 4 }), 5)
Param | Type | Required |
---|---|---|
symbol | String | true |
isIsolated | String | false |
1[ 2 { 3 symbol: 'ETHBTC', 4 isIsolated: false, 5 origClientOrderId: 'bnAoRHgI18gRD80FJmsfNP', 6 orderId: 1, 7 clientOrderId: 'RViSsQPTp1v3WmLYpeKT11' 8 }, 9 { 10 symbol: 'ETHBTC', 11 isIsolated: false, 12 origClientOrderId: 'IDbzcGmfwSCKihxILK1snu', 13 orderId: 2, 14 clientOrderId: 'HKFcuWAm9euMgRuwVGR8CL' 15 } 16]
Query Margin Account's Order
1console.log(await client.marginGetOrder({ 2 symbol: 'BNBBTC', 3 orderId: '213205622', 4 }));
Param | Type | Required | Description |
---|---|---|---|
symbol | String | true | asset,such as BTC |
isIsolated | String | false | for isolated margin or not, TRUE , FALSE , default FALSE |
orderId | String | false | |
origClientOrderId | String | false | |
recvWindow | Number | false | The value cannot be greater than 60000 |
1{ 2 "clientOrderId": "ZwfQzuDIGpceVhKW5DvCmO", 3 "cummulativeQuoteQty": "0.00000000", 4 "executedQty": "0.00000000", 5 "icebergQty": "0.00000000", 6 "isWorking": true, 7 "orderId": 213205622, 8 "origQty": "0.30000000", 9 "price": "0.00493630", 10 "side": "SELL", 11 "status": "NEW", 12 "stopPrice": "0.00000000", 13 "symbol": "BNBBTC", 14 "isIsolated": true, 15 "time": 1562133008725, 16 "timeInForce": "GTC", 17 "type": "LIMIT", 18 "updateTime": 1562133008725 19}
Retrieves a specific Margin OCO based on provided optional parameters
1console.log( 2 await client.getMarginOrderOco({ 3 orderListId: 27, 4 }), 5)
Param | Type | Required | Description |
---|---|---|---|
orderListId | Number | true | Not required if listClientOrderId is used |
symbol | Boolean | false | mandatory for isolated margin, not supported for cross margin |
isIsolated | Boolean | false | |
listClientOrderId | String | false | |
recvWindow | Number | false |
1{ 2 orderListId: 27, 3 contingencyType: 'OCO', 4 listStatusType: 'EXEC_STARTED', 5 listOrderStatus: 'EXECUTING', 6 listClientOrderId: 'h2USkA5YQpaXHPIrkd96xE', 7 transactionTime: 1565245656253, 8 symbol: 'LTCBTC', 9 isIsolated: false, 10 orders: [ 11 { 12 symbol: 'LTCBTC', 13 orderId: 4, 14 clientOrderId: 'qD1gy3kc3Gx0rihm9Y3xwS' 15 }, 16 { 17 symbol: 'LTCBTC', 18 orderId: 5, 19 clientOrderId: 'ARzZ9I00CPM8i3NhmU9Ega' 20 } 21 ] 22}
Only Portfolio Margin Account is accessible to these endpoints.
Get a Portfolio Margin Account Info.
1console.log(await client.getPortfolioMarginAccountInfo())
1{ 2 "uniMMR": "1.87987800", // Portfolio margin account maintenance margin rate 3 "accountEquity": "122607.35137903", // Account equity, unit:USD 4 "accountMaintMargin": "23.72469206", // Portfolio margin account maintenance margin, unit:USD 5 "accountStatus": "NORMAL" // Portfolio margin account status:"NORMAL", "MARGIN_CALL", "SUPPLY_MARGIN", "REDUCE_ONLY", "ACTIVE_LIQUIDATION", "FORCE_LIQUIDATION", "BANKRUPTED" 6}
Check an order's status.
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | The pair name |
orderId | LONG | NO | |
origClientOrderId | STRING | NO | |
recvWindow | LONG | NO |
Either orderId or origClientOrderId must be sent.
1console.log( 2 await client.futuresGetOrder({ 3 symbol: 'BNBETH', 4 orderId: 50167927, 5 }) 6)
1{ 2 "avgPrice": "0.00000", 3 "clientOrderId": "abc", 4 "cumQuote": "0", 5 "executedQty": "0", 6 "orderId": 1917641, 7 "origQty": "0.40", 8 "origType": "TRAILING_STOP_MARKET", 9 "price": "0", 10 "reduceOnly": false, 11 "side": "BUY", 12 "positionSide": "SHORT", 13 "status": "NEW", 14 "stopPrice": "9300", // please ignore when order type is TRAILING_STOP_MARKET 15 "closePosition": false, // if Close-All 16 "symbol": "BTCUSDT", 17 "time": 1579276756075, // order time 18 "timeInForce": "GTC", 19 "type": "TRAILING_STOP_MARKET", 20 "activatePrice": "9020", // activation price, only return with TRAILING_STOP_MARKET order 21 "priceRate": "0.3", // callback rate, only return with TRAILING_STOP_MARKET order 22 "updateTime": 1579276756075, // update time 23 "workingType": "CONTRACT_PRICE", 24 "priceProtect": false // if conditional order trigger is protected 25}
Get all account orders; active, canceled, or filled.
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | The pair name |
orderId | LONG | NO | |
startTime | LONG | NO | |
endTime | LONG | NO | |
limit | INT | NO | Default 500; max 1000. |
recvWindow | LONG | NO |
If orderId is set, it will get orders >= that orderId. Otherwise most recent orders are returned.
1console.log( 2 await client.futuresAllOrders({ 3 symbol: 'BNBETH', 4 orderId: 50167927, 5 startTime: 1579276756075, 6 limit: 700, 7 }) 8)
1[ 2 { 3 "avgPrice": "0.00000", 4 "clientOrderId": "abc", 5 "cumQuote": "0", 6 "executedQty": "0", 7 "orderId": 1917641, 8 "origQty": "0.40", 9 "origType": "TRAILING_STOP_MARKET", 10 "price": "0", 11 "reduceOnly": false, 12 "side": "BUY", 13 "positionSide": "SHORT", 14 "status": "NEW", 15 "stopPrice": "9300", // please ignore when order type is TRAILING_STOP_MARKET 16 "closePosition": false, // if Close-All 17 "symbol": "BTCUSDT", 18 "time": 1579276756075, // order time 19 "timeInForce": "GTC", 20 "type": "TRAILING_STOP_MARKET", 21 "activatePrice": "9020", // activation price, only return with TRAILING_STOP_MARKET order 22 "priceRate": "0.3", // callback rate, only return with TRAILING_STOP_MARKET order 23 "updateTime": 1579276756075, // update time 24 "workingType": "CONTRACT_PRICE", 25 "priceProtect": false // if conditional order trigger is protected 26 } 27]
Place multiple orders
Name | Type | Mandatory | Description |
---|---|---|---|
batchOrders | LIST | YES | order list. Max 5 orders |
Cancel multiple orders
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | The pair name |
orderIdList | STRING | NO | max length 10 e.g. '[1234567,2345678]' |
origClientOrderIdList | STRING | NO | max length 10 e.g. '["my_id_1","my_id_2"]' , encode the double quotes. No space after comma. |
Change user's initial leverage of specific symbol market.
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | The pair name |
leverage | INT | YES | target initial leverage: int from 1 to 125 |
recvWindow | LONG | NO |
1console.log( 2 await client.futuresLeverage({ 3 symbol: 'BTCUSDT', 4 leverage: 21, 5 }) 6)
1{ 2 "leverage": 21, 3 "maxNotionalValue": "1000000", 4 "symbol": "BTCUSDT" 5}
Change margin type.
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | The pair name |
marginType | ENUM | YES | ISOLATED, CROSSED |
recvWindow | LONG | NO |
1console.log( 2 await client.futuresMarginType({ 3 symbol: 'BTCUSDT', 4 marginType: 'ISOLATED', 5 }) 6)
1{ 2 "code": 200, 3 "msg": "success" 4}
Modify isolated position margin.
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | The pair name |
positionSide | ENUM | NO | Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. It must be sent with Hedge Mode. |
amount | DECIMAL | YES | |
type | INT | YES | 1: Add position margin,2: Reduce position margin |
recvWindow | LONG | NO |
Only for isolated symbol.
1console.log( 2 await client.futuresPositionMargin({ 3 symbol: 'BTCUSDT', 4 amount: 100, 5 type: 1, 6 }) 7)
1{ 2 "amount": 100.0, 3 "code": 200, 4 "msg": "Successfully modify position margin.", 5 "type": 1 6}
Get position margin change history.
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | The pair name |
type | INT | NO | 1: Add position margin,2: Reduce position margin |
startTime | LONG | NO | |
endTime | LONG | NO | |
limit | INT | NO | Default 500; |
recvWindow | LONG | NO |
1console.log( 2 await client.futuresMarginHistory({ 3 symbol: 'BTCUSDT', 4 type: 1, 5 startTime: 1579276756075, 6 limit: 700, 7 }) 8)
1[ 2 { 3 "amount": "23.36332311", 4 "asset": "USDT", 5 "symbol": "BTCUSDT", 6 "time": 1578047897183, 7 "type": 1, 8 "positionSide": "BOTH" 9 }, 10 { 11 "amount": "100", 12 "asset": "USDT", 13 "symbol": "BTCUSDT", 14 "time": 1578047900425, 15 "type": 1, 16 "positionSide": "LONG" 17 } 18]
Get income history.
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | The pair name |
incomeType | STRING | NO | "TRANSFER","WELCOME_BONUS", "REALIZED_PNL", "FUNDING_FEE", "COMMISSION", and "INSURANCE_CLEAR" |
startTime | LONG | NO | Timestamp in ms to get funding from INCLUSIVE. |
endTime | LONG | NO | Timestamp in ms to get funding until INCLUSIVE. |
limit | INT | NO | Default 100; max 1000 |
recvWindow | LONG | NO |
1console.log( 2 await client.futuresIncome({ 3 symbol: 'BTCUSDT', 4 startTime: 1579276756075, 5 limit: 700, 6 }) 7)
1[ 2 { 3 "symbol": "", // trade symbol, if existing 4 "incomeType": "TRANSFER", // income type 5 "income": "-0.37500000", // income amount 6 "asset": "USDT", // income asset 7 "info":"TRANSFER", // extra information 8 "time": 1570608000000, 9 "tranId":"9689322392", // transaction id 10 "tradeId":"" // trade id, if existing 11 }, 12 { 13 "symbol": "BTCUSDT", 14 "incomeType": "COMMISSION", 15 "income": "-0.01000000", 16 "asset": "USDT", 17 "info":"COMMISSION", 18 "time": 1570636800000, 19 "tranId":"9689322392", 20 "tradeId":"2059192" 21 } 22]
Get futures account balance
1console.log(await client.futuresAccountBalance());
1[ 2 { 3 "accountAlias": "SgsR", // unique account code 4 "asset": "USDT", // asset name 5 "balance": "122607.35137903", // wallet balance 6 "crossWalletBalance": "23.72469206", // crossed wallet balance 7 "crossUnPnl": "0.00000000" // unrealized profit of crossed positions 8 "availableBalance": "23.72469206", // available balance 9 "maxWithdrawAmount": "23.72469206" // maximum amount for transfer out 10 } 11]
Get trades for a specific account and symbol.
1console.log( 2 await client.futuresUserTrades({ 3 symbol: 'ETHBTC', 4 }), 5)
Param | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
startTime | LONG | NO | |
endTime | LONG | NO | |
limit | INT | NO | Default 500; max 1000. |
fromId | LONG | NO | Trade id to fetch from. Default gets most recent trades. |
recvWindow | LONG | NO |
1[ 2 { 3 "buyer": false, 4 "commission": "-0.07819010", 5 "commissionAsset": "USDT", 6 "id": 698759, 7 "maker": false, 8 "orderId": 25851813, 9 "price": "7819.01", 10 "qty": "0.002", 11 "quoteQty": "15.63802", 12 "realizedPnl": "-0.91539999", 13 "side": "SELL", 14 "positionSide": "SHORT", 15 "symbol": "BTCUSDT", 16 "time": 1569514978020 17 } 18]
Get notional and leverage brackets.
1console.log( 2 await client.futuresLeverageBracket({ 3 symbol: 'ETHBTC', // Optional 4 }), 5)
Param | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | Use if you are only interested in brackets for one symbol |
recvWindow | LONG | NO |
1[ 2 { 3 "symbol": "ETHUSDT", 4 "brackets": [ 5 { 6 "bracket": 1, // Notional bracket 7 "initialLeverage": 75, // Max initial leverage for this bracket 8 "notionalCap": 10000, // Cap notional of this bracket 9 "notionalFloor": 0, // Notional threshold of this bracket 10 "maintMarginRatio": 0.0065, // Maintenance ratio for this bracket 11 "cum":0 // Auxiliary number for quick calculation 12 13 }, 14 ] 15 } 16]
Check an order's status.
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
orderId | LONG | NO | |
origClientOrderId | STRING | NO | |
recvWindow | LONG | NO |
Either orderId or origClientOrderId must be sent.
1console.log( 2 await client.deliveryGetOrder({ 3 symbol: 'BTCUSD_200925', 4 orderId: 1917641, 5 }) 6)
1{ 2 "avgPrice": "0.0", 3 "clientOrderId": "abc", 4 "cumBase": "0", 5 "executedQty": "0", 6 "orderId": 1917641, 7 "origQty": "0.40", 8 "origType": "TRAILING_STOP_MARKET", 9 "price": "0", 10 "reduceOnly": false, 11 "side": "BUY", 12 "status": "NEW", 13 "stopPrice": "9300", // please ignore when order type is TRAILING_STOP_MARKET 14 "closePosition": false, // if Close-All 15 "symbol": "BTCUSD_200925", 16 "pair": "BTCUSD", 17 "time": 1579276756075, // order time 18 "timeInForce": "GTC", 19 "type": "TRAILING_STOP_MARKET", 20 "activatePrice": "9020", // activation price, only return with TRAILING_STOP_MARKET order 21 "priceRate": "0.3", // callback rate, only return with TRAILING_STOP_MARKET order 22 "updateTime": 1579276756075, // update time 23 "workingType": "CONTRACT_PRICE", 24 "priceProtect": false // if conditional order trigger is protected 25}
Get all account orders; active, canceled, or filled.
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | The pair name |
orderId | LONG | NO | |
startTime | LONG | NO | |
endTime | LONG | NO | |
limit | INT | NO | Default 500; max 1000. |
recvWindow | LONG | NO |
If orderId is set, it will get orders >= that orderId. Otherwise most recent orders are returned.
1console.log( 2 await client.deliveryAllOrders({ symbol: 'BTCUSD_200925' }) 3)
1[ 2 { 3 "avgPrice": "0.0", 4 "clientOrderId": "abc", 5 "cumBase": "0", 6 "executedQty": "0", 7 "orderId": 1917641, 8 "origQty": "0.40", 9 "origType": "TRAILING_STOP_MARKET", 10 "price": "0", 11 "reduceOnly": false, 12 "side": "BUY", 13 "positionSide": "SHORT", 14 "status": "NEW", 15 "stopPrice": "9300", // please ignore when order type is TRAILING_STOP_MARKET 16 "closePosition": false, // if Close-All 17 "symbol": "BTCUSD_200925", 18 "pair": "BTCUSD", 19 "time": 1579276756075, // order time 20 "timeInForce": "GTC", 21 "type": "TRAILING_STOP_MARKET", 22 "activatePrice": "9020", // activation price, only return with TRAILING_STOP_MARKET order 23 "priceRate": "0.3", // callback rate, only return with TRAILING_STOP_MARKET order 24 "updateTime": 1579276756075, // update time 25 "workingType": "CONTRACT_PRICE", 26 "priceProtect": false // if conditional order trigger is protected 27 } 28 ... 29]
Place multiple orders
Name | Type | Mandatory | Description |
---|---|---|---|
batchOrders | LIST | YES | order list. Max 5 orders |
Cancel multiple orders
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | The pair name |
orderIdList | STRING | NO | max length 10 e.g. '[1234567,2345678]' |
origClientOrderIdList | STRING | NO | max length 10 e.g. '["my_id_1","my_id_2"]' , encode the double quotes. No space after comma. |
Change user's initial leverage of specific symbol market.
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | The pair name |
leverage | INT | YES | target initial leverage: int from 1 to 125 |
recvWindow | LONG | NO |
1console.log( 2 await client.deliveryLeverage({ 3 symbol: 'BTCUSD_200925', 4 leverage: 21, 5 }) 6)
1{ 2 "leverage": 21, 3 "maxQty": "1000", // maximum quantity of base asset 4 "symbol": "BTCUSD_200925" 5}
Change margin type.
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | The pair name |
marginType | ENUM | YES | ISOLATED, CROSSED |
recvWindow | LONG | NO |
1console.log( 2 await client.futuresMarginType({ 3 symbol: 'BTCUSD_200925', 4 marginType: 'ISOLATED', 5 }) 6)
1{ 2 "code": 200, 3 "msg": "success" 4}
Modify isolated position margin.
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | The pair name |
positionSide | ENUM | NO | Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. It must be sent with Hedge Mode. |
amount | DECIMAL | YES | |
type | INT | YES | 1: Add position margin,2: Reduce position margin |
recvWindow | LONG | NO |
Only for isolated symbol.
1console.log( 2 await client.deliveryPositionMargin({ 3 symbol: 'BTCUSD_200925', 4 amount: 100, 5 type: 1, 6 }) 7)
1{ 2 "amount": 100.0, 3 "code": 200, 4 "msg": "Successfully modify position margin.", 5 "type": 1 6}
Get position margin change history.
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | The pair name |
type | INT | NO | 1: Add position margin,2: Reduce position margin |
startTime | LONG | NO | |
endTime | LONG | NO | |
limit | INT | NO | Default 50; |
recvWindow | LONG | NO |
1console.log( 2 await client.deliveryMarginHistory({ 3 symbol: 'BTCUSD_200925', 4 type: 1, 5 startTime: 1578047897180, 6 limit: 10, 7 }) 8)
1[ 2 { 3 "amount": "23.36332311", 4 "asset": "BTC", 5 "symbol": "BTCUSD_200925", 6 "time": 1578047897183, 7 "type": 1, 8 "positionSide": "BOTH" 9 }, 10 { 11 "amount": "100", 12 "asset": "BTC", 13 "symbol": "BTCUSD_200925", 14 "time": 1578047900425, 15 "type": 1, 16 "positionSide": "LONG" 17 } 18 ... 19]
Get income history.
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | The pair name |
incomeType | STRING | NO | "TRANSFER","WELCOME_BONUS", "REALIZED_PNL", "FUNDING_FEE", "COMMISSION", and "INSURANCE_CLEAR" |
startTime | LONG | NO | Timestamp in ms to get funding from INCLUSIVE. |
endTime | LONG | NO | Timestamp in ms to get funding until INCLUSIVE. |
limit | INT | NO | Default 100; max 1000 |
recvWindow | LONG | NO |
incomeType
is not sent, all kinds of flow will be returnedtrandId
is unique in the same incomeType for a userstartTime
and endTime
can not exceed 200 days:
startTime
and endTime
are not sent, the last 200 days will be returned1console.log( 2 await client.deliveryIncome({ 3 symbol: 'BTCUSD_200925', 4 startTime: 1570608000000, 5 limit: 700, 6 }) 7)
1[ 2 { 3 "symbol": "", // trade symbol, if existing 4 "incomeType": "TRANSFER", // income type 5 "income": "-0.37500000", // income amount 6 "asset": "BTC", // income asset 7 "info":"WITHDRAW", // extra information 8 "time": 1570608000000, 9 "tranId":"9689322392", // transaction id 10 "tradeId":"" // trade id, if existing 11 }, 12 { 13 "symbol": "BTCUSD_200925", 14 "incomeType": "COMMISSION", 15 "income": "-0.01000000", 16 "asset": "BTC", 17 "info":"", 18 "time": 1570636800000, 19 "tranId":"9689322392", 20 "tradeId":"2059192" 21 } 22]
Get delivery account balance
1console.log(await client.deliveryAccountBalance());
1[ 2 { 3 "accountAlias": "SgsR", // unique account code 4 "asset": "BTC", 5 "balance": "0.00250000", 6 "withdrawAvailable": "0.00250000", 7 "crossWalletBalance": "0.00241969", 8 "crossUnPnl": "0.00000000", 9 "availableBalance": "0.00241969", 10 "updateTime": 1592468353979 11 } 12 ... 13]
Get trades for a specific account and symbol.
1console.log( 2 await client.deliveryUserTrades({ 3 symbol: 'BTCUSD_200626', 4 }), 5)
Param | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | |
pair | STRING | NO | |
startTime | LONG | NO | |
endTime | LONG | NO | |
limit | INT | NO | Default 50; max 1000. |
fromId | LONG | NO | Trade id to fetch from. Default gets most recent trades. |
recvWindow | LONG | NO |
fromId
cannot be sent with startTime
or endTime
1[ 2 { 3 'symbol': 'BTCUSD_200626', 4 'id': 6, 5 'orderId': 28, 6 'pair': 'BTCUSD', 7 'side': 'SELL', 8 'price': '8800', 9 'qty': '1', 10 'realizedPnl': '0', 11 'marginAsset': 'BTC', 12 'baseQty': '0.01136364', 13 'commission': '0.00000454', 14 'commissionAsset': 'BTC', 15 'time': 1590743483586, 16 'positionSide': 'BOTH', 17 'buyer': false, 18 'maker': false 19 } 20 ... 21] 22
Get the pair's default notional bracket list.
1console.log( 2 await client.deliveryLeverageBracket({ 3 pair: 'BTCUSD', // Optional 4 }), 5)
Param | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | Use if you are only interested in brackets for one symbol |
recvWindow | LONG | NO |
1[ 2 { 3 "pair": "BTCUSD", 4 "brackets": [ 5 { 6 "bracket": 1, // bracket level 7 "initialLeverage": 125, // the maximum leverage 8 "qtyCap": 50, // upper edge of base asset quantity 9 "qtylFloor": 0, // lower edge of base asset quantity 10 "maintMarginRatio": 0.004 // maintenance margin rate 11 "cum": 0.0 // Auxiliary number for quick calculation 12 }, 13 ] 14 } 15]
Every websocket utility returns a function you can call to close the opened connection and avoid memory issues.
1const clean = client.ws.depth('ETHBTC', depth => { 2 console.log(depth) 3}) 4 5// After you're done 6clean()
Live depth market data feed. The first parameter can either
be a single symbol string or an array of symbols. If you wish
to specify the update speed (can either be 1000ms
or 100ms
)
of the stream then append the speed at the end of the symbol
string as follows: ETHBTC@100ms
1client.ws.depth('ETHBTC', depth => { 2 console.log(depth) 3})
1{ 2 eventType: 'depthUpdate', 3 eventTime: 1508612956950, 4 symbol: 'ETHBTC', 5 firstUpdateId: 18331140, 6 finalUpdateId: 18331145, 7 bidDepth: [ 8 { price: '0.04896500', quantity: '0.00000000' }, 9 { price: '0.04891100', quantity: '15.00000000' }, 10 { price: '0.04891000', quantity: '0.00000000' } ], 11 askDepth: [ 12 { price: '0.04910600', quantity: '0.00000000' }, 13 { price: '0.04910700', quantity: '11.24900000' } 14 ] 15}
You can add custom sub streams by view docs
1client.ws.customSubStream('!markPrice@arr@1s', console.log)
Top levels bids and asks, pushed every second. Valid levels are 5, 10, or 20.
Accepts an array of objects for multiple depths. If you wish
to specify the update speed (can either be 1000ms
or 100ms
)
of the stream then append the speed at the end of the symbol
string as follows: ETHBTC@100ms
1client.ws.partialDepth({ symbol: 'ETHBTC', level: 10 }, depth => {
2 console.log(depth)
3})
1{ 2 symbol: 'ETHBTC', 3 level: 10, 4 bids: [ 5 { price: '0.04896500', quantity: '0.00000000' }, 6 { price: '0.04891100', quantity: '15.00000000' }, 7 { price: '0.04891000', quantity: '0.00000000' } 8 ], 9 asks: [ 10 { price: '0.04910600', quantity: '0.00000000' }, 11 { price: '0.04910700', quantity: '11.24900000' } 12 ] 13}
24hr Ticker statistics for a symbol pushed every second. Accepts an array of symbols.
1client.ws.ticker('HSRETH', ticker => { 2 console.log(ticker) 3})
1{ 2 eventType: '24hrTicker', 3 eventTime: 1514670820924, 4 symbol: 'HSRETH', 5 priceChange: '-0.00409700', 6 priceChangePercent: '-11.307', 7 weightedAvg: '0.03394946', 8 prevDayClose: '0.03623500', 9 curDayClose: '0.03213800', 10 closeTradeQuantity: '7.02000000', 11 bestBid: '0.03204200', 12 bestBidQnt: '78.00000000', 13 bestAsk: '0.03239800', 14 bestAskQnt: '7.00000000', 15 open: '0.03623500', 16 high: '0.03659900', 17 low: '0.03126000', 18 volume: '100605.15000000', 19 volumeQuote: '3415.49097353', 20 openTime: 1514584420922, 21 closeTime: 1514670820922, 22 firstTradeId: 344803, 23 lastTradeId: 351380, 24 totalTrades: 6578 25}
Retrieves all the tickers.
1client.ws.allTickers(tickers => {
2 console.log(tickers)
3})
24hr Mini Ticker statistics for a symbol pushed every second. Accepts an array of symbols.
1client.ws.miniTicker('HSRETH', ticker => {
2 console.log(ticker)
3})
1{ 2 eventType: '24hrMiniTicker', 3 eventTime: 1514670820924, 4 symbol: 'HSRETH', 5 curDayClose: '0.03213800', 6 open: '0.03623500', 7 high: '0.03659900', 8 low: '0.03126000', 9 volume: '100605.15000000', 10 volumeQuote: '3415.49097353' 11}
Retrieves all the mini tickers.
1client.ws.allMiniTickers(tickers => {
2 console.log(tickers)
3})
Pushes any update to the best bid or ask's price or quantity in real-time for a specified symbol. Accepts a single symbol or an array of symbols.
1client.ws.bookTicker('BTCUSDT', ticker => {
2 console.log(ticker)
3})
1{ 2 updateId: 23099391508, 3 symbol: 'BTCUSDT', 4 bestBid: '21620.03000000', 5 bestBidQnt: '0.09918000', 6 bestAsk: '21621.65000000', 7 bestAskQnt: '0.06919000' 8}
Live candle data feed for a given interval. You can pass either a symbol string or a symbol array.
1client.ws.candles('ETHBTC', '1m', candle => { 2 console.log(candle) 3})
1{ 2 eventType: 'kline', 3 eventTime: 1508613366276, 4 symbol: 'ETHBTC', 5 open: '0.04898000', 6 high: '0.04902700', 7 low: '0.04898000', 8 close: '0.04901900', 9 volume: '37.89600000', 10 trades: 30, 11 interval: '5m', 12 isFinal: false, 13 quoteVolume: '1.85728874', 14 buyVolume: '21.79900000', 15 quoteBuyVolume: '1.06838790' 16}
Live trade data feed. Pass either a single symbol string or an array of symbols. The trade streams push raw trade information; each trade has a unique buyer and seller.
1client.ws.trades(['ETHBTC', 'BNBBTC'], trade => { 2 console.log(trade) 3})
1{ 2 eventType: 'trade', 3 eventTime: 1508614495052, 4 tradeTime: 1508614495050, 5 symbol: 'ETHBTC', 6 price: '0.04923600', 7 quantity: '3.43500000', 8 isBuyerMaker: true, 9 maker: true, 10 tradeId: 2148226, 11 buyerOrderId: 390876, 12 sellerOrderId: 390752 13}
Live trade data feed. Pass either a single symbol string or an array of symbols. The aggregate trade streams push trade information that is aggregated for a single taker order.
1client.ws.aggTrades(['ETHBTC', 'BNBBTC'], trade => { 2 console.log(trade) 3})
1{ 2 eventType: 'aggTrade', 3 eventTime: 1508614495052, 4 aggId: 2148226, 5 price: '0.04923600', 6 quantity: '3.43500000', 7 firstId: 37856, 8 lastId: 37904, 9 timestamp: 1508614495050, 10 symbol: 'ETHBTC', 11 isBuyerMaker: false, 12 wasBestPrice: true 13}
Live user messages data feed.
Requires authentication
1const clean = await client.ws.user(msg => { 2 console.log(msg) 3})
There is also equivalent function to query the margin wallet:
1client.ws.marginUser()
Note that this method return a promise which will resolve the clean
callback.
1{ 2 eventType: 'account', 3 eventTime: 1508614885818, 4 balances: { 5 '123': { available: '0.00000000', locked: '0.00000000' }, 6 '456': { available: '0.00000000', locked: '0.00000000' }, 7 BTC: { available: '0.00000000', locked: '0.00000000' }, 8 } 9}
Every websocket utility returns a function you can call to close the opened connection and avoid memory issues.
1const clean = client.ws.futuresDepth('ETHBTC', depth => { 2 console.log(depth) 3}) 4 5// After you're done 6clean()
Each websocket utility supports the ability to get a clean callback without data transformation, for this, pass the third attribute FALSE.
1const clean = client.ws.futuresDepth('ETHBTC', depth => {
2 console.log(depth)
3}, false)
1{ 2 "e": "depthUpdate", // Event type 3 "E": 123456789, // Event time 4 "T": 123456788, // transaction time 5 "s": "BTCUSDT", // Symbol 6 "U": 157, // First update ID in event 7 "u": 160, // Final update ID in event 8 "pu": 149, // Final update Id in last stream(ie `u` in last stream) 9 "b": [ // Bids to be updated 10 [ 11 "0.0024", // Price level to be updated 12 "10" // Quantity 13 ] 14 ], 15 "a": [ // Asks to be updated 16 [ 17 "0.0026", // Price level to be updated 18 "100" // Quantity 19 ] 20 ] 21}
Live futuresDepth market data feed. The first parameter can either be a single symbol string or an array of symbols.
1client.ws.futuresDepth('ETHBTC', depth => {
2 console.log(depth)
3})
1{ 2 eventType: 'depthUpdate', 3 eventTime: 1508612956950, 4 symbol: 'ETHBTC', 5 firstUpdateId: 18331140, 6 finalUpdateId: 18331145, 7 bidDepth: [ 8 { price: '0.04896500', quantity: '0.00000000' }, 9 { price: '0.04891100', quantity: '15.00000000' }, 10 { price: '0.04891000', quantity: '0.00000000' } ], 11 askDepth: [ 12 { price: '0.04910600', quantity: '0.00000000' }, 13 { price: '0.04910700', quantity: '11.24900000' } 14 ] 15}
Top levels bids and asks, pushed every second. Valid levels are 5, 10, or 20. Accepts an array of objects for multiple depths.
1client.ws.futuresPartialDepth({ symbol: 'ETHBTC', level: 10 }, depth => {
2 console.log(depth)
3})
1{ 2 3 eventType: 'depthUpdate', 4 eventTime: 1508612956950, 5 symbol: 'ETHBTC', 6 level: 10, 7 firstUpdateId: 18331140, 8 finalUpdateId: 18331145, 9 bidDepth: [ 10 { price: '0.04896500', quantity: '0.00000000' }, 11 { price: '0.04891100', quantity: '15.00000000' }, 12 { price: '0.04891000', quantity: '0.00000000' } ], 13 askDepth: [ 14 { price: '0.04910600', quantity: '0.00000000' }, 15 { price: '0.04910700', quantity: '11.24900000' } 16 ] 17}
24hr Ticker statistics for a symbol pushed every 500ms. Accepts an array of symbols.
1client.ws.futuresTicker('HSRETH', ticker => {
2 console.log(ticker)
3})
1{ 2 eventType: '24hrTicker', 3 eventTime: 123456789, 4 symbol: 'BTCUSDT', 5 priceChange: '0.0015', 6 priceChangePercent: '250.00', 7 weightedAvg: '0.0018', 8 curDayClose: '0.0025', 9 closeTradeQuantity: '10', 10 open: '0.0010', 11 high: '0.0025', 12 low: '0.0010', 13 volume: '10000', 14 volumeQuote: '18', 15 openTime: 0, 16 closeTime: 86400000, 17 firstTradeId: 0, 18 lastTradeId: 18150, 19 totalTrades: 18151, 20}
Retrieves all the tickers.
1client.ws.futuresAllTickers(tickers => {
2 console.log(tickers)
3})
Live candle data feed for a given interval. You can pass either a symbol string or a symbol array.
1client.ws.futuresCandles('ETHBTC', '1m', candle => { 2 console.log(candle) 3})
1{ 2 eventType: 'kline', 3 eventTime: 1508613366276, 4 symbol: 'ETHBTC', 5 open: '0.04898000', 6 high: '0.04902700', 7 low: '0.04898000', 8 close: '0.04901900', 9 volume: '37.89600000', 10 trades: 30, 11 interval: '5m', 12 isFinal: false, 13 quoteVolume: '1.85728874', 14 buyVolume: '21.79900000', 15 quoteBuyVolume: '1.06838790' 16}
Live trade data feed. Pass either a single symbol string or an array of symbols. The Aggregate Trade Streams push trade information that is aggregated for a single taker order every 100 milliseconds.
1client.ws.futuresAggTrades(['ETHBTC', 'BNBBTC'], trade => { 2 console.log(trade) 3})
1{ 2 eventType: 'aggTrade', 3 eventTime: 1508614495052, 4 aggId: 2148226, 5 price: '0.04923600', 6 quantity: '3.43500000', 7 firstId: 37856, 8 lastId: 37904, 9 timestamp: 1508614495050, 10 symbol: 'ETHBTC', 11 isBuyerMaker: false, 12}
Live liquidation data feed. Pass either a single symbol string or an array of symbols. The Liquidation Order Streams push force liquidation order information for specific symbol(s).
1client.ws.futuresLiquidations(['ETHBTC', 'BNBBTC'], liquidation => { 2 console.log(liquidation) 3})
1{ 2 symbol: string 3 price: '0.04923600', 4 origQty: '3.43500000', 5 lastFilledQty: '3.43500000', 6 accumulatedQty: '3.43500000', 7 averagePrice: '0.04923600', 8 status: 'FILLED', 9 timeInForce: 'IOC', 10 type: 'LIMIT', 11 side: 'SELL', 12 time: 1508614495050 13}
Live liquidation data feed. Pass either a single symbol string or an array of symbols. The All Liquidation Order Streams push force liquidation order information for all symbols in the market.
1client.ws.futuresAllLiquidations(liquidation => {
2 console.log(liquidation)
3})
1{ 2 symbol: string 3 price: '0.04923600', 4 origQty: '3.43500000', 5 lastFilledQty: '3.43500000', 6 accumulatedQty: '3.43500000', 7 averagePrice: '0.04923600', 8 status: 'FILLED', 9 timeInForce: 'IOC', 10 type: 'LIMIT', 11 side: 'SELL', 12 time: 1508614495050 13}
You can add custom sub streams by view docs
1client.ws.futuresCustomSubStream(['!markPrice@arr','ETHBTC@markPrice@1s'], console.log)
Live user messages data feed.
Requires authentication
1const futuresUser = await client.ws.futuresUser(msg => {
2 console.log(msg)
3})
1{ 2 eventTime: 1564745798939, 3 transactionTime: 1564745798938, 4 eventType: 'ACCOUNT_UPDATE', 5 eventReasonType: 'ORDER', 6 balances: [ 7 { 8 asset:'USDT', 9 walletBalance:'122624.12345678', 10 crossWalletBalance:'100.12345678' 11 }, 12 { 13 asset:'BNB', 14 walletBalance:'1.00000000', 15 crossWalletBalance:'0.00000000' 16 } 17 ], 18 positions: [ 19 { 20 symbol:'BTCUSDT', 21 positionAmount:'0', 22 entryPrice:'0.00000', 23 accumulatedRealized:'200', 24 unrealizedPnL:'0', 25 marginType:'isolated', 26 isolatedWallet:'0.00000000', 27 positionSide:'BOTH' 28 }, 29 { 30 symbol:'BTCUSDT', 31 positionAmount:'20', 32 entryPrice:'6563.66500', 33 accumulatedRealized:'0', 34 unrealizedPnL:'2850.21200', 35 marginType:'isolated', 36 isolatedWallet:'13200.70726908', 37 positionSide:'LONG' 38 } 39 ], 40}
Every websocket utility returns a function you can call to close the opened connection and avoid memory issues.
1const clean = client.ws.deliveryDepth('BTCUSD_200626', depth => { 2 console.log(depth) 3}) 4 5// After you're done 6clean()
Each websocket utility supports the ability to get a clean callback without data transformation, for this, pass the third attribute FALSE.
1const clean = client.ws.deliveryDepth('BTCUSD_200626', depth => {
2 console.log(depth)
3}, false)
1{ 2 "e": "depthUpdate", // Event type 3 "E": 1591270260907, // Event time 4 "T": 1591270260891, // Transction time 5 "s": "BTCUSD_200626", // Symbol 6 "ps": "BTCUSD", // Pair 7 "U": 17285681, // First update ID in event 8 "u": 17285702, // Final update ID in event 9 "pu": 17285675, // Final update Id in last stream(ie `u` in last stream) 10 "b": [ // Bids to be updated 11 [ 12 "9517.6", // Price level to be updated 13 "10" // Quantity 14 ] 15 ], 16 "a": [ // Asks to be updated 17 [ 18 "9518.5", // Price level to be updated 19 "45" // Quantity 20 ] 21 ] 22}
Live futuresDepth market data feed. The first parameter can either be a single symbol string or an array of symbols.
1client.ws.deliveryDepth('TRXUSD_PERP', depth => {
2 console.log(depth)
3})
1{ 2 eventType: 'depthUpdate', 3 eventTime: 1663111254317, 4 transactionTime: 1663111254138, 5 symbol: 'TRXUSD_PERP', 6 pair: 'TRXUSD', 7 firstUpdateId: 558024151999, 8 finalUpdateId: 558024152633, 9 prevFinalUpdateId: 558024150524, 10 bidDepth: [ 11 { price: '0.06052', quantity: '1805' }, 12 { price: '0.06061', quantity: '313' } 13 ], 14 askDepth: [ 15 { price: '0.06062', quantity: '314' }, 16 { price: '0.06063', quantity: '790' }, 17 { price: '0.06065', quantity: '1665' }, 18 { price: '0.06066', quantity: '2420' } 19 ] 20}
Top bids and asks. Valid levels are 5, 10, or 20. Update Speed : 250ms, 500ms or 100ms. Accepts an array of objects for multiple depths.
1client.ws.deliveryPartialDepth({ symbol: 'TRXUSD_PERP', level: 10 }, depth => {
2 console.log(depth)
3})
1{ 2 level: 10, 3 eventType: 'depthUpdate', 4 eventTime: 1663111554598, 5 transactionTime: 1663111554498, 6 symbol: 'TRXUSD_PERP', 7 pair: 'TRXUSD', 8 firstUpdateId: 558027933795, 9 finalUpdateId: 558027935097, 10 prevFinalUpdateId: 558027932895, 11 bidDepth: [ 12 { price: '0.06063', quantity: '604' }, 13 { price: '0.06062', quantity: '227' }, 14 { price: '0.06061', quantity: '327' } 15 ], 16 askDepth: [ 17 { price: '0.06064', quantity: '468' }, 18 { price: '0.06065', quantity: '131' } 19 ] 20}
24hr rollwing window ticker statistics for a single symbol. These are NOT the statistics of the UTC day, but a 24hr rolling window from requestTime to 24hrs before. Accepts an array of symbols.
1client.ws.deliveryTicker('BNBUSD_PERP', ticker => {
2 console.log(ticker)
3})
1{ 2 eventType: '24hrTicker', 3 eventTime: 1664834148221, 4 symbol: 'BNBUSD_PERP', 5 pair: 'BNBUSD', 6 priceChange: '0.130', 7 priceChangePercent: '0.046', 8 weightedAvg: '286.02648763', 9 curDayClose: '285.745', 10 closeTradeQuantity: '1', 11 open: '285.615', 12 high: '289.050', 13 low: '282.910', 14 volume: '9220364', 15 volumeBase: '322360.49452795', 16 openTime: 1664747700000, 17 closeTime: 1664834148215, 18 firstTradeId: 179381113, 19 lastTradeId: 179462069, 20 totalTrades: 80957 21}
Retrieves all the tickers.
1client.ws.deliveryAllTickers(tickers => {
2 console.log(tickers)
3})
Live candle data feed for a given interval. You can pass either a symbol string or a symbol array.
1client.ws.deliveryCandles('ETHUSD_PERP', '1m', candle => { 2 console.log(candle) 3})
1{ 2 eventType: 'kline', 3 eventTime: 1664834318306, 4 symbol: 'ETHUSD_PERP', 5 startTime: 1664834280000, 6 closeTime: 1664834339999, 7 firstTradeId: 545784425, 8 lastTradeId: 545784494, 9 open: '1317.68', 10 high: '1317.91', 11 low: '1317.68', 12 close: '1317.91', 13 volume: '6180', 14 trades: 70, 15 interval: '1m', 16 isFinal: false, 17 baseVolume: '46.89730466', 18 buyVolume: '5822', 19 baseBuyVolume: '44.18040830' 20}
Live trade data feed. Pass either a single symbol string or an array of symbols. The Aggregate Trade Streams push trade information that is aggregated for a single taker order every 100 milliseconds.
1client.ws.deliveryAggTrades(['ETHUSD_PERP', 'BNBUSD_PERP'], trade => { 2 console.log(trade) 3})
1{ 2 eventType: 'aggTrade', 3 eventTime: 1664834403682, 4 symbol: 'ETHUSD_PERP', 5 aggId: 216344302, 6 price: '1317.57', 7 quantity: '1318', 8 firstId: 545784591, 9 lastId: 545784591, 10 timestamp: 1664834403523, 11 isBuyerMaker: false 12}
You can add custom sub streams by view docs
1client.ws.deliveryCustomSubStream(['!miniTicker@arr','ETHUSD_PERP@markPrice@1s'], console.log)
Live user messages data feed. For different event types, see official documentation
Requires authentication
1const deliveryUser = await client.ws.deliveryUser(msg => {
2 console.log(msg)
3})
1{ 2 eventTime: 1664834883117, 3 transactionTime: 1664834883101, 4 eventType: 'ACCOUNT_UPDATE', 5 eventReasonType: 'ORDER', 6 balances: [ 7 { 8 asset: 'BUSD', 9 walletBalance: '123.45678901', 10 crossWalletBalance: '123.45678901', 11 balanceChange: '0' 12 }, 13 { 14 asset: 'BNB', 15 walletBalance: '0.12345678', 16 crossWalletBalance: '0.12345678', 17 balanceChange: '0' 18 } 19 ], 20 positions: [ 21 { 22 symbol: 'ETHBUSD', 23 positionAmount: '420.024', 24 entryPrice: '1234.56789', 25 accumulatedRealized: '9000.12345678', 26 unrealizedPnL: '0.38498800', 27 marginType: 'cross', 28 isolatedWallet: '0', 29 positionSide: 'BOTH' 30 } 31 ] 32}
To get information about limits from response headers call getInfo()
1console.log(client.getInfo())
1{ 2 futures: { 3 futuresLatency: "2ms", 4 orderCount1m: "10", 5 usedWeigh1m: "1", 6 }, 7 spot: { 8 orderCount1d: "347", 9 orderCount10s: "1", 10 usedWeigh1m: "15", 11 }, 12 delivery: { 13 usedWeight1m: '13', 14 responseTime: '4ms', 15 orderCount1m: '1' 16 } 17}
An utility error code map is also being exported by the package in order for you to make readable conditionals upon specific errors that could occur while using the API.
1import Binance, { ErrorCodes } from 'binance-api-node' 2 3console.log(ErrorCodes.INVALID_ORDER_TYPE) // -1116
No vulnerabilities found.
No security vulnerabilities found.