Registry / finance / binary-live-api

binary-live-api

JSON →
library29.0.1jsnpmunverified

binary-live-api (v29.0.1) is a high-level promise-based WebSocket client for the Binary.com trading API. It provides automatic reconnection with resubscription, an event system for real-time data, and an optional RxJS observable mode. The library targets both browser and Node.js environments, but requires a WebSocket polyfill in Node. Development is active with regular releases. Compared to direct WebSocket usage, it adds request-response mapping, subscription management, and a cleaner API.

npm install binary-live-api
INSTALL
IMPORT
SIG · BINARY-LIVE-API
B
binary-live-api
financejavascriptv29.0.1
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.

LiveApi
import { LiveApi } from 'binary-live-api'
import LiveApi from 'binary-live-api'
Named export, not default. CJS: const { LiveApi } = require('binary-live-api')
LiveApi
const { LiveApi } = require('binary-live-api')
const LiveApi = require('binary-live-api')
Named export, not default. CommonJS pattern.
LiveApi (with RxJS)
const api = new LiveApi({ useRx: true })
Enables observable mode. Incompatible with event-based API.

Connects to Binary.com WebSocket API, authorizes with token, fetches portfolio, and listens for real-time updates.

const { LiveApi } = require('binary-live-api'); const WebSocket = require('ws'); const api = new LiveApi({ websocket: WebSocket }); const token = process.env.BINARY_TOKEN || ''; api.authorize(token).then(() => { api.getPortfolio().then(response => { console.log('Portfolio:', response); }); }); api.events.on('portfolio', data => { console.log('Portfolio event:', data); }); setTimeout(() => { api.disconnect(); }, 5000);
Debug
Known issues
gotchaNode.js requires the 'ws' package. Without it, the library will throw a WebSocket is not defined error.
fix
Install 'ws' and pass it to constructor: new LiveApi({ websocket: require('ws') })
affects: *
gotchaWhen using the RxJS observable API (useRx: true), the event emitter is disabled. You must use observables instead.
fix
Do not mix api.events listeners with useRx: true. Use only observables.
affects: *
deprecatedThe RxJS mode uses rx.lite (RxJS 4), not RxJS 5+. This is considered experimental and not recommended for production.
fix
Consider using the standard Promise-based API or a newer wrapper.
affects: *
Errors
Common errors & fixes
WebSocket is not defined
Running in Node.js without providing a WebSocket implementation.
fix
Install 'ws' and pass it to LiveApi constructor: new LiveApi({ websocket: require('ws') })
TypeError: LiveApi is not a constructor
Importing default export instead of named export.
fix
Use const { LiveApi } = require('binary-live-api') or import { LiveApi } from 'binary-live-api'
Upgrade
Version history
29.0.1latest on npm
Audit
Dependencies
wsoptionalRequired in Node.js as WebSocket polyfill; browser has native WebSocket.
Agent activity
48 hits · last 30 days
node
40
Amazon
1
Perplexity
1
Resources
binary-live-api — npm install binary-live-api · libregistry