Hyperliquid Order Book WebSocket API
High-performance WebSocket server providing real-time Hyperliquid order book data with ultra-low latency. Stream trades, L2 aggregated books, and L4 individual orders.
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.
Estimate Your Usage
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. Supports optional user filtering to receive only trades involving a specific wallet address.
Ideal for:
- Volume-weighted average price (VWAP) calculations
- Trade flow and momentum analysis
- Execution quality monitoring
- Per-wallet trade tracking and fill 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 →
Data Flow Between Channels
The three subscription types serve different purposes and contain different data. Understanding which data lives where prevents common integration pitfalls.
Hyperliquid Node
|
|-- order_statuses --> L4 Book channel (status transitions: open, filled, canceled)
|-- book_diffs ------> L4 Book channel (order additions, removals, size changes)
|-- fills -----------> Trades channel (execution price, size, hash, wallets)
| L2 Book channel (aggregated from book state)Key point: Individual fill details (execution price, counterparty, transaction hash) are only available on the Trades stream. The L4 Book channel reports order status changes but not per-fill data. To track an order from placement through each fill to completion, subscribe to both L4 Book and Trades.
For a detailed walkthrough, see Understanding Order Data Flow in the L4 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/wsCode Examples Repository
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
Implement Reconnection Logic
The server may restart occasionally to resync order book state. Your client must include automatic reconnection with exponential backoff.
Initial Connection Behavior
During the first few seconds after connecting, the WebSocket handshake and subscription setup may cause a brief delay before data starts flowing. If you compare streams from two different endpoints, trades observed by one source but not the other in the first 5-10 seconds are due to connection timing, not event loss. After the initial handshake period, both streams deliver identical data.
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: support@dwellir.com
- Dashboard: dashboard.dwellir.com
Access institutional-grade Hyperliquid market data with Dwellir's ultra-low latency WebSocket infrastructure.