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

bitfinex-api-node-mod

v1.2.1

Published

Node reference library for Bitfinex API

Downloads

3

Readme

Bitfinex Trading API for Node.JS. Bitcoin, Ether and Litecoin trading

Build Status

A Node.JS reference implementation of the Bitfinex API. See the full docs at http://bitfinexcom.github.io/bitfinex-api-node/

  • Official implementation
  • REST API
  • WebSockets API

Installation

  npm install bitfinex-api-node

Usage

Version 1.0.0 supports the new v2 Websocket and Rest API. As Network calls are slow, the data is sent as lists.

In order to reconstruct key / value pairs, set opts.transform to true.

const BFX = require('bitfinex-api-node')

const API_KEY = 'secret'
const API_SECRET = 'secret'

const opts = {
  version: 2,
  transform: true
}

const bws = new BFX(API_KEY, API_SECRET, opts).ws

bws.on('auth', () => {
  // emitted after .auth()
  // needed for private api endpoints

  console.log('authenticated')
  // bws.submitOrder ...
})

bws.on('open', () => {
  bws.subscribeTicker('BTCUSD')
  bws.subscribeOrderBook('BTCUSD')
  bws.subscribeTrades('BTCUSD')

  // authenticate
  // bws.auth()
})

bws.on('orderbook', (pair, book) => {
  console.log('Order book:', book)
})

bws.on('trade', (pair, trade) => {
  console.log('Trade:', trade)
})

bws.on('ticker', (pair, ticker) => {
  console.log('Ticker:', ticker)
})

bws.on('error', console.error)

new BFX(API_KEY, API_SECRET, opts)

Where opts can be:

const opts = {
  // use v1 or v2 of the API, values: 1, 2
  version: 2,
  // transform lists for the v2 API. values: true, false, function
  transform: true
}

Version 1.0.0 Breaking changes:

constructor takes an options object now, instead of version number:

Old:

new BFX(API_KEY, API_SECRET, 2)

since 1.0.0:

new BFX(API_KEY, API_SECRET, { version: 2 })

Note version must be of type Number.

trade and orderbook snapshots are emitted as nested lists

To make dealing with snapshots better predictable, snapshots are emitted as an array.

normalized orderbooks for R0

Lists of raw orderbooks (R0) are ordered in the same order as P0, P1, P2, P3

Tests

npm test

FAQ

nonce too small

I make multiple parallel request and I receive an error that the nonce is too small. What does it mean?

Nonces are used to guard against replay attacks. When multiple HTTP requests arrive at the API with the wrong nonce, e.g. because of an async timing issue, the API will reject the request.

If you need to go parallel, you have to use multiple API keys right now.

Contributors