Hyperliquid API Guide: REST, WebSocket, Rate Limits and Examples
Hyperliquid exposes public market and account data through REST, streams live updates through WebSocket, and accepts signed trading actions through its exchange API. This guide shows how the pieces fit together before you automate anything.

Direct answer
How does the Hyperliquid API work?
The Hyperliquid API has a public info endpoint for market and account queries, a signed exchange endpoint for orders and other actions, and a WebSocket endpoint for real-time data or posted requests. Mainnet uses api.hyperliquid.xyz; testnet uses api.hyperliquid-testnet.xyz. Start with read-only calls or testnet, use an official SDK for signing, and design around both IP-based and address-based rate limits.
Updated 23 Oct 2026
On this page
- What are the main Hyperliquid API endpoints?
- How do you use the Hyperliquid REST API?
- What is the difference between /info and /exchange?
- When should you use the Hyperliquid WebSocket API?
- How should a client handle reconnects and heartbeats?
- What is a Hyperliquid API wallet?
- Why are signing and nonces difficult?
- How do you start with the Hyperliquid Python SDK?
- What are the current Hyperliquid API rate limits?
- How do asset IDs, tick sizes and precision work?
- What common Hyperliquid API errors mean
- What should you check before using the API in production?
- The bottom line
The Hyperliquid API is the programmatic interface to HyperCore, the trading system behind Hyperliquid's order books. A dashboard can use it to display prices and positions. A trading bot can use it to stream order-book changes, place signed orders and monitor fills. The same API surface supports perpetual and spot markets, but asset identifiers and some request fields differ.
This is separate from HyperEVM JSON-RPC. Use the HyperCore API for exchange data and trading actions. Use an EVM RPC endpoint when an application needs blocks, logs, contract calls or transactions on HyperEVM. Mixing the two is a common source of confusion.
What are the main Hyperliquid API endpoints?
| Interface | Mainnet endpoint | Best used for |
|---|---|---|
| REST info | POST https://api.hyperliquid.xyz/info | Markets, books, fills, orders and account state |
| REST exchange | POST https://api.hyperliquid.xyz/exchange | Signed orders, cancels, transfers and account actions |
| WebSocket | wss://api.hyperliquid.xyz/ws | Live subscriptions and low-latency posted requests |
| HyperEVM RPC | https://rpc.hyperliquid.xyz/evm | EVM blocks, logs, contract reads and transactions |
Testnet mirrors the main API layout at https://api.hyperliquid-testnet.xyz and wss://api.hyperliquid-testnet.xyz/ws. Market metadata and asset IDs can differ between networks, so do not copy a mainnet asset index into a testnet order. Fetch metadata from the network you are actually using.
How do you use the Hyperliquid REST API?
Both main REST routes accept POST requests with JSON. The info endpoint is read-only. The request body's type field selects the query, such as allMids, l2Book, openOrders, userFills or clearinghouseState. Public user data is queried by address; there is no login token to read it because the underlying account activity is public.
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type":"allMids"}'The response is a JSON object whose keys are market identifiers and whose values are prices encoded as strings. Keep numeric values as decimal strings until your application deliberately converts them. Binary floating-point arithmetic can introduce rounding differences that matter when you later construct an order.
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type":"l2Book","coin":"BTC"}'The l2Book response contains bid and ask levels with price, size and order count. A single REST snapshot is useful for inspection, but it is not a complete live-order-book strategy. An automated application must account for the snapshot time and then keep its state current from a WebSocket feed or refresh it deliberately.
What is the difference between /info and /exchange?
- /info answers read-only questions. It returns market metadata, prices, books, funding history and account state.
- /exchange changes state. It accepts signed actions such as placing or cancelling an order, updating leverage, transferring assets or approving an API wallet.
- A user address belongs in account-data queries. An API wallet signs actions but should not be substituted for the user's address when requesting the user's positions or fills.
When should you use the Hyperliquid WebSocket API?
Use WebSocket when data should arrive as it changes. Available subscriptions include all mid prices, trades, candles, level-two books, best bid and offer, active-asset context, open orders, order updates, user fills and funding updates. REST is usually simpler for an occasional snapshot; WebSocket is better for a live screen or event-driven process.
const ws = new WebSocket("wss://api.hyperliquid.xyz/ws");
ws.addEventListener("open", () => {
ws.send(JSON.stringify({
method: "subscribe",
subscription: { type: "trades", coin: "BTC" }
}));
});
ws.addEventListener("message", (event) => {
const message = JSON.parse(event.data);
console.log(message);
});A successful subscription first returns a subscriptionResponse acknowledgment and then messages on the requested channel. Some time-series user feeds begin with a snapshot marked isSnapshot: true before streaming new events. Code should distinguish that initial state from later updates rather than counting the snapshot as fresh activity.
How should a client handle reconnects and heartbeats?
Hyperliquid's documentation tells automated clients to expect periodic server-side disconnects and reconnect cleanly. Resubscribe after reconnect and rebuild state from the new snapshot or the matching info request. Do not assume the last locally received message is still current.
The server closes a connection if it has not sent a message to that client for 60 seconds. For quiet subscriptions, send {"method":"ping"}; the server answers on the pong channel. A reconnect loop should use backoff and jitter instead of opening many connections at once, which can hit the new-connection limit.
What is a Hyperliquid API wallet?
An API wallet, also called an agent wallet, is a separate signing key approved by a master account. It can sign trading actions on behalf of the master account or its subaccounts without exposing the master wallet's private key to the trading process. It does not hold the account's funds and is not the address to use when querying that account's positions.
A safer automation setup
Create a new API wallet
Generate a dedicated key and approve its public address from the master account. Do not reuse a key that was previously deregistered.
Keep the secret outside the codebase
Load it from a protected secret store or environment variable. Confirm that logs, crash reports and version control cannot expose it.
Use one signer per trading process
Separate API wallets reduce nonce collisions. Hyperliquid recommends separate API wallets for parallel subaccount processes.
Query with the account address
Use the master or actual subaccount address for user state. The API wallet address is only the signer and can return empty account data if queried by mistake.
Test the full lifecycle on testnet
Verify order placement, partial fills, cancels, reconnects, retries and shutdown behavior before considering mainnet.
Why are signing and nonces difficult?
Hyperliquid has more than one signing scheme, field order matters for msgpack payloads, trailing zeroes can change the signed value, and address casing can cause mismatches. The official documentation therefore recommends using an existing SDK instead of writing signing code from scratch. A locally recovered signer does not prove the server will reconstruct the same payload.
Nonces are tracked per signer, including an API wallet signing for multiple accounts. They must be unique and fall within the protocol's accepted time window. If two processes share one signing key, they can produce collisions even when they trade different subaccounts. Coordinate an atomic nonce source or, more simply, use a separate API wallet per process.
How do you start with the Hyperliquid Python SDK?
Hyperliquid maintains an official Python SDK. Install it in a virtual environment, start with its read-only Info class, and inspect the repository examples before sending any signed action. The following call does not require a private key and returns current mids.
from hyperliquid.info import Info
from hyperliquid.utils import constants
info = Info(constants.MAINNET_API_URL, skip_ws=True)
print(info.all_mids())For signed testnet examples, follow the SDK's current setup and basic_order files rather than copying an old snippet from a blog. The SDK example separates account_address from secret_key: when an API wallet signs, account_address is still the master account's public address. Review the order response before assuming an order rested or filled, and cancel any test order that remains open.
What are the current Hyperliquid API rate limits?
As checked against the official documentation on October 23, 2026, REST requests share an IP-based allowance of 1,200 weighted units per minute. This is not the same as 1,200 calls: an exchange request usually has low weight, selected info queries have weight 2, most other info queries have weight 20, and some history or candle requests add weight based on the number of returned items.
| Limit | Current value | Scope |
|---|---|---|
| REST weighted allowance | 1,200 per minute | Per IP across REST routes |
| WebSocket connections | 10 | Maximum per IP |
| New WebSocket connections | 30 per minute | Per IP |
| WebSocket subscriptions | 1,000 | Across connections per IP |
| Unique users in user feeds | 10 | Across user-specific subscriptions |
| Messages sent | 2,000 per minute | Across WebSocket connections |
| Simultaneous inflight posts | 100 | Across WebSocket connections |
| HyperEVM public RPC | 100 per minute | Per IP at the official RPC |
Trading actions also face address-based limits. An address begins with a 10,000-request buffer and earns further capacity from cumulative trading volume at one request per 1 USDC traded. Once limited, it can send one request every ten seconds. This address rule applies to actions, not info requests; cancels receive additional capacity so open risk can still be reduced.
- Cache slow-changing metadata instead of requesting it for every order.
- Use WebSocket subscriptions for live data rather than polling the same REST snapshot many times.
- Batch compatible orders or cancels, while still handling both per-item errors and a single error for the whole batch.
- Back off after a limit response; immediate blind retries add load and can extend the failure.
- Measure request weights, not only request counts, because different info queries cost different amounts.
How do asset IDs, tick sizes and precision work?
A displayed market name is not always the integer asset value used in a signed action. Standard perpetuals use their index in the meta universe. Spot markets use 10000 plus the spot market index. Builder-deployed perpetuals use a separate formula based on their perp DEX and metadata index. Because mainnet and testnet metadata can differ, resolve IDs from the current response rather than hard-coding a remembered number.
Order size must respect the asset's szDecimals value from metadata. Prices allow up to five significant figures and are also constrained by the asset's decimal rules; integer prices are permitted. Remove trailing zeroes when constructing values for signing. The SDK handles much of this, but the application must still round intentionally and verify that the resulting order has the expected notional value.
What common Hyperliquid API errors mean
| Problem or error | Likely cause | First check |
|---|---|---|
| Empty user state | API wallet address used in the query | Query the master or actual subaccount address |
| Tick error | Price has invalid precision | Read szDecimals and apply price rules |
| Minimum notional error | Order value is too small | Check the current minimum and rounded size |
| Perp margin error | Not enough available margin | Read clearinghouse state before ordering |
| Reduce-only error | Order would enlarge or reverse exposure | Compare side and size with the live position |
| Missing order | Order filled, was cancelled or never existed | Inspect order updates and historical status |
| Signer does not exist | Signature payload reconstructed incorrectly | Use the SDK and compare every signed field |
| WebSocket goes quiet | Idle timeout or disconnection | Ping, reconnect, resubscribe and rebuild state |
What should you check before using the API in production?
- The code uses the intended network, account address, subaccount and current asset metadata.
- Secrets never enter client-side bundles, repositories, screenshots, analytics or application logs.
- Every order response is parsed as accepted, resting, filled or rejected instead of treated as a generic success.
- The process can cancel open orders and stop safely if market data is stale or the WebSocket disconnects.
- Retries are idempotent where possible and do not duplicate signed transfers or orders.
- REST weights, WebSocket counts and address capacity are measured and alerted before limits are exhausted.
- Test coverage includes partial fills, no liquidity, invalid precision, insufficient margin, rate limits and process restarts.
- A human can revoke the API wallet and inspect positions without depending on the automated process.
The bottom line
Use REST for deliberate snapshots, WebSocket for changing state and the exchange endpoint only through carefully controlled signing code. The fastest path is not to implement every detail yourself: begin with official read-only examples, adopt the maintained Python SDK for signed actions, test failure cases on testnet and promote only a small, observable process to mainnet.
Good API integration is mostly state management and risk control. Correctly identifying the user, tracking snapshots and updates, respecting precision, preserving unique nonces and surviving disconnects matter as much as constructing the first successful order.
Frequently asked questions
Is the Hyperliquid API free to use?
Hyperliquid publishes public API endpoints without a subscription fee, but usage is subject to IP-based and address-based limits. Infrastructure, data storage, RPC providers and trading fees can still create costs for an application.
Does the Hyperliquid API require an API key?
Read-only info calls do not require an API key. State-changing exchange actions require a cryptographic signature. For automation, an approved API wallet can sign on behalf of the main account or a subaccount without exposing the master wallet key.
What is the Hyperliquid API URL?
The mainnet REST base URL is https://api.hyperliquid.xyz and the mainnet WebSocket URL is wss://api.hyperliquid.xyz/ws. Testnet uses https://api.hyperliquid-testnet.xyz and wss://api.hyperliquid-testnet.xyz/ws.
Should I use REST or WebSocket for Hyperliquid market data?
Use REST for occasional snapshots and historical or metadata queries. Use WebSocket for live books, trades, candles, prices, fills and order updates. Many robust applications use both: REST to establish state and WebSocket to keep it current.
Is there an official Hyperliquid Python SDK?
Yes. Hyperliquid maintains hyperliquid-python-sdk on GitHub and publishes the hyperliquid-python-sdk package. Its examples cover market-data queries, orders, cancels, WebSocket subscriptions, transfers and API-wallet workflows.
Can I use the same API code on mainnet and testnet?
The request structure is similar, but URLs, market availability, asset IDs and account state can differ. Select the network explicitly and fetch that network's current metadata instead of carrying IDs over from the other environment.
Why does my API wallet show no positions?
An API wallet is a signer, not the account whose positions you normally query. Pass the master account or actual subaccount address to account-data requests while using the approved API wallet only to sign actions.
What is the Hyperliquid REST rate limit?
The official documentation listed a shared allowance of 1,200 weighted units per minute per IP when checked on October 23, 2026. Different request types have different weights, and trading actions also face address-based limits, so count weights rather than assuming every call costs one unit.
Sources
- Hyperliquid documentation - API overview↗ external
- Hyperliquid documentation - Info endpoint↗ external
- Hyperliquid documentation - Exchange endpoint↗ external
- Hyperliquid documentation - WebSocket API↗ external
- Hyperliquid documentation - Rate limits and user limits↗ external
- Hyperliquid documentation - Nonces and API wallets↗ external
- Hyperliquid documentation - Signing↗ external
- Official Hyperliquid Python SDK↗ external