Node Binance Api
Node Binance API is an asynchronous node.js library for the Binance API designed to be easy to use.
Install / Use
npx skills add ccxt/node-binance-apiInstalls into whichever agent you are using.
README
Node Binance API
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.
<b><p align="center"> <a href="#binance-futures-api" style="color:#f9c513">Futures API</a> & <a href="#futures-websocket-streams" style="color:#f9c513">Streams</a> • <a href="#binance-api-spot-trading" style="color:#282828">Spot Trading API</a> & <a href="#websockets-implementation" style="color:#282828">Streams</a> • <a href="#binance-margin-api">Margin API</a> • <a href="#binance-lending-api">Lending API</a><br/> <a href="https://github.com/jaggedsoft/node-binance-api/tree/master/examples">Examples</a> • <a href="#troubleshooting">Troubleshooting</a> • <a href="https://github.com/jaggedsoft/node-binance-api/releases">Changelog</a> • <a href="https://t.me/binance_api_english">Support</a>
</p></b>Installation
npm install node-binance-api
<!-- [](https://npmjs.org/package/node-binance-api) -->
Community Telegram Chat
https://t.me/nodebinanceapi
This project is powered by <a href="https://github.com/ccxt/ccxt"><img src="https://avatars.githubusercontent.com/u/31901609" width=4% height=4%></a>
Actively maintained, typed, and safe SDK for the Binance REST APIs and Websockets. Supports ESM and CJS out of the box.
Features
- Spot, Margin, Futures and Delivery API (including the new algoOrder service)
- Demo trading support
- Testnet support (deprecated)
- Proxy support (REST and WS, including the new WS-API)
- Customizable HTTP headers
- Customizable request parameters
- RSA/ECDSA support
- Portfolio Margin API *soon*
- Websocket handling with automatic reconnection
- RecvWindow and automatic timestamps generation
- Ability to call any endpoint, even if not supported directly by the library
- Overridable hostnames (.us, .jp, etc)
- Verbose mode to debug http requests/responses
Upgrading to v1.0.0+
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.
Getting started (ESM)
import Binance from 'node-binance-api';
async function run() {
const exchange = new Binance();
const res = await exchange.futuresTime();
console.log( res );
}
Getting started (CJS)
const Binance = require('node-binance-api');
const binance = new Binance({
APIKEY: '<key>',
APISECRET: '<secret>',
test: true, // if you want to use the sandbox/testnet
});
Binance Futures API
Futures Prices
console.info( await binance.futuresPrices() );
Futures Account Balances & Positions
console.info( await binance.futuresAccount() );
Futures Balances
console.info( await binance.futuresBalance() );
Futures Limit Buy
console.info( await binance.futuresBuy( 'LIMIT', 'BTCUSDT', 0.1, 8222 ) );
Futures Limit Sell
console.info( await binance.futuresSell( 'LIMIT', 'BTCUSDT', 0.5, 11111 ) );
Futures Market Buy
console.info( await binance.futuresMarketBuy( 'BNBUSDT', 5 ) );
Futures Market Sell
console.info( await binance.futuresMarketSell( 'TRXUSDT', 1 ) );
Futures Place Multiple Orders
let orders = [
{
symbol:"BTCUSDT",
side: "BUY",
type: "MARKET",
quantity: "0.01",
},
{
symbol:"BNBUSDT",
side: "SELL",
type: "MARKET",
quantity: "0.5",
}
]
console.info( await binance.futuresMultipleOrders(orders) );
Futures Market Orders: Get the fill price using newOrderRespType
console.info( await binance.futuresMarketBuy( 'BNBUSDT', amount, { newOrderRespType: 'RESULT' } ) );
Futures reduceOnly Order Example
if ( side == 'LONG' ) order = await binance.futuresMarketSell( obj.symbol, amount, {reduceOnly: true} )
else order = await binance.futuresMarketBuy( obj.symbol, amount, {reduceOnly: true} )
Get Futures Positions
console.info( await binance.futuresPositionRisk() );
<details>
<summary>View Example</summary>
let position_data = await binance.futuresPositionRisk(), markets = Object.keys( position_data );
for ( let market of markets ) {
let obj = position_data[market], size = Number( obj.positionAmt );
if ( size == 0 ) continue;
console.info( `${leverage}x\t${market}\t${obj.unRealizedProfit}` );
//console.info( obj ); //positionAmt entryPrice markPrice unRealizedProfit liquidationPrice leverage marginType isolatedMargin isAutoAddMargin maxNotionalValue
}
</details>
Adjust Leverage (1-125x)
console.info( await binance.futuresLeverage( 'ETHUSDT', 50 ) );
Adjust Margin Type (ISOLATED, CROSSED)
console.info( await binance.futuresMarginType( 'BTCUSDT', 'ISOLATED' ) );
Adjust Position Margin
// Type: 1: Add postion margin,2: Reduce postion margin
console.info( await binance.futuresPositionMargin( "TRXUSDT", amount, type ) );
console.info( await binance.futuresTime() );
console.info( await binance.futuresExchangeInfo() );
console.info( await binance.futuresCandles( "TRXUSDT", "1m" ) );
console.info( await binance.futuresDepth( "ADAUSDT" ) );
console.info( await binance.futuresQuote() );
console.info( await binance.futuresQuote( "BCHUSDT" ) );
console.info( await binance.futuresDaily() );
console.info( await binance.futuresOpenInterest( "BTCUSDT" ) );
console.info( await binance.futuresMarkPrice() );
console.info( await binance.futuresMarkPrice( "ETHUSDT" ) );
console.info( await binance.futuresTrades( "LTCUSDT" ) );
console.info( await binance.futuresAggTrades( "XTZUSDT" ) );
console.info( await binance.futuresLiquidationOrders() );
console.info( await binance.futuresFundingRate() );
console.info( await binance.futuresHistoricalTrades( "XMRUSDT" ) );
console.info( await binance.fu
Related Skills
obsidian
385.6kWork with Obsidian vaults using the official obsidian CLI: read/search/create/edit notes, tasks, links, properties, plugins.
html-anything
8.1k✨ The agentic HTML editor — your local AI agent writes the HTML, you ship it. 🚀 75 Skills × 9 Surfaces (magazine · deck · poster · XHS / tweet · prototype · data report · Hyperframes) 🛡️ Sandboxed preview · 📤 1-click to WeChat / X / Zhihu / HTML / PNG 🔑 Zero API key — Claude Code / Cursor / Code…
openpencil
4.7kThe world's first open-source AI-native vector design tool and the first to feature concurrent Agent Teams. Design-as-Code. Turn prompts into UI directly on the live canvas. A modern alternative to Pencil.
openpencil
4.7kThe world's first open-source AI-native vector design tool and the first to feature concurrent Agent Teams. Design-as-Code. Turn prompts into UI directly on the live canvas. A modern alternative to Pencil.


