GetRawBookDiffs - Get Book Diff Data
Retrieve order book diffs at a specific position from Hyperliquid L1 Gateway via gRPC. Get incremental book changes for analysis and reconstruction.
Retrieve order book diffs at a specific position from the Hyperliquid L1 Gateway.
Full Code Examples
Clone our gRPC Code Examples Repository for complete, runnable implementations in Go, Python, and Node.js.
When to Use This Method
GetRawBookDiffs is essential for:
- Targeted Reconstruction - Pull the book changes for a specific block
- Historical Analysis - Retrieve diffs for backtesting or reporting
- Auditing - Verify resting-book changes at a specific block
- Debugging - Investigate specific book transitions during development
Method Signature
rpc GetRawBookDiffs(Position) returns (BlockRawBookDiffs) {}Common Use Cases
1. Inspect a Single Block
def get_block_diffs(client, metadata, block_height):
request = hyperliquid_pb2.Position(block_height=block_height)
response = client.GetRawBookDiffs(request, metadata=metadata)
block = json.loads(response.data)
for event in block.get('events', []):
print(event['coin'], event['oid'], event['raw_book_diff'])2. Replay a Block Range
def replay_diffs(client, metadata, start_block, end_block):
for block_height in range(start_block, end_block + 1):
request = hyperliquid_pb2.Position(block_height=block_height)
response = client.GetRawBookDiffs(request, metadata=metadata)
apply(json.loads(response.data))Book Diff Field Reference
GetRawBookDiffs returns the same format as StreamRawBookDiffs. See the StreamRawBookDiffs documentation for the complete field reference, including the three raw_book_diff shapes and order-identifier keying.
Best Practices
- Position Selection: Use block height for precise queries; timestamps may resolve to different blocks across requests
- Stable Keys: Index resting orders on
(coin, oid), never onoidalone - Data Validation: Always validate JSON structure and branch on the
raw_book_diffshape - Error Recovery: Implement retry logic with exponential backoff
- Resource Management: Close gRPC connections properly to avoid resource leaks
Current Limitations
- Backfill Window: Positions outside the node's retained on-disk feed are not available; an unconfigured feed directory returns
NotFound - Rate Limits: Be mindful of request frequency to avoid overwhelming the service
Resources
- GitHub: gRPC Code Examples - Complete working examples
- StreamRawBookDiffs Documentation - Full book diff specification and streaming examples
- Archival Data - Historical
node_raw_book_diffs_by_blockdownloads
Need help? Contact our support team or check the Hyperliquid gRPC documentation.
GetOrderStatuses - Get Order Status Data
Retrieve order status events at a specific position from Hyperliquid L1 Gateway via gRPC. Get order lifecycle data for analysis and auditing.
StreamBlocks - Real-time Block Streaming
Stream continuous block data from Hyperliquid L1 Gateway via gRPC. Complete reference for all 47 action types.