Pull Hyperliquid L2 books, trades, and funding-rate history with AymarData — API patterns, Python examples, and research tips.
Hyperliquid historical data and funding rates
Hyperliquid is an on-chain perpetual futures venue with public market data feeds for trades, L2 books, and funding. AymarData records that stream so you can query historical books and study funding alongside CEX perps. This guide covers source ids, coin symbols, book/trade pulls, and how funding fits into research workflows.
Hub: Hyperliquid data. Glossary: funding rate, mark price, open interest.
Status and source id
API source value: hyperliquid.
Collectors may run while marketing status is still Coming until reliability gates clear (for example 24h with zero drops). Confirm live symbols and history_from via /v1/markets and the hub page before large jobs. Sources & markets lists current status language. Collector scope includes public websocket trades, L2, and funding — see Changelog as schemas expand.
When Hyperliquid is the right source
| Goal | Prefer | Companion |
|---|---|---|
| On-chain perp microstructure | hyperliquid | — |
| CEX vs DEX perp basis | hyperliquid + binance-perps | Binance hub |
| Hedge cost for Polymarket crypto | either + books | Polymarket |
Discover coins / markets
export AYMARDATA_API_KEY=ad_live_YOUR_KEY
curl -s "https://api.aymardata.com/v1/markets" \
-H "Authorization: Bearer $AYMARDATA_API_KEY" \
-G \
--data-urlencode "source=hyperliquid" \
--data-urlencode "q=BTC" \
--data-urlencode "limit=20"
Market identifiers align with coin symbols used on data pages (for example BTC). Use the exact market string returned by the API in subsequent calls. Do not assume Binance-style BTCUSDT tickers on Hyperliquid — vocabulary differs by venue.
Historical L2 books
curl -s "https://api.aymardata.com/v1/book" \
-H "Authorization: Bearer $AYMARDATA_API_KEY" \
-G \
--data-urlencode "source=hyperliquid" \
--data-urlencode "market=BTC" \
--data-urlencode "at=2026-10-22T14:30:00Z" \
--data-urlencode "depth=25"
import os
import requests
API = "https://api.aymardata.com/v1"
H = {"Authorization": f"Bearer {os.environ['AYMARDATA_API_KEY']}"}
def hl_book(market: str, at: str, depth: int = 25):
r = requests.get(
f"{API}/book",
headers=H,
params={"source": "hyperliquid", "market": market, "at": at, "depth": depth},
timeout=30,
)
r.raise_for_status()
return r.json()
Replay with deltas the same way as Binance — seed a snapshot, apply /v1/book/deltas in seq order. See Binance download and replay for a full apply loop you can reuse with source=hyperliquid.
Field interpretation
Books use the shared schema: bids, asks, spread, ts_exchange, ts_recv. Thin coins may show sparse levels and infrequent deltas; validate continuity before trusting high-frequency features. Empty sides should skip mid calculation. Outcome parameters are not used for standard perp books.
Endpoint selection
- Point-in-time mid/spread →
/v1/book?at= - Path replay → snapshot +
/v1/book/deltas - Multi-day offline →
/v1/fileswhen partitions exist (Bulk)
Trades
def hl_trades(market: str, start: str, end: str, limit: int = 500):
r = requests.get(
f"{API}/trades",
headers=H,
params={
"source": "hyperliquid",
"market": market,
"start": start,
"end": end,
"limit": limit,
},
timeout=60,
)
r.raise_for_status()
return r.json()["data"]
Paginate when limits truncate. Use trades to sanity-check reconstructed top-of-book and to estimate aggressor flow for inventory-skew models.
Funding rates in context
Perpetual funding periodically transfers value between longs and shorts so the perp tracks the underlying. Positive funding usually means longs pay shorts; negative reverses the flow. Exact conventions (interval, payment formula) are venue-specific — always read Hyperliquid’s docs for settlement math and treat AymarData fields as recorded observations for analytics.
Research uses for funding history:
- Carry / basis models — compare Hyperliquid funding to Binance perps funding around the same hour
- Inventory skew — relate funding sign to book imbalance and trade aggressor flow
- Prediction-market hedges — when trading Polymarket Up/Down, funding on the crypto hedge affects net P&L
When funding series are exposed via market metadata, settlement-adjacent payloads, or bulk partitions, join them on market + timestamp. If a field is not yet in your plan’s schema, fall back to documented venue endpoints for live funding while using AymarData for L2/trades history — and watch Changelog for schema additions. Do not invent funding columns in notebooks that are not present in API responses.
# Illustrative: pull books around a funding hour and store mid + spread
from datetime import datetime, timezone, timedelta
def sample_around(market: str, hour_iso: str):
book = hl_book(market, hour_iso, depth=5)
if not book["bids"] or not book["asks"]:
return {"ts": hour_iso, "mid": None}
bid, ask = book["bids"][0]["price"], book["asks"][0]["price"]
return {
"ts": hour_iso,
"mid": (bid + ask) / 2,
"spread": book["spread"],
"bid_sz": book["bids"][0]["size"],
"ask_sz": book["asks"][0]["size"],
}
def funding_hour_grid(market: str, day: str, hour_step: int = 1):
"""day like 2026-10-22; samples book state on the hour."""
base = datetime.fromisoformat(f"{day}T00:00:00+00:00")
rows = []
for h in range(0, 24, hour_step):
ts = (base + timedelta(hours=h)).strftime("%Y-%m-%dT%H:%M:%SZ")
rows.append(sample_around(market, ts))
return rows
print(sample_around("BTC", "2026-10-22T16:00:00Z"))
Funding research pitfalls
- Aligning Hyperliquid funding timestamps to Binance funding hours without converting timezones
- Treating funding sign as a directional price forecast without controlling for mark–index basis
- Ignoring that thin coins may have irregular or missing funding observations during Coming phases
- Double-counting funding when both the hedge and the prediction-market fees already drag P&L
Mark price and open interest
Mark price is the reference used for liquidations and often for funding calculations. Open interest measures outstanding perp contracts. When these appear in AymarData market or analytics payloads, store them beside L2 mids. Until then, label external joins clearly so notebooks stay reproducible.
Cross-venue notebook sketch
def compare_mids(at: str):
hl = hl_book("BTC", at, depth=1)
r = requests.get(
f"{API}/book",
headers=H,
params={"source": "binance-perps", "market": "BTCUSDT", "at": at, "depth": 1},
timeout=30,
)
r.raise_for_status()
bn = r.json()
def mid(b):
if not b["bids"] or not b["asks"]:
return None
return (b["bids"][0]["price"] + b["asks"][0]["price"]) / 2
return {"hyperliquid": mid(hl), "binance_perp": mid(bn), "at": at}
Extend with Polymarket btc-updown-15m mids for ternary feature sets. Keep symbol maps explicit (BTC vs BTCUSDT).
Bulk files
curl -s "https://api.aymardata.com/v1/files" \
-H "Authorization: Bearer $AYMARDATA_API_KEY" \
-G \
--data-urlencode "source=hyperliquid" \
--data-urlencode "prefix=BTC"
Prefer files for multi-day funding/book joins (Bulk). Empty listings with working REST usually mean bulk partitions are not published yet for that prefix/date on your plan.
Practical cautions
- On-chain and L2 clocks can differ from CEX clocks — align deliberately
- Thin coins may show sparse deltas; validate continuity
- Coming → Live transitions can extend
history_fromsuddenly; pin date ranges in configs - Respect rate limits and license terms
- Resync replay after sequence gaps the same way as Binance (deltas guide)
Funding as a cost center, not a signal factory
It is tempting to treat funding sign flips as standalone trading signals. In practice, funding is a periodic transfer that interacts with basis, inventory, and liquidation risk. A research notebook that regresses next-hour returns on current funding without controlling for mark–index dislocation will overfit regime changes. Prefer to book funding as a cashflow line in a hedge P&L: when you are long the perp as a Polymarket hedge, positive funding is a cost; when short, it may be income. That framing keeps prediction-market studies honest about net edge after crypto carry.
Because Hyperliquid market ids differ from Binance tickers, maintain an explicit map (for example BTC → BTCUSDT on binance-perps) in config rather than string-replacing ad hoc. When a coin is Live on Hyperliquid but missing on your Binance universe (or the reverse), record a null join instead of silently dropping the day. Coverage transitions during Coming phases are especially noisy: pin history_from floors in config so yesterday’s notebook does not quietly lengthen its sample when collectors catch up.
For microstructure features, validate delta continuity on each coin you care about. Major coins often look Binance-like; long-tail coins can show multi-second gaps that break naive seq assertions if you chunk poorly. Start with snapshot grids for thin coins, then graduate to deltas once a pilot hour shows dense updates. The Binance replay guide remains the template for apply logic; only the source and market strings change.
Checklist before a multi-day Hyperliquid job
- Confirm status and symbols on /data/hyperliquid and Sources & markets.
- Discover exact
marketstrings via/v1/markets; do not assume USDT-suffixed ids. - Canary a book, a short delta replay, and a trades pull for one liquid coin.
- Decide how funding fields will enter the warehouse if present — or how external joins will be labeled if not.
- Align any CEX comparison series on exchange timestamps.
- Prefer bulk files for multi-day scans when your plan includes them.
Putting books, trades, and funding in one ledger
A clean Hyperliquid research ledger has three rows of truth for each timestamp bucket you care about: L2 state (mid, spread, imbalance), trade aggregates (volume, VWAP, aggressor imbalance), and funding cashflow when the schema exposes it. Build those columns independently, then join on market + bucket start. If funding is missing for a bucket, leave it null; do not forward-fill across days without labeling the fill. Forward-filled funding creates fictional cashflows that look like alpha in backtests.
The same ledger should record data-quality flags: empty book, seq gap, sparse trades, or external funding join. Downstream models can filter on flags without you rewriting pulls. When comparing to Binance perps, add basis columns only after both books exist for the bucket; otherwise you will study missingness patterns and mistake them for market structure. For prediction-market overlays, attach Polymarket mids in a fourth namespace rather than overwriting crypto columns — see the Polymarket hub for family slugs.
FAQ
Same API as Binance?
Same endpoint shapes; different source and market ids. Start from Quickstart.
MCP?
Yes — MCP and AI agent backtesting guide.
Is funding a guaranteed REST column today?
Use whatever your plan’s schema returns; do not assume columns. L2 and trades are the stable core while funding packaging continues to expand — track Changelog.
Pricing
Pricing for multi-source plans once Hyperliquid is enabled on your account.
Educational content, not trading or investment advice. Past data doesn't predict future results.