Skip to content

An API wrapper for Binance. Build your application faster !

License

Notifications You must be signed in to change notification settings

Treast/binance.js

Repository files navigation

Logo Binance

binance.js

An API wrapper for Binance. Build your application faster !

Benefits

  • Built with Typescript (autocomplete on request/response)
  • Use native Promises
  • Updated with the latest version

Disclaimer

This library is being written. Some features may be changed as updates are made. Be careful.

I disclaim all responsibility for any loss, injury, claim, liability, or damage of any kind resulting from, arising out of, or any way related to any errors in or omissions from this library.

Installation

npm install binance.js --save

Usage

Node

const { Binance } = require('binance.js');

const binance = new Binance.Api(API_KEY, TEST_SECRET_KEY, true); // 3rd parameter is testMode. Set explicitly to false if you want to use Live API.

binance
  .spotAllOrders({
    symbol: 'BTCUSDT',
  })
  .then((res) => {
    console.log(res);
  });

Browser

import { Binance } from 'binance.js';

const binance = new Binance.Api(API_KEY, TEST_SECRET_KEY,  true); // 3rd parameter is testMode. Set explicitly to false if you want to use Live API.

binance
.spotNewOrder({
	symbol:  'BTCUSDT',
	side: Binance.EOrderSide.BUY,
	type: Binance.EOrderType.LIMIT,
	quantity:  0.01,
	price:  1000,
	timeInForce: Binance.EOrderTimeInForce.GTC,
.then((res)  =>  {
	console.log(res);
});

Functions

All functions have the same name as described on the official documentation and are prefixed by the domain: https://binance-docs.github.io/apidocs/.

Example: Spot > New Order becomes spotNewOrder

Example: Savings > Purchase Fixed/Activity Project becomes savingsPurchaseFixedActivityProject

Streams

Stream functions return a Websocket instance from the ws package. A cache is set up to prevent opening a same stream twice.

Progress

  • API Structure
  • Wallet endpoints
  • Market endpoints
  • Spot endpoints
  • Margin endpoints
  • Saving endpoints
  • Futures endpoints
  • Streams
  • Mining endpoints
  • BLVT endpoints
  • BSwap endpoints
  • Sub-accounts endpoints
  • Streams typings
  • Better error handling

License

MIT License