Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including bfx-api-node-core with all npm packages installed. Try it out:

var bfxApiNodeCore = require("bfx-api-node-core")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

bfx-api-node-core v1.1.8

Core Bitfinex Node API

Bitfinex Modular WSv2 API Library for Node.JS

Build Status

Modular Bitfinex Node.JS API library as an alternative to bitfinex-api-node, supporting a plugin system. Connection instances are POJOs as opposed to the WSv2 class instances returned by bitfinex-api-node and are manipulated in a functional style. A connection pool manager is also provided for multiplexing.


  • POJO connection instances
  • Multiplexing connection pool manager
  • Plugin system for extending the default events


npm i --save bfx-api-node-core


const { Manager, initState } = require('bfx-api-node-core')

// Create a Manager instance with an internal connection pool, and add a
// connection to the pool
const m = new Manager({ transform: true })
const managedConnection = m.openWS()

// Alternatively, create & open a single connection yourself
const connection = initState({ transform: true })

// do something with connections, see below for examples


See docs/ for the Manager class documentation, and docs/ for documentation on the functions available for manipulating a connection instance.


Subscribing to a candle channel:

const debug = require('debug')('bfx:api:core:examples:candles')
const { subscribe, Manager } = require('../')

const CANDLE_KEY = 'trade:1m:tBTCUSD'

debug('opening connection...')

const m = new Manager({ transform: true })
const wsState = m.openWS()

m.on('ws2:open', () => debug('connection opened'))
m.on('ws2:close', () => debug('connection closed'))

m.on('ws2:candles', (candles, meta) => {
  const { chanFilter } = meta
  const { key } = chanFilter
  const [candle] = candles
  const nCandles = candles.length

  debug('recv %d candles on key', nCandles, key)
    'latest candle: open %d, high %d, low %d, close %d, volume: %d, mts: %s',, candle.high, candle.low, candle.close, candle.volume,
    new Date(candle.mts).toLocaleString()

debug('subscribing to candles channel %s', CANDLE_KEY)

subscribe(wsState, 'candles', { key: CANDLE_KEY })

Using a plugin:

const debug = require('debug')('bfx:api:core:examples:candles')
const Watchdog = require('bfx-api-node-plugin-wd')
const { Manager } = require('../')

const WATCHDOG_DELAY = 5 * 1000

debug('opening connection...')

const m = new Manager({
  transform: true,
  plugins: [Watchdog({ pachetWDDelay: WATCHDOG_DELAY })]

m.on('ws2:open', () => debug('connection opened'))
m.on('ws2:reopen', () => debug('connection re-opened'))
m.on('ws2:close', () => debug('connection closed'))

debug('awaiting watchdog trigger [no subscriptions]')


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free