Skip to main content

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.

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:

SubscriptionData TypeBest For
TradesReal-time trade executionsTrade flow analysis, VWAP calculation, execution monitoring
L2 Order BookAggregated price levelsSpread analysis, market making, liquidity assessment
L4 Order BookIndividual ordersQueue 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

View Trades Documentation →

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:

MetricPublic APIDwellir WebSocketImprovement
Median Latency263ms212ms51ms faster (24%)
Mean Latency368ms339ms29ms faster (8%)
Max Latency9,118ms1,977ms7,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
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())
Code Examples Repository

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 CaseRecommended StreamWhy
High-frequency tradingL4 BookQueue position optimization
Statistical arbitrageL2 Book + TradesCross-market spread analysis
Momentum strategiesTradesTrade flow direction

Market Making#

Use CaseRecommended StreamWhy
Spread managementL2 BookReal-time bid/ask monitoring
Inventory riskL4 BookSee competing orders
Quote adjustmentTradesExecution feedback

Analytics & Research#

Use CaseRecommended StreamWhy
Market microstructureL4 BookIndividual order analysis
Liquidity studiesL2 BookDepth at price levels
Volume analysisTradesComplete 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.

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#

Contact Us#

Ready to integrate ultra-low latency Hyperliquid data?


Access institutional-grade Hyperliquid market data with Dwellir's ultra-low latency WebSocket infrastructure.