Registry / cryptocurrency / ccxws
library0.47.0jsnpmunverified

CCXWS is a JavaScript library providing real-time public data (ticker, trades, order books) from 37+ cryptocurrency exchanges via WebSockets. Current stable version is 0.47.0. It offers a unified event-driven interface, automatic reconnection with silent reconnection logic, and market structures compatible with CCXT for interoperability. Actively maintained with regular releases. Key differentiators include broad exchange support, standardized events, and built-in resilience.

npm install ccxws
INSTALL
IMPORT
SIG · CCXWS
C
ccxws
cryptocurrencyjavascriptv0.47.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.

BinanceClient
import { BinanceClient } from 'ccxws'
const BinanceClient = require('ccxws').BinanceClient
ESM-only; named export for each exchange client.
ccxws (default)
import ccxws from 'ccxws'
const ccxws = require('ccxws')
Default export is an object containing all exchange classes. Prefer named imports for tree-shaking.
Level2Point
import { Level2Point } from 'ccxws'
import Level2Point from 'ccxws'
Level2Point is a named export, not default.
Candle
import { Candle } from 'ccxws'
TypeScript types are exported as interfaces from the package.

Shows how to connect to Binance WebSocket, subscribe to trades and L2 snapshots, and clean up after 10 seconds.

import { BinanceClient } from 'ccxws'; const client = new BinanceClient(); const market = { id: 'BTCUSDT', base: 'BTC', quote: 'USDT', }; client.on('trade', trade => { console.log('Trade:', trade); }); client.on('l2snapshot', snapshot => { console.log('L2 Snapshot:', snapshot); }); client.subscribeTrades(market); client.subscribeLevel2Snapshots(market); setTimeout(() => { client.unsubscribeTrades(market); client.unsubscribeLevel2Snapshots(market); client.close(); }, 10000);
Debug
Known issues
breakingv0.30.0 changed event names from lowercase (e.g., 'trade') to camelCase (e.g., 'trade') - but actual events remain lowercase. Check docs.
fix
Use lowercase event names as before; the change only affected internal naming.
affects: >=0.30.0
breakingv0.40.0 replaced 'subscribeOrderBook' with 'subscribeLevel2Snapshots' and 'subscribeLevel2Updates'.
fix
Replace subscribeOrderBook() calls with subscribeLevel2Snapshots() or subscribeLevel2Updates() depending on need.
affects: >=0.40.0
deprecatedThe 'orderbook' event is deprecated in favor of 'l2snapshot' and 'l2update'.
fix
Use 'l2snapshot' and 'l2update' events instead.
affects: >=0.40.0
gotchaMarket structures require 'id' to be the exchange-specific symbol ID, not the unified symbol.
fix
Use the exchange's own market ID (e.g., 'BTCUSDT' for Binance) as the 'id' field.
affects: >=0.0.0
gotchaSome exchanges (e.g., Bitmex) require authentication for certain subscriptions even for public data.
fix
Set apiKey and apiSecret on the client for those exchanges.
affects: >=0.0.0
gotchaWebSocket will auto-reconnect, but event listeners are not restored on reconnect. You must re-subscribe after a reconnect.
fix
Listen to the 'connecting' or 'connected' event to re-subscribe.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: client.on is not a function
Using import incorrectly; client is a class, not an EventEmitter directly.
fix
Ensure you instantiate the client: const client = new BinanceClient(); then client.on(...).
Error: Cannot find module 'ccxws'
Package not installed or import path wrong.
fix
Run 'npm install ccxws' and use correct import: import { BinanceClient } from 'ccxws'.
TypeError: market.id is undefined
Market object missing required fields (id, base, quote).
fix
Provide market with at least id: 'BTCUSDT', base: 'BTC', quote: 'USDT'.
WebSocket connection to 'wss://...' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT
Network issue or exchange endpoint blocked.
fix
Check network connectivity and firewall settings. Try using a VPN if necessary.
Upgrade
Version history
0.47.0latest on npm
Audit
Dependencies
wsrequiredWebSocket client for Node.js
Agent activity
34 hits · last 30 days
node
30
Amazon
1
Resources
packageccxws
ccxws — npm install ccxws · libregistry