Trades Stream - Real-Time Trade Executions
Stream real-time trade executions from Hyperliquid with ultra-low latency. Access price, size, direction, and participant data for every trade.
Stream real-time trade executions as they occur on Hyperliquid. Each trade message contains the execution price, size, direction (buy/sell), timestamp, and participant wallet addresses.
Code Examples Repository
Clone our complete examples: github.com/dwellir-public/hyperliquid-orderbook-server-code-examples
How to Subscribe
Send a subscription message to the WebSocket endpoint:
{
"method": "subscribe",
"subscription": {
"type": "trades",
"coin": "BTC"
}
}Subscription Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Must be "trades" |
coin | string | Yes | Trading pair symbol (e.g., "BTC", "ETH", "xyz:MSTR", "@150") |
user | string | No | Filter trades to only those involving a specific wallet address (e.g., "0xabc...") |
HIP3 Markets
For HIP3 (permissionless perpetuals) markets, use the full coin label format with the xyz: prefix. For example, use "xyz:MSTR" for the MicroStrategy perpetual, not just "MSTR". Standard perpetuals like BTC and ETH do not require a prefix.
Spot Markets
For spot markets, use the @{index} format where the index is the spot asset index. For example, use "@150" for a specific spot market.
User Filtering
You can filter the trades stream to only receive trades involving a specific wallet address. This is useful for tracking your own executions or monitoring a specific trader's activity without processing the full trade firehose.
{
"method": "subscribe",
"subscription": {
"type": "trades",
"coin": "BTC",
"user": "0x1ed8d101622beaf192d06137dfb220851bcad9fa"
}
}When the user field is provided, only trades where the specified address appears in the users array (as either buyer or seller) are delivered. The user field is optional — omitting it returns all trades for the coin, as before.
The first websocket message after subscribing is a subscriptionResponse; subsequent messages carry the trades channel payloads.
Response Field Reference
| Field | Type | Description |
|---|---|---|
channel | string | Always "trades" for this subscription type |
data | array | Array of trade objects (may contain multiple trades per message) |
coin | string | Trading pair symbol |
side | string | "A" = Ask (sell/taker sold), "B" = Bid (buy/taker bought) |
px | string | Execution price |
sz | string | Trade size in base currency |
time | number | Unix timestamp in milliseconds |
hash | string | Transaction hash on Hyperliquid. Zero-hash (0x000...000) indicates a TWAP fill with no on-chain transaction. |
tid | number | Unique trade ID |
users | array | Array of two wallet addresses: [buyer, seller] |
Understanding the side Field
The side field indicates which side of the order book the trade executed against:
"A"(Ask): The taker sold into the bid. A market sell order matched with a resting buy order."B"(Bid): The taker bought from the ask. A market buy order matched with a resting sell order.
Use Cases
Trade Flow Analysis
Monitor real-time trade executions to understand market momentum:
- Direction detection: Track whether buyers or sellers are dominating
- Large trade alerts: Identify whale activity by filtering on size
- Execution timing: Measure latency between your orders and confirmations
VWAP and TWAP Calculations
Build execution benchmarks from the trade stream:
- VWAP: Volume-weighted average price for execution quality analysis
- TWAP: Time-weighted average price for order slicing strategies
- Implementation shortfall: Compare your fills against market VWAP
Historical Trade Recording
Capture trade data for backtesting and research:
- Tick data collection: Store every trade for historical analysis
- Pattern recognition: Train ML models on trade sequences
- Market replay: Reconstruct market conditions for strategy testing
Wallet Tracking
Use the users field to monitor specific addresses. For dedicated tracking, use the user subscription filter to receive only trades involving a specific wallet — this is more efficient than filtering client-side.
- Whale watching: Alert when known large traders execute
- Copy trading signals: Track successful trader activity
- Smart money flow: Analyze institutional wallet behavior
- Execution monitoring: Track your own fills by filtering on your wallet address
Zero-Hash Trades (TWAP Fills)
Some trades on Hyperliquid carry a zero transaction hash:
0x0000000000000000000000000000000000000000000000000000000000000000These are typically TWAP (Time-Weighted Average Price) fills. TWAP orders split large executions into smaller slices over time. The matching engine generates these fills internally, so they do not correspond to user-signed L1 transactions and have no on-chain hash.
Zero-hash trades are valid executions with accurate price, size, and participant data. Only the hash field differs from regular trades.
This is native Hyperliquid behavior
Zero-hash trades appear at identical rates on the public Hyperliquid API. Dwellir passes through the hash field from the Hyperliquid node without modification.
Subscription Management
Multiple Coin Subscriptions
Subscribe to multiple trading pairs on a single connection:
coins = ["BTC", "ETH", "SOL", "ARB"]
for coin in coins:
await websocket.send(json.dumps({
"method": "subscribe",
"subscription": {
"type": "trades",
"coin": coin
}
}))Unsubscribe
Stop receiving trades for a specific coin:
{
"method": "unsubscribe",
"subscription": {
"type": "trades",
"coin": "BTC"
}
}Get Access
Ready to integrate real-time Hyperliquid trade data?
- Volume Calculator - Estimate monthly message volume
- Contact Sales - Get your WebSocket credentials
- Dashboard - Manage your subscription
Stream institutional-grade Hyperliquid trade data with Dwellir's ultra-low latency infrastructure.
L4 Order Book
Stream Level 4 order book data from Hyperliquid with individual order visibility. Access user addresses, order IDs, timestamps, and full order parameters.
Quick Reference
Quick reference for the Hyperliquid Order Book WebSocket API. Connection details, message formats, and links to detailed documentation.