# Hyperliquid
## Venue and constructor
| `HyperliquidAdapter::new()` | Mainnet |
| `HyperliquidAdapter::testnet()` | Testnet |
One adapter exposes Spot and the default perpetual DEX.
| Spot | `spotMeta` | Included; non-USDC quote assets included |
| Default perpetual DEX | `meta` without `dex` | `MarketKind::Perpetual` |
| HIP-3 perpetual DEX | `perpDexs`, `meta` with `dex` | Not exposed |
| Outcome assets | `outcomeMeta` | Not exposed |
The adapter caches `meta` and `spotMeta` on first use. Create a new adapter to
reload listings. Spot metadata uses `spotMeta.universe[].name`; stream frames
may use that name or `@{index}`. Use the returned `MarketInfo::native_symbol`.
## REST
| `markets(kind)` | `meta`, `spotMeta` | Markets in the support table |
| `trades(market, limit)` | `recentTrades` | `limit: 1..=10`; no provider count parameter; `None -> provider page (<= 10)`; `Some(limit)` truncates locally; newest-first |
| `order_book(market, depth)` | `l2Book` | `depth: 1..=20`; at most `depth` levels per side; local truncation |
| `ticker(market)` | `metaAndAssetCtxs`, `spotMetaAndAssetCtxs` | Reference-price summary |
| `funding_rates(request)` | `fundingHistory` | Public; Perpetual only; provider page `<= 500` |
| `all_mids()` | `POST /info` with `{"type":"allMids"}` | Public; default perpetual DEX and first-DEX Spot mids; empty books use the last trade price as fallback |
| `from`, `to` | `from <= timestamp < to` |
| `startTime` | `ceil_ms(from)` |
| `endTime` | `ceil_ms(to) - 1` |
| `cursor` | Opaque resume point; overrides `from` |
| `limit` | Local page-size target; one millisecond group is never split, so `items.len()` may be below or above `limit` |
| `limit == 0` | `Error::InvalidRequest` before credential checks or network I/O |
| Continuation | Set `cursor = page.next` until `page.next == None` |
Ticker mapping:
| `last_price` | `midPx ?? markPx`; not the latest execution price |
| `last_trade_time` | `None` |
| `timestamp` | Local read time |
| `change` | `last_price - prevDayPx` |
| `change_rate` | `(last_price - prevDayPx) / prevDayPx`; `prevDayPx == 0 -> None` |
Use `trades` or `Feed::Trades` for execution prices and times.
## Candles
| Exposed intervals | `Min1`, `Min3`, `Min5`, `Min15`, `Min30`, `Hour1`, `Hour2`, `Hour4`, `Hour8`, `Hour12`, `Day1`, `Day3`, `Week1`, `Month1` |
| `Sec1` | `Error::Unsupported` |
| Retention | Latest 5,000 candles per interval |
| `Month1` grid | Fixed 30 days |
| `quote_volume` | `None` |
## Streams
| `Feed::Trades` | `trades` | Executions with provider timestamps |
| `Feed::OrderBook` | `l2Book` | Full snapshot; up to 20 levels per side; no diffs |
| `Feed::Ticker` | `activeAssetCtx` | REST ticker mapping |
| `Feed::Candles(interval)` | `candle` | Forming and closed candles |
| `new.open_time > held.open_time` | `held(closed = true)`, then `new(closed = false)` |
| `new.open_time == held.open_time` | Replace `held`; emit `new(closed = false)` |
| `new.open_time < held.open_time` | Drop frame |
| Reconnect | Drop `held`; no cross-connection close event |
The adapter sends `{"method":"ping"}` every 15 seconds. `l2Book.nSigFigs` and
`l2Book.mantissa` are not exposed.
## Private and provider-specific APIs
Configure private calls with `.with_wallet(address, private_key)`. Wallet values
are validated on the first private call; `Client::supports` treats the feature
as configured as soon as a wallet is present. The private key is used only for
local signing and is redacted from `Debug`.
| Spot | Balances, open orders, place/cancel order, account stream |
| Perpetual | Spot features plus positions, margin summary/configuration, funding payments, and reduce-only orders |
`positions()` returns all open perpetual positions;
`positions_on(spot) == Ok(vec![])`.
| `order_type` | `Limit`; `Market -> Error::Unsupported` |
| `size` | `Size::Base`; `size > 0` |
| `price` | `price > 0`; max decimal places: Perpetual `6 - szDecimals`, Spot `8 - szDecimals`; non-integer prices: `significant_figures <= 5`; integer prices exempt |
| `time_in_force` | `GTC`, `IOC`, `PostOnly`; `FOK -> Error::Unsupported` |
| `reduce_only` | `MarketKind::Perpetual` only |
| Minimum notional | Provider validation; no `maxt` preflight validation |
| Fields | `leverage.is_some() && margin_mode.is_some()` |
| `leverage` | Positive integer; `leverage <= asset.max_leverage` |
| `margin_mode == Cross` | `Error::InvalidRequest` when `asset.only_isolated == true` |
Access the following provider-specific methods through `Client::adapter()`:
| `asset_context(&market)` | Mid, mark, oracle, funding, open interest, and order precision |
| `non_funding_ledger(from, to, cursor, limit)` | Deposits, withdrawals, transfers, and liquidations; funding excluded; wallet required; provider page `<= 500` |
`all_mids()` is a public, read-only snapshot and is fixture-verified; live reads
have not been verified. The provider's default empty `dex` selects the first
perpetual DEX, and Spot mids are included only for that DEX. If a book is empty,
Hyperliquid uses the last trade price.
| `from`, `to` | Provider millisecond range `from_ms <= time <= to_ms` |
| `cursor` | Opaque resume point; overrides `from` |
| `limit` | Local page-size target; one millisecond group is never split, so `items.len()` may be below or above `limit` |
| `limit == 0` | `Error::InvalidRequest` before credential checks or network I/O |
| Continuation | Set `cursor = page.next` until `page.next == None` |
Unknown ledger `type` strings are preserved as
`HyperliquidLedgerKind::Other(provider_name)` instead of being collapsed to a
generic value.
## Limits and official links
| REST | 1,200 aggregate request weight per minute per IP |
| WebSocket connections | 10 concurrent; 30 new per minute |
| WebSocket subscriptions | 1,000 |
| WebSocket messages sent | 2,000 per minute across all connections |
`l2Book` weight is 2. A generic `info` request weight is 20.
`candleSnapshot` adds weight per 60 returned items. `maxt` does not throttle
requests.
HIP-3, outcome assets, `Sec1`, market orders, `FOK`, `l2Book.nSigFigs`, and
`l2Book.mantissa` are not exposed.
- [API overview](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api)
- [Info endpoint](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint)
- [All mids (`allMids`)](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint)
- [Perpetual info](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals)
- [Spot info](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot)
- [WebSocket subscriptions](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions)
- [Rate limits](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/rate-limits-and-user-limits)
[Common API](../common-api.md) · [Provider support](../providers.md)