WebSocket API Overview
Real-time streaming market data via WebSocket, including available channels, usage patterns, and quick start examples.
The WebSocket API provides real-time streaming market data from cryptocurrency exchanges. Connect once and receive continuous updates as market events occur, enabling low-latency applications like live dashboards, trading bots, and real-time analytics.
When to Use WebSocket vs REST
| Use Case | Recommended API |
|---|---|
| Historical data queries | REST |
| One-time data fetches | REST |
| Backfilling missing data | REST |
| Real-time price updates | WebSocket |
| Live trading dashboards | WebSocket |
| Automated trading bots | WebSocket |
| Streaming candle updates | WebSocket |
REST API is ideal for request-response patterns where you need specific data at a point in time.
WebSocket API is ideal for continuous data streams where latency matters and you need updates as they happen.
Available Channels
| Channel | Description | Requires Timeframe | Requires Bucket |
|---|---|---|---|
candles | Real-time OHLCVT candle updates | Yes | No |
trades | Individual trades as they occur | No | No |
depth | Orderbook depth updates (alias: orderbook) | No | No |
stats | Market statistics updates | Yes | No |
oi | Open interest updates | Yes | No |
vd | Volume delta updates | Yes | Yes |
volumes | Volume profile updates | Yes | No |
heatmap_sd | Standard density heatmap updates | Yes | No |
heatmap_hd | High density heatmap updates | Yes | No |
flat_heatmap_sd | Standard density flat heatmap updates | Yes | No |
flat_heatmap_hd | High density flat heatmap updates | Yes | No |
stop_heatmap | Stop heatmap updates (flat format, hyperliquid/hyperliquid-xyz only) | Yes | No |
tp_heatmap | Take-profit heatmap updates (flat format, hyperliquid/hyperliquid-xyz only) | Yes | No |
liquidation_heatmap | Liquidation heatmap updates (flat format, hyperliquid/hyperliquid-xyz only) | Yes | No |
liquidations | Liquidation events | No | No |
markets | Market overview data (price, 24h change, volume, market cap) | No | No |
Channel Details
-
candles - Streaming candlestick data with open, high, low, close, volume, and trade count. Updates on each trade within the timeframe.
-
trades - Every individual trade execution. Highest frequency stream, useful for tick-by-tick analysis.
-
depth - Orderbook state updates. Provides bid/ask levels for market depth visualization. You can also subscribe using
"orderbook"as an alias for"depth". -
stats - Per-timeframe market statistics including mark/funding, liquidations, orderbook depth skews, and TPS metrics.
-
oi - Open interest changes for futures/perpetual markets.
-
vd - Volume delta (buying vs selling pressure) bucketed by trade size ranges.
-
volumes - Volume profile data showing buy/sell volumes at price levels.
-
heatmap_sd - Standard density orderbook heatmap for market depth visualization.
-
heatmap_hd - High density orderbook heatmap with finer price granularity.
-
flat_heatmap_sd - Standard density flat heatmap, same data as
heatmap_sdin a flattened format optimized for rendering. -
flat_heatmap_hd - High density flat heatmap, same data as
heatmap_hdin a flattened format optimized for rendering. -
stop_heatmap - Stop heatmap stream in flat format. Single-exchange only (no aggregation). Available only on
hyperliquidandhyperliquid-xyz. -
tp_heatmap - Take-profit heatmap stream in flat format. Single-exchange only (no aggregation). Available only on
hyperliquidandhyperliquid-xyz. -
liquidation_heatmap - Liquidation heatmap stream in flat format. Single-exchange only (no aggregation). Available only on
hyperliquidandhyperliquid-xyz. -
liquidations - Real-time liquidation events from the exchange.
-
markets - Market overview data including current price, 24h price change, buy/sell volumes, and market cap information.
Key Differences from REST
| Aspect | REST API | WebSocket API |
|---|---|---|
| Data delivery | Pull (you request) | Push (server sends) |
| Rate limiting | Per-request limits | Connection limits only |
| Latency | Higher (HTTP overhead) | Lower (persistent connection) |
| Connection | Stateless | Stateful (must manage lifecycle) |
| Best for | Historical queries | Real-time streams |
No Polling Required
With WebSocket, you subscribe once and receive updates automatically. No need to repeatedly poll endpoints, reducing bandwidth and ensuring you never miss data between requests.
Connection Management
Unlike REST, WebSocket connections are persistent. Your application must:
- Handle connection drops and reconnect
- Resubscribe to channels after reconnection
- Process incoming messages asynchronously
Aggregated Exchanges
Use colon-separated exchange IDs to subscribe to aggregated streams on supported channels. The exchange IDs must be unique and alphabetically ordered (for example, binancef:bybitf). Invalid aggregate exchange strings are rejected with INVALID_EXCHANGE:
{
"type": "subscribe",
"channel": "stats",
"exchange": "binancef:bybitf",
"symbol": "btc/usd",
"tf": "1m"
}For aggregated stats streams, mp (mark price) and fr (funding rate) are emitted as 0.
stop_heatmap, tp_heatmap, and liquidation_heatmap do not support aggregated exchanges and must use a single exchange ID. They are available only for hyperliquid and hyperliquid-xyz.
Quick Example
Connect
wss://eu-central-1.mmt.gg/api/v1/ws?api_key=YOUR_KEYBy format:
format=json(default): messages are WebSocket text framesformat=cbor: messages are WebSocket binary frames
Available regions:
eu-central-1.mmt.gg
Subscribe to a Channel
Once connected, send a JSON message to subscribe:
{
"type": "subscribe",
"channel": "candles",
"exchange": "binancef",
"symbol": "btc/usd",
"tf": "1m"
}Receive Updates
The server will stream updates as they occur:
{
"type": "data",
"channel": "candles",
"exchange": "binancef",
"symbol": "btc/usd",
"tf": "1m",
"id": "candles.binancef.btc/usd.60",
"data": {
"t": 1704067200,
"o": 42150.5,
"h": 42175.0,
"l": 42140.0,
"c": 42165.5,
"vb": 1500000.00,
"vs": 1400000.00,
"tb": 1250,
"ts": 1180
}
}Unsubscribe
{
"type": "unsubscribe",
"channel": "candles",
"exchange": "binancef",
"symbol": "btc/usd",
"tf": "1m"
}Next Steps
- Connecting - Establishing and managing WebSocket connections
- Subscribing - Managing channel subscriptions
- Channels - All available data channels
- Connection Lifecycle - Reconnection and error handling
Get volume profile GET
Returns volume profile data with buy/sell volumes at each price level. Supports aggregated exchanges (requires tier permission). Cost multiplier: 4x. Max 20,000 data points per request.
Connecting
How to establish and authenticate WebSocket connections, including regional endpoints, connection limits, and response formats.