npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

open-binance-api

v1.2.1

Published

Binance API Client

Downloads

18

Readme

Open-Binance-Api-Client

Donate: TRC20 - Tether(USDT) - TFacXQTfHGYv9Vcyp64egx1VNt4ycnfj8m

Binance Api Client

NodeJS Binance API Client

Install

npm i open-binance-api

Usage

const OpenBinance = require("open-binance-api");

let OBinance = new OpenBinance(
  "API_KEY",

  "SECRET_KEY"
);

Account/Wallet

Fetch details of assets supported on Binance.
await OBinance.assetDetail()
  .then((result) => {
    console.log("assetDetail Result", result);
  })
  .catch((err) => {
    console.log("assetDetail Error: ", err);
  });
Univarsal Tranfser (BETWEEN WALLETS)
OBinance.universalTransfer("MAIN_FUNDING", "USDT", 10)
  .then((result) => {
    console.log("universalTransfer Result", result);
  })
  .catch((err) => {
    console.log("universalTransfer Error: ", err);
  });
Get user assets, just for positive data.
OBinance.getUserAsset()
  .then((result) => {
    console.log("getUserAsset Result", result);
  })
  .catch((err) => {
    console.log("getUserAsset Error: ", err);
  });
Get Api Restrictions
OBinance.apiRestrictions()
  .then((result) => {
    console.log("apiRestrictions Result", result);
  })
  .catch((err) => {
    console.log("apiRestrictions Error: ", err);
  });
Get Trade Fee
OBinance.tradeFee("BTCUSDT")
  .then((result) => {
    console.log("tradeFee Result", result);
  })
  .catch((err) => {
    console.log("tradeFee Error: ", err);
  });

Market Data Endpoints

Test connectivity to the Rest API.
OBinance.ping()
  .then((result) => {
    console.log("ping Result:", result);
  })
  .catch((err) => {
    console.log("ping Error: ", err);
  });
Test connectivity to the Rest API and get the current server time.
OBinance.checkServerTime()
  .then((result) => {
    console.log("checkServerTime Result:", result);
  })
  .catch((err) => {
    console.log("checkServerTime Error: ", err);
  });
Current exchange trading rules and symbol information
OBinance.exchangeInfo()
  .then((result) => {
    console.log("exchangeInfo Result:", result);
  })
  .catch((err) => {
    console.log("exchangeInfo Error: ", err);
  });
Order Book
OBinance.depth("BTCUSDT")
  .then((result) => {
    console.log("depth Result:", result);
  })
  .catch((err) => {
    console.log("depth Error: ", err);
  });
Get recent trades.
OBinance.trades("BTCUSDT")
  .then((result) => {
    console.log("trades Result:", result);
  })
  .catch((err) => {
    console.log("trades Error: ", err);
  });
Get compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price will have the quantity aggregated.
OBinance.aggTrades("BTCUSDT")
  .then((result) => {
    console.log("aggTrades Result:", result);
  })
  .catch((err) => {
    console.log("aggTrades Error: ", err);
  });
Kline/candlestick bars for a symbol.
OBinance.klines("BTCUSDT")
  .then((result) => {
    console.log("klines Result:", result);
  })
  .catch((err) => {
    console.log("klines Error: ", err);
  });
Current average price for a symbol.
OBinance.avgPrice("BTCUSDT")
  .then((result) => {
    console.log("avgPrice Result:", result);
  })
  .catch((err) => {
    console.log("avgPrice Error: ", err);
  });
24 hour rolling window price change statistics. Careful when accessing this with no symbol.
OBinance.tickerPrice24hr(["BTCUSDT"])
  .then((result) => {
    console.log("tickerPrice24hr Result:", result);
  })
  .catch((err) => {
    console.log("tickerPrice24hr Error: ", err);
  });
Latest price for a symbol or symbols.
OBinance.latestPrice(["BTCUSDT"])
  .then((result) => {
    console.log("latestPrice Result:", result);
  })
  .catch((err) => {
    console.log("latestPrice Error: ", err);
  });
Best price/qty on the order book for a symbol or symbols.
OBinance.bookTicker(["BTCUSDT"])
  .then((result) => {
    console.log("bookTicker Result:", result);
  })
  .catch((err) => {
    console.log("bookTicker Error: ", err);
  });
This endpoint is different from the tickerPrice24hr() method.
OBinance.computeStatistics(["BTCUSDT"])
  .then((result) => {
    console.log("computeStatistics Result:", result);
  })
  .catch((err) => {
    console.log("computeStatistics Error: ", err);
  });

Spot Account/Trade Endpoints

Test new order creation and signature/recvWindow long. Creates and validates a new order but does not send it into the matching engine.
OBinance.testNewOrder("BTCUSDT", "BUY", "LIMIT", 0.001, "GTC")
  .then((result) => {
    console.log("testNewOrder Result:", result);
  })
  .catch((err) => {
    console.log("testNewOrder Error: ", err);
  });
SPOT : MarketBuy
OBinance.spotMarketBuy("BTCUSDT", 0.001)
  .then((result) => {
    console.log("spotMarketBuy Result:", result);
  })
  .catch((err) => {
    console.log("spotMarketBuy Error: ", err);
  });
SPOT : MarketSell
OBinance.spotMarketSell("BTCUSDT", 0.001)
  .then((result) => {
    console.log("spotMarketSell Result:", result);
  })
  .catch((err) => {
    console.log("spotMarketSell Error: ", err);
  });
SPOT : LimitBuy
OBinance.spotLimitBuy("BTCUSDT", 0.001, 24000)
  .then((result) => {
    console.log("spotLimitBuy Result:", result);
  })
  .catch((err) => {
    console.log("spotLimitBuy Error: ", err);
  });
SPOT : LimitSell
OBinance.spotLimitSell("BTCUSDT", 0.001, 24000)
  .then((result) => {
    console.log("spotLimitSell Result:", result);
  })
  .catch((err) => {
    console.log("spotLimitSell Error: ", err);
  });
Cancel an active order.
OBinance.spotCancelOrder("BTCUSDT", 123456)
  .then((result) => {
    console.log("spotCancelOrder Result:", result);
  })
  .catch((err) => {
    console.log("spotMarkspotCancelOrderetBuy Error: ", err);
  });
Cancels all active orders on a symbol.
OBinance.spotCancelAllOrders("BTCUSDT")
  .then((result) => {
    console.log("spotCancelAllOrders Result:", result);
  })
  .catch((err) => {
    console.log("spotCancelAllOrders Error: ", err);
  });
Check an order's status.
OBinance.getOrder("BTCUSDT", 123456)
  .then((result) => {
    console.log("getOrder Result:", result);
  })
  .catch((err) => {
    console.log("getOrder Error: ", err);
  });
Get trades for a specific account and symbol.
OBinance.myTrades("BTCUSDT")
  .then((result) => {
    console.log("myTrades Result:", result);
  })
  .catch((err) => {
    console.log("myTrades Error: ", err);
  });
Displays the user's current order count usage for all intervals.
OBinance.rateLimitOrder()
  .then((result) => {
    console.log("rateLimitOrder Result:", result);
  })
  .catch((err) => {
    console.log("rateLimitOrder Error: ", err);
  });
Displays the list of orders that were expired because of STP trigger.
OBinance.myPreventedMatches("BTCUSDT", { orderId: 1111 })
  .then((result) => {
    console.log("myPreventedMatches Result:", result);
  })
  .catch((err) => {
    console.log("myPreventedMatches Error: ", err);
  });