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.
npm install node-binance-apiVerified import paths — ran on the pinned version, not inferred.
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.
Existing WebSocket implementations may need to be updated. Review the official documentation for `node-binance-api` and adapt WebSocket subscription calls to utilize the new `ws-api` methods or structures.
Implement robust rate-limiting strategies within your application to manage request frequency. Consult Binance's official API documentation for the most current rate limit details and best practices.
Always use secure methods for managing credentials, such as environment variables (e.g., `process.env.BINANCE_API_KEY`), dedicated configuration management tools, or secret management services. Never expose keys publicly.
Call the imported module as a function to get the client instance: `const binance = Binance().options({...});` rather than `const binance = new Binance().options({...});`.Use methods like `binance.setFuturesEndpoint()` and verify that the API key provided in `binance.options()` has the necessary permissions enabled for Futures trading on your Binance account.
Remove the `new` keyword: `const binance = Binance().options({...});`.Ensure your server's time is synchronized using NTP. You can also try setting `useServerTime: true` in the `binance.options()` to have the library attempt to use Binance's server time for requests.
Double-check your API_KEY and API_SECRET. Verify on the Binance website that the API key is active, has the required permissions (e.g., Spot Trading, Futures Trading, Read), and that your server's IP address is whitelisted if IP restrictions are enabled.
Ensure your API key has WebSocket permissions. For user data streams, verify that you have obtained a valid `listenKey` and it has not expired. Refresh the `listenKey` regularly (e.g., every 30-60 minutes).
No dependency data recorded yet.