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

binance-futures-node

v0.0.8

Published

A simple JavaScript Binance(Futures) API implementation

Downloads

13

Readme

binance-futures-node

A Node JavaScript wrapper for the Binance(Futures) API.

Note: This wrapper uses Promises, if they are not supported in your environment, you might want to add a polyfill for them.

For PRs or issues, head over to the source repository.

Installation

yarn add binance-futures-node

Getting started

Import the module and create a new client. Passing api keys is optional only if you don't plan on doing authenticated calls. You can create an api key here.

import BinanceFutures from 'binance-futures-node'

new BinanceFutures().init('public','private').then(instance=>{
    instance.depth('BTCUSDT', DepthLimit.fiveHundred).then(res => res.json())
        .then((json) => {
            const find = (prev, cur) => {
                const current = {
                    price: cur[0],
                    amount: cur[1]
                }
                return current.amount > prev.amount ? current : prev
            }
            const start = {
                price: 0,
                amount: 0,
            }
            const lowest = json.bids.reduce(find, start)
            const biggest = json.asks.reduce(find, start)
            console.log('Looking at frame: [' + json.bids[json.bids.length - 1][0]
                + ']-[' + json.asks[json.asks.length - 1][0]+']')
            console.log(lowest)
            console.log(biggest)
            console.log("current prices: ["+json.bids[0][0] +"]-["+json.asks[0][0]+"]")
        })
})

BinanceFutures.time().then(res => res.json()).then(json => console.log(json.serverTime))

If you do not have an appropriate babel config, you will need to use the basic commonjs requires.

const BinanceFutures = require('binance-futures-node').default

Every REST method returns a Promise, making this library async await ready. Following examples will use the await form, which requires some configuration you will have to lookup.

Table of Contents

Public REST Endpoints

ping

Test connectivity to the API.

console.log(await client.ping())

time

Test connectivity to the Rest API and get the current server time.

console.log(await client.time())
1508478457643

exchangeInfo

Get the current exchange trading rules and symbol information.

console.log(await client.exchangeInfo())
{
  "timezone": "UTC",
  "serverTime": 1508631584636,
  "rateLimits": [
    {
      "rateLimitType": "REQUEST_WEIGHT",
      "interval": "MINUTE",
      "intervalNum": 1,
      "limit": 1200
    },
    {
      "rateLimitType": "ORDERS",
      "interval": "SECOND",
      "intervalNum": 1,
      "limit": 10
    },
    {
      "rateLimitType": "ORDERS",
      "interval": "DAY",
      "intervalNum": 1,
      "limit": 100000
    }
  ],
  "exchangeFilters": [],
  "symbols": [{
    "symbol": "ETHBTC",
    "status": "TRADING",
    "baseAsset": "ETH",
    "baseAssetPrecision": 8,
    "quoteAsset": "BTC",
    "quotePrecision": 8,
    "orderTypes": ["LIMIT", "MARKET"],
    "icebergAllowed": false,
    "filters": [{
      "filterType": "PRICE_FILTER",
      "minPrice": "0.00000100",
      "maxPrice": "100000.00000000",
      "tickSize": "0.00000100"
    }, {
      "filterType": "LOT_SIZE",
      "minQty": "0.00100000",
      "maxQty": "100000.00000000",
      "stepSize": "0.00100000"
    }, {
      "filterType": "MIN_NOTIONAL",
      "minNotional": "0.00100000"
    }]
  }]
}