{"library":"node-binance-api","title":"Binance API Client for Node.js","description":"The `node-binance-api` package provides a comprehensive client library for interacting with the Binance cryptocurrency exchange API from Node.js environments. It offers full coverage of Binance's Spot, Futures, and WebSocket APIs, enabling real-time market data streaming, order management, and account queries. The current stable version is 1.0.27, and the library maintains a relatively active release cadence, frequently pushing minor updates and bug fixes. Key differentiators include extensive API coverage, robust WebSocket support for various data streams, and built-in handling for common trading operations, making it suitable for developing automated trading bots and market analysis tools.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install node-binance-api"],"cli":null},"imports":["import Binance from 'node-binance-api';\nconst binance = Binance().options({ /* ... */ });","import { WebSockets } from 'node-binance-api';","const Binance = require('node-binance-api');\nconst binance = Binance().options({ /* ... */ });"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import Binance from 'node-binance-api';\n\nconst binance = Binance().options({\n  APIKEY: process.env.BINANCE_API_KEY ?? '',\n  APISECRET: process.env.BINANCE_API_SECRET ?? '',\n  useServerTime: true, // Recommended to sync time with Binance\n  recvWindow: 60000, // Set a higher recvWindow for potentially slow networks\n});\n\nasync function getMarketDataAndBalance() {\n  try {\n    console.log('Fetching market prices...');\n    const prices = await binance.prices();\n    console.log('Current BTCUSDT price:', prices.BTCUSDT);\n\n    if (binance.options.APIKEY && binance.options.APISECRET) {\n      console.log('\\nFetching account balances...');\n      const balances = await binance.balance();\n      console.log('Available USDT balance:', balances.USDT ? balances.USDT.available : 'N/A');\n      console.log('Available BTC balance:', balances.BTC ? balances.BTC.available : 'N/A');\n    } else {\n      console.log('\\nSkipping account balance check: API_KEY and/or API_SECRET not provided.');\n    }\n\n    console.log('\\nSubscribing to BTCUSDT KLine stream for 1 minute intervals...');\n    binance.websockets.chart(\"BTCUSDT\", \"1m\", (symbol, interval, chart) => {\n      const tick = binance.last(chart);\n      console.log(`[${new Date(tick.openTime).toLocaleTimeString()}] BTCUSDT 1m: Open ${tick.open}, High ${tick.high}, Low ${tick.low}, Close ${tick.close}`);\n    });\n\n  } catch (error) {\n    console.error('An error occurred:', error.message);\n  }\n}\n\ngetMarketDataAndBalance();","lang":"typescript","description":"This quickstart initializes the Binance API client using environment variables, fetches current market prices, retrieves account balances (if API keys are provided), and demonstrates a real-time WebSocket subscription for BTCUSDT 1-minute candlestick data.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}