
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
bfx-api-node-core
Advanced tools
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.
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/manager_docs.md
for the Manager class documentation, and docs/ws2_funcs.md
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)
debug(
'latest candle: open %d, high %d, low %d, close %d, volume: %d, mts: %s',
candle.open, 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'))
m.openWS()
debug('awaiting watchdog trigger [no subscriptions]')
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Core Bitfinex Node API
The npm package bfx-api-node-core receives a total of 284 weekly downloads. As such, bfx-api-node-core popularity was classified as not popular.
We found that bfx-api-node-core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.