spotTwapSnapshot
Endpoint to get all active TWAP orders across all Hyperliquid spot markets.
💧New endpoint - this endpoint is not a part of original Hyperliquid API and is added by us for builder convenience.
Overview
spotTwapSnapshot endpoint allows you to access all active TWAP (Time-Weighted Average Price) orders on Hyperliquid spot markets. TWAPs are algorithmic orders that execute over time, splitting large orders into smaller pieces.
There are two ways to access the data:
Metadata Endpoint (Fast): Check for updates without downloading data
Snapshots Endpoint (Heavy): Download actual TWAP snapshot data
Efficient polling pattern
To minimize bandwidth and server load, you should:
Poll the metadata endpoint to check for updates
Only call the snapshots endpoint when data has changed
Cache the snapshot ID locally to avoid unnecessary downloads
Dependencies and best practices
Dependencies
JavaScript
zstd: For decompression (e.g.,
fzstd,@gera2ld/zstd)msgpack: For decoding (e.g.,
@msgpack/msgpack)
Python
zstd: For decompression (e.g.,
zstandard)msgpack: For decoding (e.g.,
msgpack)aiohttp: For async HTTP requests
Error handling
404: No TWAP snapshots are available yet. Wait and retry.
500: A server error occurred. Retry with exponential backoff.
Network errors: Implement retry logic with jitter to avoid overwhelming the server.
Parse errors: Log the issue and continue using cached data if available.
Spot TWAP Snapshot Metadata (Fast)
Endpoint:
POST /infoPurpose: Check if TWAP snapshots have been updated
Response Time: ~1ms
Request
Response
Spot TWAP Snapshots (Heavy)
Endpoint:
POST /infoPurpose: Download TWAP snapshot data
Response Time: ~50ms+
Request
Query Options
Specific tokens:
["HYPE", "PURR"]-> Specific spot tokens["@107"]-> By spot index["HYPE/USDC"]-> By pair name
All tokens:
["ALL"]-> All spot tokens with active TWAPs
Response Headers
Single Token:
x-payload-format: msgpack,Content-Encoding: zstdMultiple Tokens:
x-payload-format: multi-zstd,x-compression: inner-zstd
Data Format
Single Token Response
Format: Raw zstd-compressed MessagePack data
Decompressed Structure:
Snapshot Array Format:
0
snapshot_id
Snapshot identifier
1
token_name
Token name (e.g., "HYPE", "PURR")
2
twaps
Array of TWAP tuples
TWAP Tuple Format:
0
address
User address (hex string)
1
twap_id
TWAP ID (unique per user)
2
asset
Asset symbol (e.g., "HYPE", "PURR")
3
is_buy
Direction: true = buy, false = sell
4
total_sz
Total size to execute (normalized)
5
executed_sz
Size already executed (normalized)
6
remaining_sz
Remaining size (total_sz - executed_sz)
7
executed_ntl
Notional value executed (USD)
8
progress_pct
Progress percentage (0-100)
9
duration_secs
Total TWAP duration in seconds
10
start_time_ms
TWAP creation timestamp (milliseconds since epoch)
11
reduce_only
Whether TWAP is reduce-only (boolean)
12
randomize
Whether execution timing is randomized (boolean)
13
next_slice_time
Next slice execution time (ISO timestamp string)
14
slice_number
Current slice number in execution
15
market_name
Spot market index (e.g., "@107", "@232")
16
market_readable
Human-readable pair name (e.g., "HYPE/USDC", "HYPE/USDH")
Multiple Tokens Response
Format: Custom binary format with length prefixes
Binary Structure:
Each zstd_data blob, when decompressed, contains a single token's TWAP snapshot in the same array format as the single token response.
Implementation Examples
Note: Make sure to set HYDROMANCER_API_KEY in your .env file
Last updated