1+ ![ Downloads] ( https://img.shields.io/npm/dt/node-binance-api.svg?style=for-the-badge&maxAge=86400 ) ![ Stars] ( https://img.shields.io/github/stars/jaggedsoft/node-binance-api.svg?style=for-the-badge&label=Stars ) ![ Contributors] ( https://img.shields.io/github/contributors/jaggedsoft/node-binance-api.svg?style=for-the-badge&maxAge=86400 )
12
23[ ![ Latest Version] ( https://img.shields.io/github/release/jaggedsoft/node-binance-api.svg?style=flat-square )] ( https://github.com/jaggedsoft/node-binance-api/releases )
34[ ![ GitHub last commit] ( https://img.shields.io/github/last-commit/jaggedsoft/node-binance-api.svg?maxAge=2400 )] ( # )
4- [ ![ npm downloads] ( https://img.shields.io/npm/dt/node-binance-api.svg?maxAge=7200 )] ( https://www.npmjs.com/package/node-binance-api )
5+ <!-- [](https://www.npmjs.com/package/node-binance-api) -->
56[ ![ jaggedsoft on Twitter] ( https://img.shields.io/twitter/follow/jaggedsoft.svg?style=social )] ( https://twitter.com/jaggedsoft )
67
78[ ![ NPM] ( https://nodei.co/npm/node-binance-api.png?compact=true )] ( https://npmjs.org/package/node-binance-api )
89
910[ ![ Build Status] ( https://travis-ci.org/jaggedsoft/node-binance-api.svg?branch=master&style=flat-square )] ( https://travis-ci.org/jaggedsoft/node-binance-api )
1011[ ![ Coverage Status] ( https://coveralls.io/repos/github/jaggedsoft/node-binance-api/badge.svg?branch=master&style=flat-square )] ( https://coveralls.io/github/jaggedsoft/node-binance-api )
1112[ ![ CodeCov] ( https://codecov.io/gh/jaggedsoft/node-binance-api/branch/master/graph/badge.svg?style=flat-square )] ( https://codecov.io/github/jaggedsoft/node-binance-api/ )
12- [ ![ Codacy Badge] ( https://api.codacy.com/project/badge/Coverage/996757cec66542c0a64fca2b4cf8a936 )] ( https://www.codacy.com/app/dmzoneill /node-binance-api?utm_source=github.com&utm_medium=referral&utm_content=jaggedsoft/node-binance-api&utm_campaign=Badge_Coverage )
13- [ ![ Codacy Badge ] ( https://api.codacy.com/project/badge/Grade/996757cec66542c0a64fca2b4cf8a936 )] ( https://www.codacy.com/app/dmzoneill/node-binance-api?utm_source=github.com & amp ; utm_medium=referral & amp ; utm_content= jaggedsoft/node-binance-api& amp ; utm_campaign=Badge_Grade )
13+ <!-- [](https://www.codacy.com/app/jaggedsoft /node-binance-api?utm_source=github.com&utm_medium=referral&utm_content=jaggedsoft/node-binance-api&utm_campaign=Badge_Coverage) -->
14+ [ ![ Codacy Grade ] ( https://api.codacy.com/project/badge/Grade/996757cec66542c0a64fca2b4cf8a936 )] ( https://www.codacy.com/app/jaggedsoft/node-binance-api )
1415
1516# Node Binance API
1617This project is designed to help you make your own projects that interact with the [ Binance API] ( https://github.com/binance-exchange/binance-official-api-docs ) . 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.
18+ ** Now supporting Promises, Margin, Futures and OCO**
1719
1820#### Installation
1921```
@@ -22,14 +24,47 @@ npm install node-binance-api --save
2224
2325#### Getting started
2426``` javascript
25- const binance = require (' node-binance-api' )().options ({
27+ const Binance = require (' node-binance-api' );
28+ const binance = new Binance ().options ({
2629 APIKEY : ' <key>' ,
27- APISECRET : ' <secret>' ,
28- useServerTime: true // If you get timestamp errors, synchronize to server time at startup
30+ APISECRET : ' <secret>'
2931});
3032```
3133
32- Note: You can use promises or callbacks, whatever you're the most comfortable with.
34+ # Binance Futures API
35+ > ** Work in progress, including documentation. Promises only**
36+ ``` js
37+ console .info ( await api .futuresPrices () );
38+ console .info ( await api .futuresTime () );
39+ console .info ( await api .futuresExchangeInfo () );
40+ console .info ( await api .futuresCandles ( " TRXUSDT" , " 1m" ) );
41+ console .info ( await api .futuresDepth ( " ADAUSDT" ) );
42+ console .info ( await api .futuresQuote () );
43+ console .info ( await api .futuresQuote ( " BCHUSDT" ) );
44+ console .info ( await api .futuresDaily () );
45+ console .info ( await api .futuresOpenInterest ( " BTCUSDT" ) );
46+ console .info ( await api .futuresMarkPrice () );
47+ console .info ( await api .futuresMarkPrice ( " ETHUSDT" ) );
48+ console .info ( await api .futuresTrades ( " LTCUSDT" ) );
49+ console .info ( await api .futuresAggTrades ( " XTZUSDT" ) );
50+ console .info ( await api .futuresLiquidationOrders () );
51+ console .info ( await api .futuresFundingRate () );
52+ console .info ( await api .futuresHistoricalTrades ( " XMRUSDT" ) );
53+ console .info ( await api .futuresLeverageBracket ( " LINKUSDT" ) );
54+
55+ // Currently in development:
56+ futuresMarketBuy
57+ futuresMarketSell
58+ futuresOrderStatus
59+ futuresOrder: private ' v1/order'
60+ futuresCancelOrder: private ' v1/order' ' DELETE'
61+ futuresOpenOrders: private ' v1/openOrders'
62+ futuresPositionRisk: private ' v1/positionRisk'
63+ futuresGetDataStream: private ' v1/listenKey' ' POST'
64+ futuresKeepDataStream: private ' v1/listenKey' ' PUT'
65+ futuresCloseDataStream: private ' v1/listenKey' ' DELETE'
66+ Futures WebSockets
67+ ```
3368
3469#### Getting latest price of all symbols
3570``` javascript
@@ -1569,69 +1604,42 @@ let amount = 0.1;
15691604binance .withdraw (" XMR" , address, amount, addressTag);
15701605```
15711606
1572- #### Withdraw with Callback
1573- ``` js
1574- binance .withdraw (" ETH" , " 0x1d2034348c851ea29c7d03731c7968a5bcc91564" , 1 , false , (error , response ) => {
1575- console .log (response);
1576- });
1577- ```
1578-
15791607#### Withdraw
15801608``` js
15811609binance .withdraw (" BTC" , " 1C5gqLRs96Xq4V2ZZAR1347yUCpHie7sa" , 0.2 );
15821610```
15831611
1584- #### Withdraw with custom name
1585- ``` js
1586- // let name = false // Falsy value won't save address to address book
1587- let name = ' My Withdrawal Address'
1588- binance .withdraw (" BTC" , " 1C5gqLRs96Xq4V2ZZAR1347yUCpHie7sa" , 0.2 , undefined , name)
1589- ```
1590- # Margin
1591- Margin is newly implemented and a work in progress.
1592- For now:
1612+ # Binance Margin API
15931613
15941614#### Transfer from Main account to Margin account
15951615``` js
15961616binance .mgTransferMainToMargin (asset, amount, (error , response ) => {
1597- if (error) {
1598- // error from Binance endpoint
1599- } else {
1600- // should get a tranId
1601- }
1617+ if ( error ) return console .warn (error);
1618+ // Success! Transaction ID: response.tranId
16021619});
16031620
16041621```
16051622#### Transfer from Margin account to Main account
16061623``` js
16071624binance .mgTransferMarginToMain (asset, amount, (error , response ) => {
1608- if (error) {
1609- // error from Binance endpoint
1610- } else {
1611- // should get a tranId
1612- }
1625+ if ( error ) return console .warn (error);
1626+ // Success! Transaction ID: response.tranId
16131627});
16141628```
16151629
16161630#### Borrow from margin account
16171631``` js
16181632binance .mgBorrow (asset, amount, (error , response ) => {
1619- if (error) {
1620- // error from Binance endpoint
1621- } else {
1622- // should get a tranId
1623- }
1633+ if ( error ) return console .warn (error);
1634+ // Success! Transaction ID: response.tranId
16241635});
16251636```
16261637
16271638#### Repay margin account
16281639``` js
16291640binance .mgRepay (asset, amount, (error , response ) => {
1630- if (error) {
1631- // error from Binance endpoint
1632- } else {
1633- // should get a tranId
1634- }
1641+ if ( error ) return console .warn (error);
1642+ // Success! Transaction ID: response.tranId
16351643});
16361644```
16371645
@@ -1664,7 +1672,6 @@ binance.mgOrderStatus("ETHBTC", orderid, (error, orderStatus, symbol) => {
16641672});
16651673```
16661674
1667-
16681675#### [ Advanced Examples] ( https://github.com/jaggedsoft/node-binance-api/blob/master/examples/advanced.md )
16691676> [ exchangeInfo: Pull minimum order size, quantity, etc] ( https://github.com/jaggedsoft/node-binance-api/blob/master/examples/advanced.md#exchangeinfo-pull-minimum-order-size-quantity-etc ) \
16701677[ Clamp order quantities to required amounts via minQty, minNotional, stepSize when placing orders] ( https://github.com/jaggedsoft/node-binance-api/blob/master/examples/advanced.md#clamp-order-quantities-to-required-amounts-via-minqty-minnotional-stepsize-when-placing-orders ) \
@@ -1678,39 +1685,6 @@ binance.mgOrderStatus("ETHBTC", orderid, (error, orderStatus, symbol) => {
16781685[ Margin User Data: Account Balance Updates, Trade Updates, New Orders, Filled Orders, Cancelled Orders via WebSocket] ( https://github.com/jaggedsoft/node-binance-api/blob/master/examples/advanced.md#margin-user-data-account-balance-updates-trade-updates-new-orders-filled-orders-cancelled-orders-via-websocket )
16791686[ Asynchronous Syntax Options] ( https://github.com/jaggedsoft/node-binance-api/blob/master/examples/advanced.md#asynchronous-syntax-options )
16801687
1681-
1682- ### Proxy Support
1683- For the standard REST API the https_proxy or socks_proxy variable is honoured
1684- * NOTE* proxy package has no dns name support, please use proxy IP address
1685-
1686- ** Linux**
1687- ``` bash
1688- export https_proxy=http://ip:port
1689- # export socks_proxy=socks://ip:port
1690- # run your app
1691- ```
1692-
1693- ** Windows**
1694- ``` bash
1695- set https_proxy=http://ip:port
1696- # set socks_proxy=socks://ip:port
1697- # run your app
1698- ```
1699-
1700- For web sockets currently only the socks method is functional at this time
1701-
1702- ** linux**
1703- ``` bash
1704- export socks_proxy=socks://ip:port
1705- # run your app
1706- ```
1707-
1708- ** windows**
1709- ``` bash
1710- set socks_proxy=socks://ip:port
1711- # run your app
1712- ```
1713-
17141688### Troubleshooting
17151689Verify that your system time is correct. If you have any suggestions don't hesitate to file an issue.
17161690
@@ -1730,7 +1704,7 @@ binance.options({
17301704
17311705Problems getting your balance? Wrap the entry point of your application in useServerTime:
17321706``` js
1733- binance .useServerTime (function () {
1707+ binance .useServerTime (() => {
17341708 binance .balance ((error , balances ) => {
17351709 if ( error ) return console .error (error);
17361710 console .log (" balances()" , balances);
@@ -1739,11 +1713,9 @@ binance.useServerTime(function() {
17391713});
17401714```
17411715
1742- Thank you to all contributors: Eluvade, dbvcode, bmino, dmzoneill, dmitriz, keith1024, pavlovdog, usama33, yanislk, learnathoner, vaielab, nickreese, Tuitio, grandmore, itnok, CollinEstes, sethyx, mstijak, MadDeveloper, balthazar, bitoiu, matthewwoop, robaleman, hems and others!
1743-
1744- > # ⚠️ Binance no longer offers support for API projects.
1745- > ## No support is offered. No questions will be answered. Pull requests are still welcome.
1716+ *** Thank you to all contributors:*** Eluvade, dbvcode, bmino, dmzoneill, dmitriz, keith1024, pavlovdog, usama33, yanislk, learnathoner, vaielab, nickreese, Tuitio, grandmore, itnok, CollinEstes, sethyx, mstijak, MadDeveloper, balthazar, bitoiu, matthewwoop, robaleman, hems and others!
17461717
1718+ > # ⚠️ For support go to [ Telegram] ( https://t.me/binance_api_english ) &mdash ; I am too busy to help you
17471719
17481720## Stargazers over time
17491721
0 commit comments