Registry / finance / bfx-api-node-rest

bfx-api-node-rest

JSON →
library8.0.0jsnpmunverified

Official Node.js library for interacting with the Bitfinex REST v1 and v2 APIs. v8.0.0 requires Node >=16 and uses promises with optional callbacks. Supports both public and authenticated endpoints, with transform option to convert array responses into key-value objects. Key differentiator: official implementation maintained by Bitfinex, supporting both API versions.

npm install bfx-api-node-rest
INSTALL
IMPORT
SIG · BFX-API-NODE-REST
B
bfx-api-node-rest
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.

RESTv2
const { RESTv2 } = require('bfx-api-node-rest')
import { RESTv2 } from 'bfx-api-node-rest'
This package is primarily CommonJS; ESM import may work but is not officially supported. Use require() for guaranteed compatibility.
RESTv1
const { RESTv1 } = require('bfx-api-node-rest')
const RESTv1 = require('bfx-api-node-rest').RESTv1
Deprecated but still available. Prefer RESTv2 for new projects.
default import
const BFX = require('bfx-api-node-rest')
import BFX from 'bfx-api-node-rest'
Default export is an object containing RESTv1, RESTv2, and possibly other utilities. Named destructuring is preferred.

Initialize RESTv2 with transform enabled and fetch a ticker for BTCUSD.

const { RESTv2 } = require('bfx-api-node-rest'); const rest = new RESTv2({ transform: true }); // Fetch ticker for BTCUSD rest.ticker('tBTCUSD').then(ticker => { console.log('BTCUSD last price:', ticker.last_price); }).catch(err => { console.error('Error:', err); });
Debug
Known issues
gotchaNonce errors when making parallel requests with the same API key. The API rejects nonces that are too small due to async timing issues.
fix
Use multiple API keys for parallel requests, or serialize your requests.
affects: >=0.0.0
gotchaArray responses are not transformed by default. You must set transform: true to get key-value pair objects.
fix
Pass { transform: true } in the constructor options.
affects: >=0.0.0
breakingNode.js version requirement increased to >=16.0.0 in v8.0.0.
fix
Upgrade Node.js to version 16 or later.
affects: >=8.0.0
Errors
Common errors & fixes
nonce too small
Multiple parallel requests with the same API key cause nonce sequencing issues.
fix
Use separate API keys for each parallel request or ensure sequential execution.
TypeError: Cannot destructure property 'RESTv2' of 'require(...)' as it is undefined.
Incorrect import: attempting to use ESM import or a named import from a default-only export.
fix
Use const { RESTv2 } = require('bfx-api-node-rest').
Upgrade
Version history
8.0.0latest on npm
Audit
Dependencies
debugrequiredLogging utility for request debugging
Agent activity
46 hits · last 30 days
node
40
Perplexity
1
Resources
bfx-api-node-rest — npm install bfx-api-node-rest · libregistry