Gathering detailed insights and metrics for node-binance-api
Gathering detailed insights and metrics for node-binance-api
Gathering detailed insights and metrics for node-binance-api
Gathering detailed insights and metrics for node-binance-api
binance-api-node
A node API wrapper for Binance
binance
Professional Node.js & JavaScript SDK for Binance REST APIs & WebSockets, with TypeScript & end-to-end tests.
@liesauer/node-binance-api
Binance API for node https://github.com/jaggedsoft/node-binance-api
open-binance-api
Binance API Client
Node Binance API is an asynchronous node.js library for the Binance API designed to be easy to use.
npm install node-binance-api
Typescript
Module System
Node Version
NPM Version
75.5
Supply Chain
98.8
Quality
88.7
Maintenance
100
Vulnerability
99.3
License
TypeScript (50.28%)
JavaScript (49.58%)
Shell (0.14%)
Total Downloads
1,102,450
Last Day
327
Last Week
3,244
Last Month
12,322
Last Year
102,415
MIT License
1,631 Stars
1,236 Commits
775 Forks
65 Watchers
19 Branches
83 Contributors
Updated on Jul 23, 2025
Latest Version
1.0.11
Package Id
node-binance-api@1.0.11
Unpacked Size
1.12 MB
Size
156.74 kB
File Count
13
NPM Version
10.8.2
Node Version
20.19.0
Published on
Jul 10, 2025
Cumulative downloads
Total Downloads
Last Day
13.1%
327
Compared to previous day
Last Week
20.1%
3,244
Compared to previous week
Last Month
46%
12,322
Compared to previous month
Last Year
-26.9%
102,415
Compared to previous year
9
32
This project is designed to help you make your own projects that interact with the Binance API. You can stream candlestick chart data, market depth, or use other advanced features such as setting stop losses and iceberg orders. This project seeks to have complete API coverage including WebSockets.
Futures API &
Streams •
Spot Trading API &
Streams •
Margin API •
Lending API
Examples •
Troubleshooting •
Changelog •
Support
npm install node-binance-api
Actively maintained, typed, and safe SDK for the Binance REST APIs and Websockets. Supports ESM and CJS out of the box.
We highly advise you to update from 0.0.X but minor adjustments might be needed.
The library was fully refactored to use a modern and typed JavaScript/Typescript version, using the built-in await/async syntax and unifying some methods' signatures. Some important changes include the removal of callbacks as parameters of REST methods, adaptation of signatures to directly receive some important request values (symbol, orderId, ...), among others.
1import Binance from 'node-binance-api'; 2async function run() { 3 const exchange = new Binance(); 4 const res = await exchange.futuresTime(); 5 console.log( res ); 6}
1const Binance = require('node-binance-api'); 2const binance = new Binance({ 3 APIKEY: '<key>', 4 APISECRET: '<secret>', 5 test: true, // if you want to use the sandbox/testnet 6});
1console.info( await binance.futuresPrices() );
1console.info( await binance.futuresAccount() );
1console.info( await binance.futuresBalance() );
1console.info( await binance.futuresBuy( 'LIMIT', 'BTCUSDT', 0.1, 8222 ) );
1console.info( await binance.futuresSell( 'LIMIT', 'BTCUSDT', 0.5, 11111 ) );
1console.info( await binance.futuresMarketBuy( 'BNBUSDT', 5 ) );
1console.info( await binance.futuresMarketSell( 'TRXUSDT', 1 ) );
1let orders = [ 2 { 3 symbol:"BTCUSDT", 4 side: "BUY", 5 type: "MARKET", 6 quantity: "0.01", 7 }, 8 { 9 symbol:"BNBUSDT", 10 side: "SELL", 11 type: "MARKET", 12 quantity: "0.5", 13 } 14] 15console.info( await binance.futuresMultipleOrders(orders) );
1console.info( await binance.futuresMarketBuy( 'BNBUSDT', amount, { newOrderRespType: 'RESULT' } ) );
1if ( side == 'LONG' ) order = await binance.futuresMarketSell( obj.symbol, amount, {reduceOnly: true} )
2else order = await binance.futuresMarketBuy( obj.symbol, amount, {reduceOnly: true} )
1console.info( await binance.futuresPositionRisk() );
1let position_data = await binance.futuresPositionRisk(), markets = Object.keys( position_data ); 2for ( let market of markets ) { 3 let obj = position_data[market], size = Number( obj.positionAmt ); 4 if ( size == 0 ) continue; 5 console.info( `${leverage}x\t${market}\t${obj.unRealizedProfit}` ); 6 //console.info( obj ); //positionAmt entryPrice markPrice unRealizedProfit liquidationPrice leverage marginType isolatedMargin isAutoAddMargin maxNotionalValue 7}
1console.info( await binance.futuresLeverage( 'ETHUSDT', 50 ) );
1console.info( await binance.futuresMarginType( 'BTCUSDT', 'ISOLATED' ) );
1// Type: 1: Add postion margin,2: Reduce postion margin 2console.info( await binance.futuresPositionMargin( "TRXUSDT", amount, type ) );
1console.info( await binance.futuresTime() ); 2console.info( await binance.futuresExchangeInfo() ); 3console.info( await binance.futuresCandles( "TRXUSDT", "1m" ) ); 4console.info( await binance.futuresDepth( "ADAUSDT" ) ); 5console.info( await binance.futuresQuote() ); 6console.info( await binance.futuresQuote( "BCHUSDT" ) ); 7console.info( await binance.futuresDaily() ); 8console.info( await binance.futuresOpenInterest( "BTCUSDT" ) ); 9console.info( await binance.futuresMarkPrice() ); 10console.info( await binance.futuresMarkPrice( "ETHUSDT" ) ); 11console.info( await binance.futuresTrades( "LTCUSDT" ) ); 12console.info( await binance.futuresAggTrades( "XTZUSDT" ) ); 13console.info( await binance.futuresLiquidationOrders() ); 14console.info( await binance.futuresFundingRate() ); 15console.info( await binance.futuresHistoricalTrades( "XMRUSDT" ) ); 16console.info( await binance.futuresLeverageBracket( "LINKUSDT" ) ); 17console.info( await binance.futuresIncome() ); 18console.info( await binance.futuresCancelAll( "BTCUSDT" ) ); 19console.info( await binance.futuresCancel( "BTCUSDT", "1025137386" ) ); 20console.info( await binance.futuresCountdownCancelAll( "BTCUSDT", 45000 ) ); 21console.info( await binance.futuresOrderStatus( "BTCUSDT", "1025137386") ); 22console.info( await binance.futuresOpenOrders() ); 23console.info( await binance.futuresOpenOrders( "BTCUSDT" ) ); 24console.info( await binance.futuresAllOrders() ); 25console.info( await binance.futuresAllOrders( "BTCUSDT" ) ); 26console.info( await binance.futuresUserTrades( "BTCUSDT" ) ); 27console.info( await binance.futuresGetDataStream() ); 28console.info( await binance.futuresPositionMarginHistory( "TRXUSDT" ) ); 29console.info( await binance.futuresPublicRequest( 'v1/time' ) ); 30console.info( await binance.spotPublicRequest( 'v1/time')); // call any method by providing the path 31console.info( await binance.privateFuturesRequest('v3/account')); // custom futures private call 32// Batch orders, remaining WebSocket streams, and better documentation will be come later
In some specific cases using a proxy is required, for example:
This package supports the following proxy types, httpsProxy
, proxyUrl
and socksProxy
To set a real http(s) proxy for your scripts, you need to have an access to a remote http or https proxy, so calls will be made directly to the target exchange, tunneled through your proxy server:
1client.httpsProxy = 'http://1.2.3.4:8080/';
This property prepends an url to API requests. It might be useful for simple redirection or bypassing CORS browser restriction.
1client.proxyUrl = 'YOUR_PROXY_URL';
Tou can also use socks proxy with the following format:
1client.socksProxy = 'socks5://1.2.3.4:8080/';
1console.info( await binance.futuresHistDataId( 2 "BTCUSDT", { 3 startTime: new Date().getTime() - 24 * 60 * 60 * 1000, 4 endTime: new Date().getTime(), 5 dataType: 'T_TRADE' 6 } ) 7)
1console.info( await binance.futuresDownloadLink(7343) )
1binance.futuresMiniTickerStream( miniTicker => {
2 console.info( miniTicker );
3} );
1binance.futuresMiniTickerStream( 'BTCUSDT', console.log );
1binance.futuresBookTickerStream( console.log );
1binance.futuresBookTickerStream( 'BTCUSDT', console.log );
1binance.futuresTickerStream( console.log );
1binance.futuresTickerStream( 'BTCUSDT', console.log );
1binance.futuresMarkPriceStream( console.log );
1binance.futuresMarkPriceStream( 'BTCUSDT', console.log );
1binance.futuresAggTradeStream( 'BTCUSDT', console.log );
1binance.futuresChart( 'BTCUSDT', '1m', console.log );
1binance.futuresLiquidationStream( console.log );
1binance.futuresLiquidationStream( 'BTCUSDT', console.log );
1binance.futuresSubscribe( 'btcusdt@kline_4h', console.log );
1binance.futuresTerminate( 'btcusdt@kline_4h' );
1console.log( binance.futuresSubscriptions() );
deliveryBuy
deliverySell
deliveryMarketBuy
deliveryMarketSell
deliveryPrices
deliveryDaily
deliveryOpenInterest
deliveryExchangeInfo
deliveryOpenOrders
deliveryAllOrders
deliveryCandles
deliveryIndexKlines
deliveryContinuousKlines
deliveryMarkPriceKlines
deliveryMarkPrice
deliveryHistoricalTrades
deliveryTrades
deliveryAggTrades
deliveryUserTrades
deliveryLiquidationOrders
deliveryPositionRisk
deliveryLeverage
deliveryMarginType
deliveryPositionMargin
deliveryPositionMarginHistory
deliveryIncome
deliveryBalance
deliveryAccount
deliveryDepth
deliveryQuote
deliveryLeverageBracket
deliveryOrderStatus
deliveryCancel
deliveryCancelAll
deliveryCountdownCancelAll
deliveryOrder
deliveryGetDataStream
deliveryCloseDataStream
deliveryKeepDataStream
deliveryPing
deliveryTime
deliveryOrder
1let ticker = await binance.prices(); 2console.info(`Price of BNB: ${ticker.BNBUSDT}`);
1binance.prices('BNBBTC', (error, ticker) => { 2 console.info("Price of BNB: ", ticker.BNBBTC); 3});
1{ ETHBTC: '0.07003500', 2 LTCBTC: '0.01176700', 3 BNBBTC: '0.00035735', 4 NEOBTC: '0.00809500', 5 QTUMETH: '0.03851200', 6 EOSETH: '0.00189600', 7 SNTETH: '0.00008595', 8 BNTETH: '0.00738800', 9 BCCBTC: '0.08104000', 10 GASBTC: '0.00629800', 11 BNBETH: '0.00509495', 12 BTMETH: '0.00018900', 13 HCCBTC: '0.00000180', 14 BTCUSDT: '4464.44000000', 15 ETHUSDT: '312.89000000', 16 HSRBTC: '0.00289000', 17 OAXETH: '0.00180000', 18 DNTETH: '0.00014190', 19 MCOETH: '0.02358300', 20 ICNETH: '0.00557000', 21 ELCBTC: '0.00000053', 22 MCOBTC: '0.00166900', 23 WTCBTC: '0.00184138', 24 WTCETH: '0.02601700', 25 LLTBTC: '0.00001669', 26 LRCBTC: '0.00001100', 27 LRCETH: '0.00016311', 28 QTUMBTC: '0.00271600', 29 YOYOBTC: '0.00000481', 30 OMGBTC: '0.00187800', 31 OMGETH: '0.02677400', 32 ZRXBTC: '0.00004319', 33 ZRXETH: '0.00060800', 34 STRATBTC: '0.00087800', 35 STRATETH: '0.01218800', 36 SNGLSBTC: '0.00003649', 37 SNGLSETH: '0.00051280', 38 BQXBTC: '0.00013150', 39 BQXETH: '0.00184240', 40 KNCBTC: '0.00038969', 41 KNCETH: '0.00550320', 42 FUNBTC: '0.00000573', 43 FUNETH: '0.00008433', 44 SNMBTC: '0.00003176', 45 SNMETH: '0.00047119', 46 NEOETH: '0.11500200', 47 IOTABTC: '0.00012136', 48 IOTAETH: '0.00171001', 49 LINKBTC: '0.00010646', 50 LINKETH: '0.00150999', 51 XVGBTC: '0.00000145', 52 XVGETH: '0.00002059', 53 CTRBTC: '0.00025532', 54 CTRETH: '0.00375180', 55 SALTBTC: '0.00080100', 56 SALTETH: '0.01140000', 57 MDABTC: '0.00057002', 58 MDAETH: '0.00819490' } 59//Price of BNB: 0.00035735
1binance.balance((error, balances) => { 2 if ( error ) return console.error(error); 3 console.info("balances()", balances); 4 console.info("ETH balance: ", balances.ETH.available); 5}); 6// If you have problems with this function, 7// see Troubleshooting at the bottom of this page.
1{ BTC: { available: '0.77206464', onOrder: '0.00177975' }, 2 LTC: { available: '0.00000000', onOrder: '0.00000000' }, 3 ETH: { available: '1.14109900', onOrder: '0.00000000' }, 4 BNC: { available: '0.00000000', onOrder: '0.00000000' }, 5 ICO: { available: '0.00000000', onOrder: '0.00000000' }, 6 NEO: { available: '0.00000000', onOrder: '0.00000000' }, 7 BNB: { available: '41.33761879', onOrder: '0.00000000' }, 8 QTUM: { available: '0.00000000', onOrder: '0.00000000' }, 9 EOS: { available: '0.00000000', onOrder: '0.00000000' }, 10 SNT: { available: '0.00000000', onOrder: '0.00000000' }, 11 BNT: { available: '0.00000000', onOrder: '0.00000000' }, 12 GAS: { available: '0.00000000', onOrder: '0.00000000' }, 13 BCC: { available: '0.00000000', onOrder: '0.00000000' }, 14 BTM: { available: '0.00000000', onOrder: '0.00000000' }, 15 USDT: { available: '0.00000000', onOrder: '0.00000000' }, 16 HCC: { available: '0.00000000', onOrder: '0.00000000' }, 17 HSR: { available: '0.00000000', onOrder: '0.00000000' }, 18 OAX: { available: '0.00000000', onOrder: '0.00000000' }, 19 DNT: { available: '0.00000000', onOrder: '0.00000000' }, 20 MCO: { available: '0.00000000', onOrder: '0.00000000' }, 21 ICN: { available: '0.00000000', onOrder: '0.00000000' }, 22 ELC: { available: '0.00000000', onOrder: '0.00000000' }, 23 PAY: { available: '0.00000000', onOrder: '0.00000000' }, 24 ZRX: { available: '0.00000000', onOrder: '0.00000000' }, 25 OMG: { available: '0.00000000', onOrder: '0.00000000' }, 26 WTC: { available: '0.00000000', onOrder: '0.00000000' }, 27 LRX: { available: '0.00000000', onOrder: '0.00000000' }, 28 YOYO: { available: '0.00000000', onOrder: '0.00000000' }, 29 LRC: { available: '0.00000000', onOrder: '0.00000000' }, 30 LLT: { available: '0.00000000', onOrder: '0.00000000' }, 31 TRX: { available: '0.00000000', onOrder: '0.00000000' }, 32 FID: { available: '0.00000000', onOrder: '0.00000000' }, 33 SNGLS: { available: '0.00000000', onOrder: '0.00000000' }, 34 STRAT: { available: '0.00000000', onOrder: '0.00000000' }, 35 BQX: { available: '0.00000000', onOrder: '0.00000000' }, 36 FUN: { available: '0.00000000', onOrder: '0.00000000' }, 37 KNC: { available: '0.00000000', onOrder: '0.00000000' }, 38 CDT: { available: '0.00000000', onOrder: '0.00000000' }, 39 XVG: { available: '0.00000000', onOrder: '0.00000000' }, 40 IOTA: { available: '0.00000000', onOrder: '0.00000000' }, 41 SNM: { available: '0.76352833', onOrder: '0.00000000' }, 42 LINK: { available: '0.00000000', onOrder: '0.00000000' }, 43 CVC: { available: '0.00000000', onOrder: '0.00000000' }, 44 TNT: { available: '0.00000000', onOrder: '0.00000000' }, 45 REP: { available: '0.00000000', onOrder: '0.00000000' }, 46 CTR: { available: '0.00000000', onOrder: '0.00000000' }, 47 MDA: { available: '0.00000000', onOrder: '0.00000000' }, 48 MTL: { available: '0.00000000', onOrder: '0.00000000' }, 49 SALT: { available: '0.00000000', onOrder: '0.00000000' }, 50 NULS: { available: '0.00000000', onOrder: '0.00000000' } } 51//ETH balance: 1.14109900
1binance.bookTickers('BNBBTC', (error, ticker) => { 2 console.info("bookTickers", ticker); 3});
1{ 2 "symbol": "BNBBTC", 3 "bidPrice": "4.00000000", 4 "bidQty": "431.00000000", 5 "askPrice": "4.00000200", 6 "askQty": "9.00000000" 7} 8 9// from: https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#symbol-order-book-ticker
1binance.bookTickers((error, ticker) => { 2 console.info("bookTickers()", ticker); 3 console.info("Price of BNB: ", ticker.BNBBTC); 4});
1 { ETHBTC: 2 { bid: '0.06201000', 3 bids: '1.28200000', 4 ask: '0.06201300', 5 asks: '0.34200000' }, 6 LTCBTC: 7 { bid: '0.01042000', 8 bids: '41.45000000', 9 ask: '0.01048700', 10 asks: '16.81000000' }, 11 BNBBTC: 12 { bid: '0.00028754', 13 bids: '727.00000000', 14 ask: '0.00028755', 15 asks: '400.00000000' }, 16 NEOBTC: 17 { bid: '0.00601800', 18 bids: '16.82000000', 19 ask: '0.00603700', 20 asks: '73.43000000' }, 21 QTUMETH: 22 { bid: '0.04062900', 23 bids: '1.30000000', 24 ask: '0.04075300', 25 asks: '0.58000000' }, 26 EOSETH: 27 { bid: '0.00191400', 28 bids: '202.53000000', 29 ask: '0.00192500', 30 asks: '26.08000000' }, 31 SNTETH: 32 { bid: '0.00007610', 33 bids: '403.00000000', 34 ask: '0.00007638', 35 asks: '19850.00000000' }, 36 BNTETH: 37 { bid: '0.00736800', 38 bids: '7.82000000', 39 ask: '0.00745900', 40 asks: '177.32000000' }, 41 BCCBTC: 42 { bid: '0.06862000', 43 bids: '1.56100000', 44 ask: '0.06893600', 45 asks: '0.81100000' }, 46 GASBTC: 47 { bid: '0.00451700', 48 bids: '44.00000000', 49 ask: '0.00489700', 50 asks: '44.95000000' }, 51 BNBETH: 52 { bid: '0.00462592', 53 bids: '32.00000000', 54 ask: '0.00467982', 55 asks: '57.00000000' }, 56 BTMETH: 57 { bid: '0.00000000', 58 bids: '0.00000000', 59 ask: '0.00000000', 60 asks: '0.00000000' }, 61 HCCBTC: 62 { bid: '0.00000000', 63 bids: '0.00000000', 64 ask: '0.00000000', 65 asks: '0.00000000' }, 66 BTCUSDT: 67 { bid: '4786.01000000', 68 bids: '0.58627700', 69 ask: '4796.10000000', 70 asks: '0.28486400' }, 71 ETHUSDT: 72 { bid: '297.01000000', 73 bids: '7.17846000', 74 ask: '297.90000000', 75 asks: '0.30742000' }, 76 HSRBTC: 77 { bid: '0.00000000', 78 bids: '0.00000000', 79 ask: '0.00000000', 80 asks: '0.00000000' }, 81 OAXETH: 82 { bid: '0.00156200', 83 bids: '96.00000000', 84 ask: '0.00169900', 85 asks: '552.90000000' }, 86 DNTETH: 87 { bid: '0.00011782', 88 bids: '1273.00000000', 89 ask: '0.00012045', 90 asks: '238.00000000' }, 91 MCOETH: 92 { bid: '0.02651200', 93 bids: '0.94000000', 94 ask: '0.02681200', 95 asks: '8.59000000' }, 96 ICNETH: 97 { bid: '0.00484600', 98 bids: '448.76000000', 99 ask: '0.00490000', 100 asks: '0.01000000' }, 101 ELCBTC: 102 { bid: '0.00000000', 103 bids: '0.00000000', 104 ask: '0.00000000', 105 asks: '0.00000000' }, 106 MCOBTC: 107 { bid: '0.00164600', 108 bids: '1.00000000', 109 ask: '0.00164700', 110 asks: '12.11000000' }, 111 WTCBTC: 112 { bid: '0.00132101', 113 bids: '124.00000000', 114 ask: '0.00133200', 115 asks: '98.00000000' }, 116 WTCETH: 117 { bid: '0.02130000', 118 bids: '784.35000000', 119 ask: '0.02140800', 120 asks: '10.70000000' }, 121 LLTBTC: 122 { bid: '0.00000000', 123 bids: '0.00000000', 124 ask: '0.00000000', 125 asks: '0.00000000' }, 126 LRCBTC: 127 { bid: '0.00000000', 128 bids: '0.00000000', 129 ask: '0.00000000', 130 asks: '0.00000000' }, 131 LRCETH: 132 { bid: '0.00000000', 133 bids: '0.00000000', 134 ask: '0.00000000', 135 asks: '0.00000000' }, 136 QTUMBTC: 137 { bid: '0.00252800', 138 bids: '123.48000000', 139 ask: '0.00253200', 140 asks: '10.50000000' }, 141 YOYOBTC: 142 { bid: '0.00000000', 143 bids: '0.00000000', 144 ask: '0.00000000', 145 asks: '0.00000000' }, 146 OMGBTC: 147 { bid: '0.00164900', 148 bids: '25.94000000', 149 ask: '0.00166400', 150 asks: '0.90000000' }, 151 OMGETH: 152 { bid: '0.02660000', 153 bids: '9.86000000', 154 ask: '0.02698200', 155 asks: '43.21000000' }, 156 ZRXBTC: 157 { bid: '0.00003936', 158 bids: '117.00000000', 159 ask: '0.00003982', 160 asks: '8596.00000000' }, 161 ZRXETH: 162 { bid: '0.00062801', 163 bids: '239.00000000', 164 ask: '0.00063595', 165 asks: '2446.00000000' }, 166 STRATBTC: 167 { bid: '0.00070600', 168 bids: '43.43000000', 169 ask: '0.00070900', 170 asks: '15.00000000' }, 171 STRATETH: 172 { bid: '0.01092100', 173 bids: '9.00000000', 174 ask: '0.01162700', 175 asks: '47.90000000' }, 176 SNGLSBTC: 177 { bid: '0.00003162', 178 bids: '366.00000000', 179 ask: '0.00003183', 180 asks: '308.00000000' }, 181 SNGLSETH: 182 { bid: '0.00050064', 183 bids: '300.00000000', 184 ask: '0.00051543', 185 asks: '64.00000000' }, 186 BQXBTC: 187 { bid: '0.00013334', 188 bids: '13.00000000', 189 ask: '0.00013889', 190 asks: '1224.00000000' }, 191 BQXETH: 192 { bid: '0.00200740', 193 bids: '990.00000000', 194 ask: '0.00228890', 195 asks: '80.00000000' }, 196 KNCBTC: 197 { bid: '0.00029509', 198 bids: '300.00000000', 199 ask: '0.00029842', 200 asks: '4.00000000' }, 201 KNCETH: 202 { bid: '0.00481840', 203 bids: '411.00000000', 204 ask: '0.00484440', 205 asks: '10.00000000' }, 206 FUNBTC: 207 { bid: '0.00000461', 208 bids: '217.00000000', 209 ask: '0.00000465', 210 asks: '16668.00000000' }, 211 FUNETH: 212 { bid: '0.00007486', 213 bids: '2004.00000000', 214 ask: '0.00007617', 215 asks: '1419.00000000' }, 216 SNMBTC: 217 { bid: '0.00002462', 218 bids: '6922.00000000', 219 ask: '0.00002495', 220 asks: '404.00000000' }, 221 SNMETH: 222 { bid: '0.00040181', 223 bids: '373.00000000', 224 ask: '0.00043404', 225 asks: '9281.00000000' }, 226 NEOETH: 227 { bid: '0.09610400', 228 bids: '8.02000000', 229 ask: '0.09891100', 230 asks: '5.00000000' }, 231 IOTABTC: 232 { bid: '0.00009674', 233 bids: '206.00000000', 234 ask: '0.00009721', 235 asks: '269.00000000' }, 236 IOTAETH: 237 { bid: '0.00155061', 238 bids: '1231.00000000', 239 ask: '0.00158100', 240 asks: '22.00000000' }, 241 LINKBTC: 242 { bid: '0.00007670', 243 bids: '2278.00000000', 244 ask: '0.00007697', 245 asks: '8000.00000000' }, 246 LINKETH: 247 { bid: '0.00123000', 248 bids: '3492.00000000', 249 ask: '0.00123999', 250 asks: '4000.00000000' }, 251 XVGBTC: 252 { bid: '0.00000111', 253 bids: '47758.00000000', 254 ask: '0.00000113', 255 asks: '215443.00000000' }, 256 XVGETH: 257 { bid: '0.00001801', 258 bids: '8329.00000000', 259 ask: '0.00001842', 260 asks: '85146.00000000' }, 261 CTRBTC: 262 { bid: '0.00019801', 263 bids: '650.00000000', 264 ask: '0.00021103', 265 asks: '49.00000000' }, 266 CTRETH: 267 { bid: '0.00320200', 268 bids: '538.00000000', 269 ask: '0.00351990', 270 asks: '2081.00000000' }, 271 SALTBTC: 272 { bid: '0.00063900', 273 bids: '57.13000000', 274 ask: '0.00064000', 275 asks: '96.48000000' }, 276 SALTETH: 277 { bid: '0.01030200', 278 bids: '728.27000000', 279 ask: '0.01038900', 280 asks: '0.04000000' }, 281 MDABTC: 282 { bid: '0.00039031', 283 bids: '282.00000000', 284 ask: '0.00039994', 285 asks: '540.00000000' }, 286 MDAETH: 287 { bid: '0.00635500', 288 bids: '432.00000000', 289 ask: '0.00641990', 290 asks: '185.00000000' }, 291 MTLBTC: 292 { bid: '0.00145500', 293 bids: '45.00000000', 294 ask: '0.00145600', 295 asks: '42.12000000' }, 296 MTLETH: 297 { bid: '0.02300100', 298 bids: '96.10000000', 299 ask: '0.02477400', 300 asks: '131.90000000' }, 301 SUBBTC: 302 { bid: '0.00003250', 303 bids: '4474.00000000', 304 ask: '0.00003380', 305 asks: '3878.00000000' }, 306 SUBETH: 307 { bid: '0.00053000', 308 bids: '740.00000000', 309 ask: '0.00053501', 310 asks: '580.00000000' } } 311/* Price of BNB: { bid: '0.00028754', 312 bids: '727.00000000', 313 ask: '0.00028755', 314 asks: '400.00000000' } */
1binance.bookTickers((error, ticker) => { 2 console.info("bookTickers", ticker); 3});
1{ ETHBTC: 2 { bid: '0.06187700', 3 bids: '0.64000000', 4 ask: '0.06188300', 5 asks: '6.79700000' }, 6 LTCBTC: 7 { bid: '0.01036000', 8 bids: '14.96000000', 9 ask: '0.01037000', 10 asks: '0.60000000' }, 11 BNBBTC: 12 { bid: '0.00028226', 13 bids: '802.00000000', 14 ask: '0.00028268', 15 asks: '584.00000000' }, 16 NEOBTC: 17 { bid: '0.00595600', 18 bids: '33.00000000', 19 ask: '0.00595900', 20 asks: '37.00000000' }, 21 QTUMETH: 22 { bid: '0.03958000', 23 bids: '1.42000000', 24 ask: '0.04024300', 25 asks: '7.46000000' }, 26 EOSETH: 27 { bid: '0.00192600', 28 bids: '29.31000000', 29 ask: '0.00193500', 30 asks: '418.91000000' }, 31 SNTETH: 32 { bid: '0.00007607', 33 bids: '8864.00000000', 34 ask: '0.00007682', 35 asks: '1311.00000000' }, 36 BNTETH: 37 { bid: '0.00740200', 38 bids: '1.36000000', 39 ask: '0.00746800', 40 asks: '419.86000000' }, 41 BCCBTC: 42 { bid: '0.06786500', 43 bids: '0.18600000', 44 ask: '0.06835400', 45 asks: '0.72600000' }, 46 GASBTC: 47 { bid: '0.00435500', 48 bids: '332.73000000', 49 ask: '0.00435600', 50 asks: '18.31000000' }, 51 BNBETH: 52 { bid: '0.00456443', 53 bids: '4.00000000', 54 ask: '0.00461795', 55 asks: '192.00000000' }, 56 BTMETH: 57 { bid: '0.00000000', 58 bids: '0.00000000', 59 ask: '0.00000000', 60 asks: '0.00000000' }, 61 HCCBTC: 62 { bid: '0.00000000', 63 bids: '0.00000000', 64 ask: '0.00000000', 65 asks: '0.00000000' }, 66 BTCUSDT: 67 { bid: '4801.05000000', 68 bids: '0.82289400', 69 ask: '4812.00000000', 70 asks: '1.04753200' }, 71 ETHUSDT: 72 { bid: '296.32000000', 73 bids: '3.24294000', 74 ask: '297.81000000', 75 asks: '17.69901000' }, 76 HSRBTC: 77 { bid: '0.00000000', 78 bids: '0.00000000', 79 ask: '0.00000000', 80 asks: '0.00000000' }, 81 OAXETH: 82 { bid: '0.00154500', 83 bids: '422.64000000', 84 ask: '0.00169200', 85 asks: '159.94000000' }, 86 DNTETH: 87 { bid: '0.00012059', 88 bids: '434.00000000', 89 ask: '0.00012100', 90 asks: '8311.00000000' }, 91 MCOETH: 92 { bid: '0.02566000', 93 bids: '5.85000000', 94 ask: '0.02651200', 95 asks: '4.37000000' }, 96 ICNETH: 97 { bid: '0.00489000', 98 bids: '232.97000000', 99 ask: '0.00500000', 100 asks: '0.01000000' }, 101 ELCBTC: 102 { bid: '0.00000000', 103 bids: '0.00000000', 104 ask: '0.00000000', 105 asks: '0.00000000' }, 106 MCOBTC: 107 { bid: '0.00162700', 108 bids: '2.87000000', 109 ask: '0.00163800', 110 asks: '0.70000000' }, 111 WTCBTC: 112 { bid: '0.00129604', 113 bids: '600.00000000', 114 ask: '0.00131600', 115 asks: '1.00000000' }, 116 WTCETH: 117 { bid: '0.02080000', 118 bids: '30.00000000', 119 ask: '0.02097600', 120 asks: '24.00000000' }, 121 LLTBTC: 122 { bid: '0.00000000', 123 bids: '0.00000000', 124 ask: '0.00000000', 125 asks: '0.00000000' }, 126 LRCBTC: 127 { bid: '0.00000000', 128 bids: '0.00000000', 129 ask: '0.00000000', 130 asks: '0.00000000' }, 131 LRCETH: 132 { bid: '0.00000000', 133 bids: '0.00000000', 134 ask: '0.00000000', 135 asks: '0.00000000' }, 136 QTUMBTC: 137 { bid: '0.00245100', 138 bids: '43.11000000', 139 ask: '0.00248500', 140 asks: '74.96000000' }, 141 YOYOBTC: 142 { bid: '0.00000000', 143 bids: '0.00000000', 144 ask: '0.00000000', 145 asks: '0.00000000' }, 146 OMGBTC: 147 { bid: '0.00160700', 148 bids: '300.00000000', 149 ask: '0.00161300', 150 asks: '36.05000000' }, 151 OMGETH: 152 { bid: '0.02597100', 153 bids: '4.92000000', 154 ask: '0.02633200', 155 asks: '19.00000000' }, 156 ZRXBTC: 157 { bid: '0.00003852', 158 bids: '9.00000000', 159 ask: '0.00003912', 160 asks: '103.00000000' }, 161 ZRXETH: 162 { bid: '0.00062997', 163 bids: '645.00000000', 164 ask: '0.00062998', 165 asks: '5376.00000000' }, 166 STRATBTC: 167 { bid: '0.00069200', 168 bids: '50.50000000', 169 ask: '0.00070000', 170 asks: '6.54000000' }, 171 STRATETH: 172 { bid: '0.01080400', 173 bids: '5.00000000', 174 ask: '0.01200000', 175 asks: '5.88000000' }, 176 SNGLSBTC: 177 { bid: '0.00003121', 178 bids: '726.00000000', 179 ask: '0.00003161', 180 asks: '153.00000000' }, 181 SNGLSETH: 182 { bid: '0.00046686', 183 bids: '4782.00000000', 184 ask: '0.00051906', 185 asks: '32.00000000' }, 186 BQXBTC: 187 { bid: '0.00011512', 188 bids: '87.00000000', 189 ask: '0.00011840', 190 asks: '133.00000000' }, 191 BQXETH: 192 { bid: '0.00183080', 193 bids: '1051.00000000', 194 ask: '0.00195000', 195 asks: '626.00000000' }, 196 KNCBTC: 197 { bid: '0.00027859', 198 bids: '7.00000000', 199 ask: '0.00028462', 200 asks: '35.00000000' }, 201 KNCETH: 202 { bid: '0.00452830', 203 bids: '13.00000000', 204 ask: '0.00454970', 205 asks: '35.00000000' }, 206 FUNBTC: 207 { bid: '0.00000464', 208 bids: '753.00000000', 209 ask: '0.00000465', 210 asks: '13924.00000000' }, 211 FUNETH: 212 { bid: '0.00007126', 213 bids: '44131.00000000', 214 ask: '0.00007617', 215 asks: '1419.00000000' }, 216 SNMBTC: 217 { bid: '0.00002489', 218 bids: '564.00000000', 219 ask: '0.00002559', 220 asks: '2553.00000000' }, 221 SNMETH: 222 { bid: '0.00040060', 223 bids: '374.00000000', 224 ask: '0.00041494', 225 asks: '7624.00000000' }, 226 NEOETH: 227 { bid: '0.09604700', 228 bids: '22.05000000', 229 ask: '0.09800000', 230 asks: '0.31000000' }, 231 IOTABTC: 232 { bid: '0.00009515', 233 bids: '3.00000000', 234 ask: '0.00009529', 235 asks: '147.00000000' }, 236 IOTAETH: 237 { bid: '0.00150002', 238 bids: '4311.00000000', 239 ask: '0.00155216', 240 asks: '7.00000000' }, 241 LINKBTC: 242 { bid: '0.00007601', 243 bids: '4337.00000000', 244 ask: '0.00007630', 245 asks: '525.00000000' }, 246 LINKETH: 247 { bid: '0.00121903', 248 bids: '3784.00000000', 249 ask: '0.00122965', 250 asks: '200.00000000' }, 251 XVGBTC: 252 { bid: '0.00000113', 253 bids: '470101.00000000', 254 ask: '0.00000114', 255 asks: '147728.00000000' }, 256 XVGETH: 257 { bid: '0.00001813', 258 bids: '8274.00000000', 259 ask: '0.00001843', 260 asks: '8320.00000000' }, 261 CTRBTC: 262 { bid: '0.00020202', 263 bids: '625.00000000', 264 ask: '0.00020649', 265 asks: '1143.00000000' }, 266 CTRETH: 267 { bid: '0.00330510', 268 bids: '387.00000000', 269 ask: '0.00339330', 270 asks: '436.00000000' }, 271 SALTBTC: 272 { bid: '0.00063500', 273 bids: '76.00000000', 274 ask: '0.00064300', 275 asks: '437.54000000' }, 276 SALTETH: 277 { bid: '0.01014200', 278 bids: '202.79000000', 279 ask: '0.01122600', 280 asks: '1.36000000' }, 281 MDABTC: 282 { bid: '0.00038061', 283 bids: '8.00000000', 284 ask: '0.00041300', 285 asks: '1772.00000000' }, 286 MDAETH: 287 { bid: '0.00655000', 288 bids: '547.00000000', 289 ask: '0.00660830', 290 asks: '8814.00000000' }, 291 MTLBTC: 292 { bid: '0.00140600', 293 bids: '0.11000000', 294 ask: '0.00143800', 295 asks: '12.00000000' }, 296 MTLETH: 297 { bid: '0.02300000', 298 bids: '1166.86000000', 299 ask: '0.02489500', 300 asks: '13.98000000' }, 301 SUBBTC: 302 { bid: '0.00003580', 303 bids: '7617.00000000', 304 ask: '0.00003619', 305 asks: '1052.00000000' }, 306 SUBETH: 307 { bid: '0.00056500', 308 bids: '3649.00000000', 309 ask: '0.00059988', 310 asks: '3649.00000000' } }
1binance.depth("BNBBTC", (error, depth, symbol) => { 2 console.info(symbol+" market depth", depth); 3});
1market depth for BNBBTC 2{ bids: 3 { '0.00022997': '49.00000000', 4 '0.00022867': '11.00000000', 5 '0.00022865': '1149.00000000', 6 '0.00022810': '20.00000000', 7 '0.00022800': '1000.00000000', 8 '0.00022777': '1350.00000000', 9 '0.00022774': '96.00000000', 10 '0.00022765': '5.00000000', 11 '0.00022741': '12.00000000', 12 '0.00022705': '1372.00000000', 13 '0.00022700': '402.00000000', 14 '0.00022514': '756.00000000', 15 '0.00022513': '761.00000000', 16 '0.00022502': '2244.00000000', 17 '0.00022501': '2190.00000000', 18 '0.00022500': '5069.00000000', 19 '0.00022419': '1871.00000000', 20 '0.00022418': '1667.00000000', 21 '0.00022167': '1889.00000000', 22 '0.00022162': '1014.00000000', 23 '0.00022112': '13563.00000000', 24 '0.00022078': '4056.00000000', 25 '0.00022000': '8060.00000000', 26 '0.00021963': '13563.00000000', 27 '0.00021850': '52.00000000', 28 '0.00021800': '1282.00000000', 29 '0.00021710': '102.00000000', 30 '0.00021680': '100.00000000', 31 '0.00021652': '29.00000000', 32 '0.00021641': '154.00000000', 33 '0.00021500': '1491.00000000', 34 '0.00021471': '977.00000000', 35 '0.00021405': '478.00000000', 36 '0.00021400': '11.00000000', 37 '0.00021314': '686.00000000', 38 '0.00021219': '1089.00000000', 39 '0.00021200': '767.00000000', 40 '0.00021100': '5000.00000000', 41 '0.00021011': '50.00000000', 42 '0.00021000': '3468.00000000', 43 '0.00020900': '169.00000000', 44 '0.00020843': '90.00000000', 45 '0.00020811': '200.00000000', 46 '0.00020702': '50.00000000', 47 '0.00020691': '283.00000000', 48 '0.00020600': '3703.00000000', 49 '0.00020500': '107.00000000', 50 '0.00020450': '6363.00000000', 51 '0.00020250': '301.00000000', 52 '0.00020222': '200.00000000', 53 '0.00020200': '123.00000000', 54 '0.00020137': '50.00000000', 55 '0.00020122': '727.00000000', 56 '0.00020100': '6400.00000000', 57 '0.00020088': '10.00000000', 58 '0.00020020': '793.00000000', 59 '0.00020010': '500.00000000', 60 '0.00020009': '44.00000000', 61 '0.00020001': '20020.00000000', 62 '0.00020000': '45269.00000000', 63 '0.00019990': '270.00000000', 64 '0.00019880': '2117.00000000', 65 '0.00019800': '1200.00000000', 66 '0.00019783': '50.00000000', 67 '0.00019702': '300.00000000', 68 '0.00019686': '10.00000000', 69 '0.00019600': '1025.00000000', 70 '0.00019595': '139.00000000', 71 '0.00019501': '3227.00000000', 72 '0.00019500': '3832.00000000', 73 '0.00019488': '82.00000000', 74 '0.00019400': '1853.00000000', 75 '0.00019293': '10.00000000', 76 '0.00019289': '30.00000000', 77 '0.00019234': '1999.00000000', 78 '0.00019200': '4765.00000000', 79 '0.00019190': '6.00000000', 80 '0.00019100': '4353.00000000', 81 '0.00019073': '12.00000000', 82 '0.00019058': '28.00000000', 83 '0.00019050': '718.00000000', 84 '0.00019001': '20.00000000', 85 '0.00019000': '39478.00000000', 86 '0.00018907': '10.00000000', 87 '0.00018888': '10045.00000000', 88 '0.00018880': '15.00000000', 89 '0.00018800': '3528.00000000', 90 '0.00018700': '328.00000000', 91 '0.00018600': '1000.00000000', 92 '0.00018598': '2187.00000000', 93 '0.00018538': '1383.00000000', 94 '0.00018529': '10.00000000', 95 '0.00018500': '1512.00000000', 96 '0.00018253': '30.00000000', 97 '0.00018200': '3000.00000000', 98 '0.00018158': '10.00000000', 99 '0.00018106': '250.00000000', 100 '0.00018100': '4577.00000000', 101 '0.00018011': '500.00000000', 102 '0.00018000': '29832.00000000' }, 103 asks: 104 { '0.00022999': '32.00000000', 105 '0.00023086': '583.00000000', 106 '0.00023095': '1154.00000000', 107 '0.00023119': '781.00000000', 108 '0.00023120': '3401.00000000', 109 '0.00023180': '4889.00000000', 110 '0.00023185': '83.00000000', 111 '0.00023211': '750.00000000', 112 '0.00023339': '9273.00000000', 113 '0.00023340': '474.00000000', 114 '0.00023440': '500.00000000', 115 '0.00023450': '1433.00000000', 116 '0.00023500': '1480.00000000', 117 '0.00023573': '87.00000000', 118 '0.00023580': '518.00000000', 119 '0.00023999': '863.00000000', 120 '0.00024000': '275.00000000', 121 '0.00024100': '60.00000000', 122 '0.00024119': '3736.00000000', 123 '0.00024180': '989.00000000', 124 '0.00024350': '1285.00000000', 125 '0.00024399': '500.00000000', 126 '0.00024400': '2964.00000000', 127 '0.00024419': '500.00000000', 128 '0.00024500': '4499.00000000', 129 '0.00024580': '542.00000000', 130 '0.00024584': '6.00000000', 131 '0.00024700': '250.00000000', 132 '0.00024789': '2938.00000000', 133 '0.00024790': '5535.00000000', 134 '0.00024800': '499.00000000', 135 '0.00024892': '2000.00000000', 136 '0.00024920': '652.00000000', 137 '0.00024972': '9242.00000000', 138 '0.00024999': '1262.00000000', 139 '0.00025000': '3739.00000000', 140 '0.00025078': '250.00000000', 141 '0.00025348': '1000.00000000', 142 '0.00025499': '220.00000000', 143 '0.00025500': '6029.00000000', 144 '0.00025518': '10.00000000', 145 '0.00025698': '17.00000000', 146 '0.00025700': '250.00000000', 147 '0.00025800': '265.00000000', 148 '0.00025925': '20.00000000', 149 '0.00025984': '1048.00000000', 150 '0.00025985': '1048.00000000', 151 '0.00025987': '1165.00000000', 152 '0.00025990': '465.00000000', 153 '0.00025994': '571.00000000', 154 '0.00025995': '390.00000000', 155 '0.00026000': '5033.00000000', 156 '0.00026028': '10.00000000', 157 '0.00026280': '40.00000000', 158 '0.00026300': '13.00000000', 159 '0.00026348': '50.00000000', 160 '0.00026500': '38.00000000', 161 '0.00026548': '10.00000000', 162 '0.00026594': '51.00000000', 163 '0.00026666': '15000.00000000', 164 '0.00026700': '500.00000000', 165 '0.00026800': '27.00000000', 166 '0.00026900': '1000.00000000', 167 '0.00026929': '50.00000000', 168 '0.00026990': '270.00000000', 169 '0.00027000': '8750.00000000', 170 '0.00027199': '50.00000000', 171 '0.00027300': '351.00000000', 172 '0.00027429': '50.00000000', 173 '0.00027480': '270.00000000', 174 '0.00027500': '38.00000000', 175 '0.00027690': '242.00000000', 176 '0.00027700': '500.00000000', 177 '0.00027789': '1317.00000000', 178 '0.00027906': '1457.00000000', 179 '0.00027912': '98.00000000', 180 '0.00027949': '50.00000000', 181 '0.00027950': '2000.00000000', 182 '0.00027977': '96.00000000', 183 '0.00027980': '1031.00000000', 184 '0.00028000': '782.00000000', 185 '0.00028300': '25.00000000', 186 '0.00028500': '48.00000000', 187 '0.00028590': '364.00000000', 188 '0.00028680': '50.00000000', 189 '0.00028699': '50.00000000', 190 '0.00028700': '1600.00000000', 191 '0.00028800': '3509.00000000', 192 '0.00028890': '175.00000000', 193 '0.00028900': '11474.00000000', 194 '0.00028999': '10000.00000000', 195 '0.00029000': '623.00000000', 196 '0.00029100': '303.00000000', 197 '0.00029141': '456.00000000', 198 '0.00029200': '9999.00000000', 199 '0.00029234': '104.00000000', 200 '0.00029300': '200.00000000', 201 '0.00029358': '325.00000000', 202 '0.00029399': '153.00000000', 203 '0.00029428': '100.00000000' } }
1let quantity = 1, price = 0.069; 2binance.buy("ETHBTC", quantity, price); 3binance.sell("ETHBTC", quantity, price);
1// These orders will be executed at current market price. 2let quantity = 1; 3binance.marketBuy("BNBBTC", quantity); 4binance.marketSell("ETHBTC", quantity);
1let quantity = 5, price = 0.00402030; 2binance.buy("BNBETH", quantity, price, {type:'LIMIT'}, (error, response) => { 3 console.info("Limit Buy response", response); 4 console.info("order id: " + response.orderId); 5});
Limit Buy response {
symbol: 'BNBETH',
orderId: 4480717,
clientOrderId: 'te38xGILZUXrPZHnTQPH6h',
transactTime: 1509049732437,
price: '0.00402030',
origQty: '5.00000000',
executedQty: '5.00000000',
status: 'FILLED',
timeInForce: 'GTC',
type: 'LIMIT',
side: 'BUY' }
//order id: 4480717
1let quantity = 1; 2binance.marketBuy("BNBBTC", quantity, (error, response) => { 3 console.info("Market Buy response", response); 4 console.info("order id: " + response.orderId); 5 // Now you can limit sell with a stop loss, etc. 6});
Market Buy response {
symbol: 'BNBETH',
orderId: 4480553,
clientOrderId: 'rCGiCG08PGy7AwvbrG5d83',
transactTime: 1509049376261,
price: '0.00000000',
origQty: '1.00000000',
executedQty: '1.00000000',
status: 'FILLED',
timeInForce: 'GTC',
type: 'MARKET',
side: 'BUY' }
//order id: 4480553
1// When the stop is reached, a stop order becomes a market order 2// Note: You must also pass one of these type parameters: 3// STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT 4let type = "STOP_LOSS"; 5let quantity = 1; 6let price = 0.069; 7let stopPrice = 0.068; 8binance.sell("ETHBTC", quantity, price, {stopPrice: stopPrice, type: type});
1// Iceberg orders are intended to conceal the order quantity. 2let quantity = 1; 3let price = 0.069; 4binance.sell("ETHBTC", quantity, price, {icebergQty: 10});
1binance.cancel("ETHBTC", orderid, (error, response, symbol) => { 2 console.info(symbol+" cancel response:", response); 3});
1console.info( await binance.cancelAll("XMRBTC") );
1binance.openOrders("ETHBTC", (error, openOrders, symbol) => { 2 console.info("openOrders("+symbol+")", openOrders); 3});
1binance.openOrders(false, (error, openOrders) => { 2 console.info("openOrders()", openOrders); 3});
1let orderid = "7610385"; 2binance.orderStatus("ETHBTC", orderid, (error, orderStatus, symbol) => { 3 console.info(symbol+" order status:", orderStatus); 4});
1binance.trades("SNMBTC", (error, trades, symbol) => { 2 console.info(symbol+" trade history", trades); 3});
1[ { id: 9572, 2 orderId: 47884, 3 price: '0.00003701', 4 qty: '1467.00000000', 5 commission: '0.06774660', 6 commissionAsset: 'BNB', 7 time: 1507062500456, 8 isBuyer: true, 9 isMaker: true, 10 isBestMatch: true }, 11 { id: 9575, 12 orderId: 47884, 13 price: '0.00003701', 14 qty: '735.00000000', 15 commission: '0.03394257', 16 commissionAsset: 'BNB', 17 time: 1507062502528, 18 isBuyer: true, 19 isMaker: true, 20 isBestMatch: true } } ]
1binance.allOrders("ETHBTC", (error, orders, symbol) => { 2 console.info(symbol+" orders:", orders); 3});
1binance.dustLog((error, dustlog) => { 2 console.info(dustlog); 3})
1binance.prevDay(false, (error, prevDay) => { 2 // console.info(prevDay); // view all data 3 for ( let obj of prevDay ) { 4 let symbol = obj.symbol; 5 console.info(symbol+" volume:"+obj.volume+" change: "+obj.priceChangePercent+"%"); 6 } 7});
1binance.prevDay("BNBBTC", (error, prevDay, symbol) => { 2 console.info(symbol+" previous day:", prevDay); 3 console.info("BNB change since yesterday: "+prevDay.priceChangePercent+"%") 4});
You can use the optional API parameters for getting historical candlesticks, these are useful if you want to import data from earlier back in time. Optional parameters: limit (max/default 500), startTime, endTime.
1// Intervals: 1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w,1M 2binance.candlesticks("BNBBTC", "5m", (error, ticks, symbol) => { 3 console.info("candlesticks()", ticks); 4 let last_tick = ticks[ticks.length - 1]; 5 let [time, open, high, low, close, volume, closeTime, assetVolume, trades, buyBaseVolume, buyAssetVolume, ignored] = last_tick; 6 console.info(symbol+" last close: "+close); 7}, {limit: 500, endTime: 1514764800000});
This function pulls existing chart data before connecting to the WebSocket, and provides you realtime synchronized chart information including the most recent 500 candles.
1binance.websockets.chart("BNBBTC", "1m", (symbol, interval, chart) => { 2 let tick = binance.last(chart); 3 const last = chart[tick].close; 4 console.info(chart); 5 // Optionally convert 'chart' object to array: 6 // let ohlc = binance.ohlc(chart); 7 // console.info(symbol, ohlc); 8 console.info(symbol+" last price: "+last) 9});
{
'1517557800000':
{ open: '0.00100090',
high: '0.00100650',
low: '0.00099810',
close: '0.00100370',
volume: '1161.52000000' },
'1517557860000':
{ open: '0.00100360',
high: '0.00101010',
low: '0.00100000',
close: '0.00100310',
volume: '1977.68000000' },
'1517557920000':
{ open: '0.00100100',
high: '0.00101130',
low: '0.00100080',
close: '0.00100670',
volume: '2002.00000000' },
'1517557980000':
{ open: '0.00100660',
high: '0.00101400',
low: '0.00100200',
close: '0.00100640',
volume: '3896.40000000' },
'1517558040000':
{ open: '0.00100630',
high: '0.00101390',
low: '0.00100350',
close: '0.00100470',
volume: '1675.48000000' },
'1517558100000':
{ open: '0.00100860',
high: '0.00101450',
low: '0.00100100',
close: '0.00100270',
volume: '1918.46000000' },
'1517558160000':
{ open: '0.00100460',
high: '0.00101480',
low: '0.00100310',
close: '0.00100670',
volume: '2464.12000000' },
'1517558220000':
{ open: '0.00100510',
high: '0.00100660',
low: '0.00100110',
close: '0.00100250',
volume: '1484.59000000' } }
// (..many more entries not shown)
///BNBBTC last price: 0.00100250
1// Periods: 1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w,1M 2binance.websockets.candlesticks(['BNBBTC'], "1m", (candlesticks) => { 3 let { e:eventType, E:eventTime, s:symbol, k:ticks } = candlesticks; 4 let { o:open, h:high, l:low, c:close, v:volume, n:trades, i:interval, x:isFinal, q:quoteVolume, V:buyVolume, Q:quoteBuyVolume } = ticks; 5 console.info(symbol+" "+interval+" candlestick update"); 6 console.info("open: "+open); 7 console.info("high: "+high); 8 console.info("low: "+low); 9 console.info("close: "+close); 10 console.info("volume: "+volume); 11 console.info("isFinal: "+isFinal); 12});
1binance.websockets.trades(['BNBBTC', 'ETHBTC'], (trades) => { 2 let {e:eventType, E:eventTime, s:symbol, p:price, q:quantity, m:maker, a:tradeId} = trades; 3 console.info(symbol+" trade update. price: "+price+", quantity: "+quantity+", maker: "+maker); 4});
1binance.websockets.miniTicker(markets => {
2 console.info(markets);
3});
ICXBNB:
{ close: '0.34803000',
open: '0.34249000',
high: '0.35000000',
low: '0.31001000',
volume: '134681.88000000',
quoteVolume: '44351.78363150',
eventTime: 1520501508957 },
ELFETH:
{ close: '0.00120820',
open: '0.00132816',
high: '0.00132926',
low: '0.00115888',
volume: '852919.00000000',
quoteVolume: '1045.37831133',
eventTime: 1520501508735 },
PIVXBTC:
{ close: '0.00049510',
open: '0.00051000',
high: '0.00056290',
low: '0.00049200',
volume: '215530.27000000',
quoteVolume: '111.50245426',
eventTime: 1520501508367 }
1// For all symbols: 2binance.websockets.prevDay(false, (error, response) => { 3 console.info(response); 4}); 5 6// For a specific symbol: 7binance.websockets.prevDay('BNBBTC', (error, response) => { 8 console.info(response); 9});
{ eventType: '24hrTicker',
eventTime: 1512629577435,
symbol: 'BNBBTC',
priceChange: '-0.00002671',
percentChange: '-12.844',
averagePrice: '0.00019282',
prevClose: '0.00020796',
close: '0.00018125',
closeQty: '55.00000000',
bestBid: '0.00018038',
bestBidQty: '580.00000000',
bestAsk: '0.00018125',
bestAskQty: '144.00000000',
open: '0.00020796',
high: '0.00021300',
low: '0.00017555',
volume: '3731915.00000000',
quoteVolume: '719.59011818',
openTime: 1512543177433,
closeTime: 1512629577433,
firstTradeId: 2248079,
lastTradeId: 2284725,
numTrades: 36647 }
1binance.websockets.depth(['BNBBTC'], (depth) => { 2 let {e:eventType, E:eventTime, s:symbol, u:updateId, b:bidDepth, a:askDepth} = depth; 3 console.info(symbol+" market depth update"); 4 console.info(bidDepth, askDepth); 5});
1binance.websockets.depthCache(['BNBBTC'], (symbol, depth) => { 2 let bids = binance.sortBids(depth.bids); 3 let asks = binance.sortAsks(depth.asks); 4 console.info(symbol+" depth cache update"); 5 console.info("bids", bids); 6 console.info("asks", asks); 7 console.info("best bid: "+binance.first(bids)); 8 console.info("best ask: "+binance.first(asks)); 9 console.info("last updated: " + new Date(depth.eventTime)); 10});
1BNBBTC depth cache update 2asks { '0.00025400': 0.531114, 3 '0.00025440': 0.2602512, 4 '0.00025469': 0.01400795, 5 '0.00025500': 0.0051, 6 '0.00025555': 0.0245328, 7 '0.00025629': 0.05100171, 8 '0.00025630': 0.0146091, 9 '0.00025642': 0.02230854, 10 '0.00025825': 0.00180775, 11 '0.00025896': 0.21856224, 12 '0.00025927': 0.025927 } 13bids { '0.00025203': 0.201624, 14 '0.00025202': 0.04838784, 15 '0.00025200': 0.13482, 16 '0.00025195': 0.01385725, 17 '0.00025187': 0.25539618, 18 '0.00025138': 0.012569, 19 '0.00025136': 0.04247984, 20 '0.00025135': 0.0085459, 21 '0.00025100': 0.02259, 22 '0.00025072': 0.012536, 23 '0.00025071': 0.00401136 } 24//best ask: 0.00025400 25//best bid: 0.00025203 26//last updated: Thu Apr 18 2019 00:52:49 GMT-0400 (Eastern Daylight Time)
1binance.websockets.bookTickers( console.log );
1binance.websockets.bookTickers( 'BTCUSDT', console.log );
1binance.depositAddress("XMR", (error, response) => { 2 console.info(response); 3});
1binance.depositHistory((error, response) => { 2 console.info(response); 3});
1binance.depositHistory((error, response) => { 2 console.info(response); 3}, "VEN");
1binance.withdrawHistory((error, response) => { 2 console.info(response); 3});
1binance.withdrawHistory((error, response) => { 2 console.info(response); 3}, "BTC");
1// Required for coins like XMR, XRP, etc. 2let address = "44tLjmXrQNrWJ5NBsEj2R77ZBEgDa3fEe9GLpSf2FRmhexPvfYDUAB7EXX1Hdb3aMQ9FLqdJ56yaAhiXoRsceGJCRS3Jxkn"; 3let addressTag = "0e5e38a01058dbf64e53a4333a5acf98e0d5feb8e523d32e3186c664a9c762c1"; 4let amount = 0.1; 5binance.withdraw("XMR", address, amount, addressTag);
1binance.withdraw("BTC", "1C5gqLRs96Xq4V2ZZAR1347yUCpHie7sa", 0.2);
Example Spot account transfer to USDⓈ-M Futures account , use ENUM -> "MAIN_UMFUTURE"
1console.info( await binance.universalTransfer("MAIN_UMFUTURE","USDT",10) );
for more account transfers (ENUMs) see docs
1binance.mgTransferMainToMargin(asset, amount, (error, response) => { 2 if ( error ) return console.warn(error); 3 // Success! Transaction ID: response.tranId 4}); 5
1binance.mgTransferMarginToMain(asset, amount, (error, response) => { 2 if ( error ) return console.warn(error); 3 // Success! Transaction ID: response.tranId 4});
1binance.maxTransferable(asset, (error, response) => { 2 if ( error ) return console.warn(error); 3 console.info(`Maximum transfer-out amount: ${response.amount}`); 4});
1binance.maxBorrowable(asset, (error, response) => { 2 if ( error ) return console.warn(error); 3 console.info(`Maximum borrow amount: ${response.amount}`); 4});
1binance.mgBorrow(asset, amount, (error, response) => { 2 if ( error ) return console.warn(error); 3 // Success! Transaction ID: response.tranId 4});
1binance.mgRepay(asset, amount, (error, response) => { 2 if ( error ) return console.warn(error); 3 // Success! Transaction ID: response.tranId 4});
Instead of binance.buy()
use binance.mgBuy()
and instead of binance.sell()
use binance.mgSell()
.
For market orders use binance.mgMarketBuy()
and binance.mgMarketSell()
.
For order operations, use binance.mgCancel()
, binance.mgCancelOrders()
, binance.mgAllOrders()
, binance.openOrders()
, binance.mgOrderStatus()
.
Usage and callbacks are the same as the 'regular account' counterparts.
Use binance.mgTrades()
instead of binance.trades()
.
1binance.mgTrades("ETHUSDT", (error, trades, symbol) => { 2 console.info(symbol+" trade history", trades); 3});
1[ { symbol: 'ETHUSDT', 2 id: 9572, 3 orderId: 47884, 4 price: '2063.07', 5 qty: '1.44877', 6 commission: '2.98891392', 7 commissionAsset: 'USDT', 8 time: 1617900638521, 9 isBuyer: false, 10 isMaker: false, 11 isBestMatch: true, 12 isIsolated: true }]
1binance.mgAccount((error, response) => { 2 if ( error ) return console.warn(error); 3 console.info("Account details response:", response) 4})
1 { 2 borrowEnabled: true, 3 marginLevel: '999.00000000', 4 totalAssetOfBtc: '0.00000003', 5 totalLiabilityOfBtc: '0.00000000', 6 totalNetAssetOfBtc: '0.00000003', 7 tradeEnabled: true, 8 transferEnabled: true, 9 userAssets: [ 10 { 11 asset: 'MATIC', 12 borrowed: '0.00000000', 13 free: '0.00000000', 14 interest: '0.00000000', 15 locked: '0.00000000', 16 netAsset: '0.00000000' 17 } 18 ] 19 }
1let lendingData = await binance.lending();
1 lendingData { 2 positionAmountVos: [ 3 { 4 amount: '952983.20208997', 5 amountInBTC: '129.54853649', 6 amountInUSDT: '952983.20208997', 7 asset: 'USDT' 8 } 9 ], 10 totalAmountInBTC: '129.54853649', 11 totalAmountInUSDT: '952983.20208997', 12 totalFixedAmountInBTC: '13.59400000', 13 totalFixedAmountInUSDT: '100000.00000000', 14 totalFlexibleInBTC: '115.95453649', 15 totalFlexibleInUSDT: '852983.20208997' 16 } 17 { 18 positionAmountVos: [], 19 totalAmountInBTC: '0.00000000', 20 totalAmountInUSDT: '0.00000000', 21 totalFixedAmountInBTC: '0.00000000', 22 totalFixedAmountInUSDT: '0.00000000', 23 totalFlexibleInBTC: '0.00000000', 24 totalFlexibleInUSDT: '0.00000000' 25 } 26 { 27 positionAmountVos: [], 28 totalAmountInBTC: '0.00000000', 29 totalAmountInUSDT: '0.00000000', 30 totalFixedAmountInBTC: '0.00000000', 31 totalFixedAmountInUSDT: '0.00000000', 32 totalFlexibleInBTC: '0.00000000', 33 totalFlexibleInUSDT: '0.00000000' 34 }
exchangeInfo: Pull minimum order size, quantity, etc
Clamp order quantities to required amounts via minQty, minNotional, stepSize when placing orders
Show API Rate limits
Connect to all WebSockets at once
Get last order for a symbol
newOrderRespType example
Recent Trades (historicalTrades, recentTrades, aggTrades functions)
Terminate WebSocket connections
User Data: Account Balance Updates, Trade Updates, New Orders, Filled Orders, Cancelled Orders via WebSocket Margin User Data: Account Balance Updates, Trade Updates, New Orders, Filled Orders, Cancelled Orders via WebSocket Asynchronous Syntax Options
Verify that your system time is correct. If you have any suggestions don't hesitate to file an issue.
Having problems? Try adding useServerTime
to your options or setting recvWindow
:
1binance.options({ 2 APIKEY: 'xxx', 3 APISECRET: 'xxx', 4 useServerTime: true, 5 recvWindow: 60000, // Set a higher recvWindow to increase response timeout 6 verbose: true, // Add extra output when subscribing to WebSockets, etc 7 log: log => { 8 console.log(log); // You can create your own logger here, or disable console output 9 } 10});
Problems getting your balance? Wrap the entry point of your application in useServerTime:
1await binance.useServerTime(); 2binance.balance((error, balances) => { 3 if ( error ) return console.error(error); 4 console.info("balances()", balances); 5 console.info("BNB balance: ", balances.BNB.available); 6});
You can enable verbose mode to help with debugging WebSocket streams:
1binance.setOption( 'verbose', true );
No vulnerabilities found.