📅  最后修改于: 2023-12-03 15:13:39.399000             🧑  作者: Mango
Binance JS is a Javascript library that allows you to interact with the Binance API. With this library, you can create trading bots, analyze historical data, place orders, and more.
You can install Binance JS using npm:
npm install binance-api-node
First, you need to create an instance of the client:
const Binance = require('binance-api-node').default;
const client = Binance({
apiKey: 'YOUR_API_KEY',
apiSecret: 'YOUR_API_SECRET',
});
const balance = await client.accountInfo();
console.log(balance.balances);
const candles = await client.candles({
symbol: 'BTCUSDT',
interval: '1d',
limit: 30,
});
console.log(candles);
const order = await client.order({
symbol: 'BTCUSDT',
side: 'BUY',
type: 'MARKET',
quantity: 0.001,
});
console.log(order);
For more examples and documentation, please refer to the official Binance API documentation.
Binance JS is a powerful tool for building trading bots, analyzing data, and automating your trading strategies on the Binance Exchange. With its easy to use API and extensive documentation, you can quickly get started with your project.