Registry / finance / bitfinex-api-node

bitfinex-api-node

JSON →
library8.0.0jsnpmunverified

Official Node.js client library for the Bitfinex cryptocurrency exchange API. Version 8.0.0 supports REST v2 and WebSocket v2/v1 APIs, providing real-time trading, order management, and market data. Requires Node >=18.0. Key differentiators: official library with full coverage of Bitfinex endpoints, built-in WebSocket management, automatic reconnection, and order tracking via event emitters. Actively maintained with regular releases. Alternative to community libraries like ccxt, but Bitfinex-specific and supports advanced features like margin trading and funding.

npm install bitfinex-api-node
INSTALL
IMPORT
SIG · BITFINEX-API-NODE
B
bitfinex-api-node
financejavascriptv8.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

WSv2
import { WSv2 } from 'bitfinex-api-node'
import WSv2 from 'bitfinex-api-node'
WSv2 is a named export, not default. For CommonJS: const { WSv2 } = require('bitfinex-api-node')
Order
import { Order } from 'bitfinex-api-node'
const Order = require('bitfinex-api-node').Order
Order is a named export. In v2+, the constructor takes only options object.
BFX
import BFX from 'bitfinex-api-node'
const BFX = require('bitfinex-api-node').BFX
BFX is the default export. For TypeScript, use import BFX from 'bitfinex-api-node'.

Connects to Bitfinex WebSocket, authenticates, subscribes to BTCUSD trades, and logs incoming trades.

import BFX from 'bitfinex-api-node'; const bfx = new BFX({ apiKey: process.env.BITFINEX_API_KEY ?? '', apiSecret: process.env.BITFINEX_API_SECRET ?? '', ws: { autoReconnect: true, seqAudit: true } }); const ws = bfx.ws(); ws.on('error', console.error); ws.on('open', () => { console.log('WebSocket connected'); ws.auth(); }); ws.on('auth', () => { console.log('Authenticated'); ws.subscribeTrades('BTCUSD'); }); ws.onTrades({ symbol: 'tBTCUSD' }, (trades) => { console.log('Trades:', trades); }); ws.open();
Debug
Known issues
breakingConstructor changed from (apiKey, apiSecret, options) to (options) in v2.0.0
fix
Pass credentials inside an options object: new BFX({ apiKey: '...', apiSecret: '...' })
affects: >=2.0.0
deprecatedWebSocket v1 API is deprecated and may be removed in future versions
fix
Use WebSocket v2 API (WSv2) instead of the v1 WebSocket client.
affects: >=all
gotchaOrder snapshots and trade snapshots are emitted as nested arrays, not flat arrays
fix
Iterate over sub-arrays: orders.forEach(order => ...) where order is an array.
affects: >=2.0.0
breakingNode.js >=18.0 required as of v8.0.0
fix
Upgrade Node.js to version 18 or later, or pin to an older version of the library.
affects: >=8.0.0
Errors
Common errors & fixes
TypeError: BFX is not a constructor
Importing BFX incorrectly with named import instead of default import
fix
Use `import BFX from 'bitfinex-api-node'` (default) not `import { BFX } from 'bitfinex-api-node'`
Error: listen EADDRINUSE :::0
Multiple WebSocket connections trying to use the same port, possibly due to reconnection issues
fix
Ensure only one WebSocket instance is created, or close previous connections before opening new ones.
Error: API key or secret invalid
API key or secret passed incorrectly or missing in constructor options
fix
Pass apiKey and apiSecret as strings inside the options object: new BFX({ apiKey: '...', apiSecret: '...' })
UnhandledPromiseRejectionWarning: Error: Socket not open
Attempting to send data before the WebSocket connection is established
fix
Ensure you call ws.open() and wait for the 'open' event before sending messages.
Upgrade
Version history
8.0.0latest on npm
Audit
Dependencies
wsrequiredWebSocket client for real-time API communication
lodashrequiredUtility library used internally for data manipulation
Agent activity
50 hits · last 30 days
node
44
Perplexity
1
Resources
bitfinex-api-node — npm install bitfinex-api-node · libregistry