Skip to main content

WebSocket API

ScaleX DEX provides comprehensive WebSocket support for real-time market data, order updates, and yield tracking. The WebSocket API enables building responsive trading applications with live data feeds.

Connection Details

WebSocket Endpoint

Connection Parameters

Message Format

All WebSocket messages use JSON format:

Message Fields

Public Data Streams

Ticker Stream

Real-time 24hr ticker statistics for all symbols.
Stream Name: ticker@{symbol} or !ticker@arr

Trade Stream

Real-time trade execution data.
Stream Name: trade@{symbol} or !trade@arr

Order Book Stream

Real-time order book depth updates.
Stream Names:
  • depth@{symbol} - Full order book
  • depth{levels}@{symbol} - Partial depth (5, 10, 20 levels)
  • depthUpdate@{symbol} - Incremental updates

Candlestick Stream

Real-time OHLCV candlestick data.
Intervals: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M

Private Data Streams

User Order Updates

Real-time updates for user orders.

Account Updates

Real-time balance and position updates.

Yield Updates

Real-time yield generation and rewards updates.

Implementation Examples

TypeScript WebSocket Client

Advanced Features

Rate Limiting

WebSocket connections are subject to rate limits:

Connection Management

Stream Aggregation

Combine multiple streams for complex analysis:

Error Handling

Common Error Codes

Robust Error Handling


Smart Contracts

Integrate with ScaleX smart contracts

API Reference

REST API for complementary data
The WebSocket API provides real-time access to all ScaleX DEX data streams. Combine with yield tracking to build applications that monitor both trading and earning opportunities in real-time.