Hyperliquid Order Book WebSocket API
Dwellir provides a high-performance WebSocket server delivering real-time order book data from Hyperliquid with ultra-low latency. This service offers direct node connectivity, significantly faster than public API endpoints.
Not sure which plan fits your trading strategy? Use our Volume Calculator to estimate monthly message volume and get a personalized pricing recommendation.
Watch the WebSocket Walkthrough#
Available Subscription Types#
The WebSocket API provides three distinct data streams, each designed for specific use cases:
| Subscription | Data Type | Best For |
|---|---|---|
| Trades | Real-time trade executions | Trade flow analysis, VWAP calculation, execution monitoring |
| L2 Order Book | Aggregated price levels | Spread analysis, market making, liquidity assessment |
| L4 Order Book | Individual orders | Queue position tracking, whale watching, microstructure analysis |
Trades Stream#
Stream real-time trade executions as they occur on Hyperliquid. Each trade includes price, size, direction, and participant addresses.
Ideal for:
- Volume-weighted average price (VWAP) calculations
- Trade flow and momentum analysis
- Execution quality monitoring
- Historical trade data collection
L2 Order Book (Level 2)#
Aggregated order book data showing total size at each price level. Supports configurable depth and price aggregation for bandwidth optimization.
Ideal for:
- Bid-ask spread monitoring
- Market making strategies
- Liquidity depth analysis
- Support/resistance level detection
View L2 Order Book Documentation →
L4 Order Book (Level 4)#
The most detailed market data available - individual order visibility with user addresses, order IDs, timestamps, and full order parameters.
Ideal for:
- Queue position optimization
- Whale wallet tracking
- Market microstructure research
- Order flow toxicity analysis
View L4 Order Book Documentation →
Key Features#
- Ultra-low latency - Direct node connectivity eliminates public API overhead
- Full market depth - Access to L4 data with individual order visibility
- Real-time streaming - WebSocket push model for immediate updates
- Efficient compression - Optimized bandwidth usage for high-frequency data
- Institutional grade - Professional infrastructure with monitoring and support
Performance Benchmarks#
Based on real-world benchmarking of 2,662 matched trades:
| Metric | Public API | Dwellir WebSocket | Improvement |
|---|---|---|---|
| Median Latency | 263ms | 212ms | 51ms faster (24%) |
| Mean Latency | 368ms | 339ms | 29ms faster (8%) |
| Max Latency | 9,118ms | 1,977ms | 7,141ms faster |
Win rate: WebSocket delivers data faster in 75.5% of cases.
Quick Start#
Connect to the WebSocket endpoint and subscribe to your desired data streams:
wss://<your-instance>.dwellir.com/ws
- Python
- JavaScript
import asyncio
import json
import websockets
async def main():
ws_url = "wss://your-instance.dwellir.com/ws"
async with websockets.connect(ws_url) as websocket:
# Subscribe to BTC trades
await websocket.send(json.dumps({
"method": "subscribe",
"subscription": {"type": "trades", "coin": "BTC"}
}))
# Listen for messages
async for message in websocket:
data = json.loads(message)
print(f"Received: {data}")
if __name__ == "__main__":
asyncio.run(main())
const WebSocket = require('ws');
const ws = new WebSocket('wss://your-instance.dwellir.com/ws');
ws.on('open', () => {
// Subscribe to BTC trades
ws.send(JSON.stringify({
method: 'subscribe',
subscription: { type: 'trades', coin: 'BTC' }
}));
});
ws.on('message', (data) => {
const message = JSON.parse(data);
console.log('Received:', message);
});
Clone our complete examples: github.com/dwellir-public/hyperliquid-orderbook-server-code-examples
Message Protocol#
Subscribe to Data Stream#
{
"method": "subscribe",
"subscription": {
"type": "trades", // or "l2Book" or "l4Book"
"coin": "BTC"
// Additional parameters vary by type
}
}
Unsubscribe from Data Stream#
{
"method": "unsubscribe",
"subscription": {
// Same subscription object used to subscribe
}
}
Server Responses#
Subscription Confirmation:
{
"channel": "subscriptionResponse",
"data": {
"method": "subscribe",
"subscription": { /* echoed subscription */ }
}
}
Error Messages:
{
"channel": "error",
"data": "Descriptive error message"
}
Common errors include: "coin not found", "n_levels too high", "Already subscribed", "Order book not ready".
Use Cases by Industry#
Quantitative Trading#
| Use Case | Recommended Stream | Why |
|---|---|---|
| High-frequency trading | L4 Book | Queue position optimization |
| Statistical arbitrage | L2 Book + Trades | Cross-market spread analysis |
| Momentum strategies | Trades | Trade flow direction |
Market Making#
| Use Case | Recommended Stream | Why |
|---|---|---|
| Spread management | L2 Book | Real-time bid/ask monitoring |
| Inventory risk | L4 Book | See competing orders |
| Quote adjustment | Trades | Execution feedback |
Analytics & Research#
| Use Case | Recommended Stream | Why |
|---|---|---|
| Market microstructure | L4 Book | Individual order analysis |
| Liquidity studies | L2 Book | Depth at price levels |
| Volume analysis | Trades | Complete trade history |
Connection Best Practices#
The server may restart occasionally to resync order book state. Your client must include automatic reconnection with exponential backoff.
class RobustWSClient:
def __init__(self, ws_url):
self.ws_url = ws_url
self.reconnect_delay = 1
self.max_delay = 60
async def connect_with_retry(self):
while True:
try:
async with websockets.connect(self.ws_url) as ws:
self.reconnect_delay = 1 # Reset on success
await self.handle_connection(ws)
except Exception as e:
print(f"Connection error: {e}")
await asyncio.sleep(self.reconnect_delay)
self.reconnect_delay = min(self.reconnect_delay * 2, self.max_delay)
Get Started#
Hosted WebSocket Service#
Dwellir offers production-ready WebSocket servers with:
- Direct node connectivity - Fastest possible data access
- Geographic distribution - Servers in Singapore and Tokyo
- 99.99% uptime SLA - Enterprise reliability
- Dedicated support - Direct access to engineering team
Resources#
- Volume Calculator - Estimate your monthly usage
- Code Examples - Production-ready implementations
- Pricing - Plans for every scale
Contact Us#
Ready to integrate ultra-low latency Hyperliquid data?
- Email: ben@dwellir.com
- Dashboard: dashboard.dwellir.com
Access institutional-grade Hyperliquid market data with Dwellir's ultra-low latency WebSocket infrastructure.