DEV Community

Cover image for Hyperliquid API Explained: Endpoints, Signing, Rate Limits and SDKs
Hanson for Hyperdash

Posted on Originally published at hyperdash.com

Hyperliquid API Explained: Endpoints, Signing, Rate Limits and SDKs

Originally published on the Hyperdash blog.

The Hyperliquid API is the public interface to Hyperliquid's exchange, HyperCore, at https://api.hyperliquid.xyz. It has three parts: the info endpoint (POST /info) for market and account data, the exchange endpoint (POST /exchange) for signed orders, cancels and transfers, and a WebSocket at wss://api.hyperliquid.xyz/ws for live updates. Reading data needs no key. Trading needs a signature from your wallet or an API wallet you approve. Every IP gets 1,200 request weight a minute. For data the public API does not keep, such as a wallet's fills past its latest 10,000 or liquidations across every market, the Hyperdash Data API adds it from $20 a month, with the last 90 days on the $20 plan and full history on Enterprise.

What is the Hyperliquid API?

Hyperliquid runs one API for HyperCore, its on-chain order book. API servers keep a copy of the chain state, answer reads from it and forward signed actions to a node, then return the result once the block commits (API servers).

The three parts of the Hyperliquid API

Part Mainnet address What it does Auth
Info endpoint POST https://api.hyperliquid.xyz/info Prices, order books, candles, funding, metadata, and any wallet's positions, orders and fills None
Exchange endpoint POST https://api.hyperliquid.xyz/exchange Orders, cancels, leverage, margin, transfers, withdrawals, API wallet approval Signed by the account or an approved API wallet
WebSocket wss://api.hyperliquid.xyz/ws Live subscriptions, plus info requests and signed actions sent over the socket None to read

Testnet uses the same paths at https://api.hyperliquid-testnet.xyz and wss://api.hyperliquid-testnet.xyz/ws. The API is still labeled v0, and its short field names (px for price, sz for size, szi for signed size) are listed on the Notation page.

Hyperliquid API docs: where each topic lives

The official Hyperliquid API docs sit in Hyperliquid's GitBook under For developers, then API. Each page also has a Markdown copy at the same URL plus .md, and the docs publish an llms.txt index for AI agents.

Hyperliquid takes API questions in the #api-traders channel of its Discord, not in support tickets, and posts API changes to its API announcements Telegram channel.

Hyperliquid API quick start

These four steps go from a first read to a first order, on testnet for the order. Steps 1 to 3 run as pasted; step 4 needs the setup below.

  1. Read the mid price of every main-dex perp and spot pair, with no key: curl -X POST https://api.hyperliquid.xyz/info -H "Content-Type: application/json" -d '{"type": "allMids"}'
  2. Install the official Python SDK: pip install hyperliquid-python-sdk
  3. Read the BTC order book from Python: from hyperliquid.info import Info; from hyperliquid.utils import constants; info = Info(constants.MAINNET_API_URL, skip_ws=True); print(info.l2_snapshot("BTC"))
  4. Place a resting order on testnet, signed by an API wallet for your main account: exchange = Exchange(eth_account.Account.from_key(API_WALLET_KEY), constants.TESTNET_API_URL, account_address=MAIN_ADDRESS), then exchange.order("ETH", True, 0.2, 1100, {"limit": {"tif": "Gtc"}})

Step 4 needs from hyperliquid.exchange import Exchange and import eth_account, a testnet balance, and an API wallet approved by your testnet account. MAIN_ADDRESS is your account's address, not the API wallet's. The order comes from the SDK's own basic_order.py example: a buy of 0.2 ETH at $1,100, far enough below the market that it rests on the book.

How do you read data from the info endpoint?

Every info request is a POST to /info with Content-Type: application/json and a body that names the request type. The most used types are:

  • allMids: the mid price of every perp on the main dex and every spot pair; add "dex": "xyz" for a Hyperliquid HIP-3 dex.
  • meta and metaAndAssetCtxs: every perp market on the main dex (add dex for a Hyperliquid HIP-3 dex), with mark price, funding, open interest and 24-hour volume in the second.
  • l2Book: the order book, at most 20 levels per side, with optional nSigFigs to group levels.
  • candleSnapshot: candles from 1 minute to 1 month for one market, limited to the most recent 5,000.
  • fundingHistory: past funding rates for one market from a startTime.
  • clearinghouseState and spotClearinghouseState: one wallet's perp positions and margin, and its spot balances.
  • openOrders, userFills, userFillsByTime and historicalOrders: one wallet's orders and fills.
  • userRateLimit: how much of its address-based limit a wallet has used.

Five rules catch most first-time errors. Perps use the coin name from meta, such as BTC. Spot uses PURR/USDC for PURR and @ plus the pair index for everything else, so HYPE is @107 on mainnet. Hyperliquid HIP-3 markets carry their dex name as a prefix, such as xyz:XYZ100. Account queries take the account's own address: an API wallet's address returns an empty result. Most requests over a time range return at most 500 items (userFillsByTime returns up to 2,000), so page forward from the last timestamp.

How does the exchange endpoint work?

Every exchange request is a POST to /exchange with four parts: an action object, a nonce, a signature and, when trading for a sub-account or vault, a vaultAddress. Some actions also take expiresAfter, a time in milliseconds after which the action is rejected.

An order action lists one or more orders, each with:

  • a: the asset ID. Perps use their index in meta (BTC is 0 on mainnet), spot uses 10000 plus the pair index, and Hyperliquid HIP-3 perps use 100000 plus 10000 times the perp dex index plus the market's index (Asset IDs).
  • b, p, s, r: buy or sell, price, size and reduce-only. Prices take at most 5 significant figures (whole numbers are always allowed), and sizes are rounded to the asset's szDecimals from meta.
  • t: a limit order with time in force Gtc, Ioc or Alo (post-only), or a trigger order for take-profit and stop-loss.
  • c: an optional client order ID, a 128-bit hex string you can cancel by.

Other actions cover cancels, modifies, a scheduled cancel (dead man's switch), leverage and isolated margin, TWAP orders, transfers, withdrawals, staking, and approving API wallets and builder fees.

How do API wallets and signing work?

The Hyperliquid API has no key and secret pair to send in a header. Each action is signed with an Ethereum private key, either the account's own or that of an API wallet (also called an agent wallet) the account has approved to sign for it and its sub-accounts. An account can approve 1 unnamed API wallet and up to 3 named ones, plus 2 more named ones per sub-account, and a named wallet can be set to expire up to 180 days ahead. Sub-accounts and vaults have no keys of their own: the master account or its API wallet signs, with vaultAddress set.

Hyperliquid's docs recommend an SDK over hand-written signatures. There are two signing schemes, called sign_l1_action and sign_user_signed_action in the Python SDK, and the usual mistakes are field order in the msgpack payload, trailing zeros on numbers and upper-case letters in addresses. A wrong signature does not fail with a reason: it recovers a different address, so the error names a user or API wallet that "does not exist" (Signing).

Nonces work differently from Ethereum. Hyperliquid stores the 100 highest nonces per signer. A new nonce must be higher than the lowest of them, never used before, and within 2 days before to 1 day after the block time. The docs recommend the current time in milliseconds, one API wallet per trading process, and a new API wallet address rather than reusing an old one, because a deregistered wallet's nonce history can be pruned (Nonces and API wallets).

What are the Hyperliquid API rate limits?

Hyperliquid limits requests per IP address and actions per wallet address.

Hyperliquid API rate limits per IP address

Limit Value
REST weight, shared by info and exchange 1,200 per minute
Exchange actions Weight 1, plus 1 per 40 orders or cancels in a batch
l2Book, allMids, clearinghouseState, orderStatus, spotClearinghouseState, exchangeStatus Weight 2
userRole Weight 60
Every other info request Weight 20
Fills, historical orders, funding and other list requests Extra weight per 20 items returned (per 60 for candles)
WebSocket connections 10 open, 30 new per minute
WebSocket subscriptions 1,000, across at most 10 unique wallets
Messages sent over WebSocket 2,000 per minute, 100 post requests in flight

At weight 20, one IP can send about 60 info requests a minute, or 600 at weight 2. Polling many wallets or markets reaches that quickly, which is why apps move live data to the WebSocket.

The wallet limit covers actions only, not info requests. Each address gets an initial 10,000 requests plus 1 request per 1 USDC it has ever traded. Past the limit it can send one request every 10 seconds, and cancels get extra room so open orders can always be canceled. A batch of orders counts as one request against the IP limit and as one per order against the address limit. Each account can hold 1,000 open orders, plus 1 more per $5 million of volume, up to 5,000.

Testnet vs mainnet

Testnet runs the same API at https://api.hyperliquid-testnet.xyz, so code moves between the two by changing the base URL, or constants.TESTNET_API_URL in the Python SDK. Three things differ. Asset IDs are not the same: HYPE's spot ID is 107 on mainnet and 1035 on testnet. User-signed actions such as withdrawals name the chain in hyperliquidChain, "Mainnet" or "Testnet". And testnet funds come from a faucet that pays 1,000 mock USDC to addresses that have deposited on mainnet. Faucet steps, the HyperEVM testnet and SDK setup are in Hyperliquid Testnet: Faucet, API URLs, Chain ID and SDK Setup.

Hyperliquid SDKs: official and community

  • Python (official): hyperliquid-python-sdk, installed with pip install hyperliquid-python-sdk. It covers the info and exchange endpoints and the WebSocket, handles signing, and ships runnable examples. Hyperliquid's docs point to its code as the reference for signing.
  • Rust (community): hypersdk, written by Infinite Field.
  • TypeScript (community): nktkas/hyperliquid and nomeida/hyperliquid.
  • CCXT: a Hyperliquid integration in several languages, using CCXT's standard interface.

The Hyperliquid WebSocket in brief

Connect to wss://api.hyperliquid.xyz/ws and send {"method": "subscribe", "subscription": {"type": "trades", "coin": "BTC"}} to stream BTC trades; other channels cover order books, candles, asset contexts and a wallet's fills, orders and funding. The server closes a connection it has not sent a message to in 60 seconds, so clients on quiet channels send {"method": "ping"}. Reconnects, snapshots, the full channel list and the Hyperdash stream are covered in Hyperliquid WebSocket API.

How much history does the Hyperliquid API return?

The public API is built for trading and live state, so its history is short. Candles stop at the most recent 5,000 per interval, which is about three and a half days of 1-minute bars. A wallet's fills stop at its 10,000 most recent, and its historical orders at 2,000. The order book is the current one only, and there is no request for every past trade in a market.

For older data, Hyperliquid's hyperliquid-archive S3 bucket holds L2 book snapshots and asset contexts, uploaded about once a month with no guarantee of timely updates, and hl-mainnet-node-data holds node fills and blocks. The requester pays the transfer cost, and there are no candles in S3. Hyperliquid Historical Data compares every route and lists how far back each dataset goes.

When to add the Hyperdash Data API

Keep the Hyperliquid API for orders signed by your own code and for live state of one wallet or one market at a time. The Hyperdash Data API is read-only. Add the Hyperdash Data API when a job needs data the public API does not keep or limits you on:

  • Longer history: a wallet's fills past its latest 10,000, and candles by time range instead of the latest 5,000, with 90 days of history on Hobby up to full history on Enterprise (plans).
  • Market-wide data: every liquidation with the liquidated wallet, and every trade with both the taker and maker wallets.
  • Many wallets at once: batch requests read up to 10,000 wallets on Scale, plus leaderboards, cohort positioning and trader statistics.
  • Separate from Hyperliquid's rate limits: Hyperdash serves its data from its own Hyperliquid nodes, so these reads do not use your 1,200 weight a minute.
  • AI agents: a hosted MCP server, so Claude or ChatGPT can query the data in plain language.

Requests are REST with a bearer key. This one returns about 30 days of hourly BTC candles: curl "https://data.hyperdash.com/v1/markets/BTC/candles?interval=1h" -H "Authorization: Bearer $HYPERDASH_API_KEY"

For keys, request formats, limits and streams side by side, read Hyperliquid Native API vs Hyperdash Data API.

Build on the Hyperliquid API with your AI agent

Connect an AI agent and ask: "Pull the last 7 days of hourly BTC candles and funding on Hyperliquid, then write a Python script that fetches the same data every hour."

Further reading: Hyperliquid Historical Data and Hyperliquid Native API vs Hyperdash Data API.

FAQ

Where are the Hyperliquid API docs? In Hyperliquid's GitBook at hyperliquid.gitbook.io, under For developers, then API. The section covers the info endpoint, the exchange endpoint, the WebSocket, signing, nonces, asset IDs and rate limits. For ready-made history and analytics, the Hyperdash Data API docs cover the Hyperdash side.

What is the Hyperliquid API base URL? https://api.hyperliquid.xyz on mainnet, with reads at /info, signed actions at /exchange and the WebSocket at wss://api.hyperliquid.xyz/ws. Testnet uses https://api.hyperliquid-testnet.xyz.

Is the Hyperliquid API free? Yes. The info endpoint, exchange endpoint and WebSocket cost nothing to call within the rate limits; trades pay the normal trading fees. The Hyperdash website, with wallet pages, the leaderboard and trader positioning, is also free to use. The Hyperdash Data API is paid, from $20 a month.

Do I need an API key for the Hyperliquid API? No. Reads need no key at all. Orders and transfers are signed with your wallet's private key or with an API wallet that your account has approved.

What is a Hyperliquid API wallet? A separate private key that your account approves to sign actions for it and its sub-accounts. An account can have 1 unnamed and up to 3 named API wallets. Queries still take the account's address, not the API wallet's.

What is the Hyperliquid API rate limit? 1,200 weight per minute per IP address. Most info requests weigh 20, so about 60 a minute; l2Book, allMids and clearinghouseState weigh 2. Actions also have a per-address limit of 10,000 requests plus 1 per USDC traded.

What nonce should I use for Hyperliquid API requests? The current time in milliseconds. It must be higher than the lowest of the address's 100 stored nonces, unused, and within 2 days before to 1 day after the block time.

Why does my Hyperliquid signature fail with "does not exist"? The signature recovered a different address than your wallet. The usual causes are the wrong signing scheme, msgpack field order, trailing zeros or upper-case addresses. Signing through an SDK avoids all four.

How do I get more than 10,000 fills for a Hyperliquid wallet? The Hyperdash Data API returns a wallet's fills by time range, from 90 days back on Hobby up to full history on Enterprise. The public API stops at a wallet's 10,000 most recent fills, and Hyperliquid's node data on S3 also holds older fills.

Which Hyperliquid SDK is official? The Python SDK, hyperliquid-python-sdk. Hyperliquid's docs list a Rust SDK and two TypeScript SDKs written by community members, and a CCXT integration.

Get started with Hyperdash

  1. Create your Hyperdash account and get your first API key. Plans start at $20 a month.
  2. Connect the Hyperdash MCP server to Claude, ChatGPT, Claude Code, Codex or Cursor in about 2 minutes, with no API key.
  3. Make your first request with the Quickstart.

Need full history, an SLA or Hyperliquid Peering in Tokyo or Frankfurt? Talk to the Hyperdash team.

Top comments (0)