The Hyperliquid API, With Python Examples

The Hyperliquid API has a public info endpoint for market and account data, an exchange endpoint for signed orders, and a WebSocket for live streams. Reading needs no key; trading needs a signature from your wallet or an API wallet you approve. Every example below was run on November 17, 2026, and shows its real output.

By Keel Research Team · Updated November 17, 2026

Hyperliquid runs its order book on its own chain and publishes a public API for it. You can read every market without an account, and trade from code once you sign with a wallet. This guide covers the parts most people need: reading prices, books, candles and funding, streaming trades, placing an order with an API wallet, and staying under the rate limits.

Every sample uses Python. They were run on November 17, 2026, 19:58 UTC with Python 3.12, hyperliquid-python-sdk 0.24.0, requests 2.34.2, websockets 17.4, and the output under each one is what it printed then. Prices will differ when you run them.

Hyperliquid API endpoints

EndpointURLUse
Info (REST)POST https://api.hyperliquid.xyz/infoMarket and account data. No key, no signature.
Exchange (REST)POST https://api.hyperliquid.xyz/exchangeOrders, cancels, transfers. Every request is signed.
WebSocketwss://api.hyperliquid.xyz/wsLive trades, books, candles and your own fills.
Testnethttps://api.hyperliquid-testnet.xyzThe same API against test funds.

From Hyperliquid’s API docs. Every info request is a POST with a JSON body whose type names what you want.

Read market data with Python

The mid price of every market comes back from one allMids request:

Python
import requests

INFO = "https://api.hyperliquid.xyz/info"

mids = requests.post(INFO, json={"type": "allMids"}, timeout=10).json()
for coin in ["BTC", "ETH", "SOL"]:
    print(coin, mids[coin])
Output, run November 17, 2026, 19:58 UTC
BTC 63759.5
ETH 1792.15
SOL 72.8515

l2Book returns the order book, at most 20 levels a side. Each level carries a price, a size and an order count:

Python
import requests

INFO = "https://api.hyperliquid.xyz/info"

book = requests.post(INFO, json={"type": "l2Book", "coin": "ETH"}, timeout=10).json()
bids, asks = book["levels"]
print("best bid", bids[0]["px"], "size", bids[0]["sz"])
print("best ask", asks[0]["px"], "size", asks[0]["sz"])
print("levels per side", len(bids), len(asks))
Output, run November 17, 2026, 19:58 UTC
best bid 1792.0 size 162.2541
best ask 1792.1 size 1.4758
levels per side 20 20

candleSnapshot returns candles for a time range in milliseconds. The last row is the hour still in progress. Per the info endpoint docs, only the most recent 5,000 candles of an interval are available, and a ranged request returns at most 500 rows, so page through a long range by using the last timestamp as the next start. For longer ranges, Hyperliquid OHLCV data shows three other ways to get candles.

Python
import time

import requests

INFO = "https://api.hyperliquid.xyz/info"

end = int(time.time() * 1000)
start = end - 3 * 60 * 60 * 1000  # the last three hours
body = {
    "type": "candleSnapshot",
    "req": {"coin": "BTC", "interval": "1h", "startTime": start, "endTime": end},
}
for c in requests.post(INFO, json=body, timeout=10).json():
    print(c["t"], c["o"], c["h"], c["l"], c["c"], c["v"])
Output, run November 17, 2026, 19:58 UTC
1794931200000 64100.0 64463.0 63440.0 63728.0 6565.31994
1794934800000 63727.0 64121.0 63511.0 63805.0 2699.39595
1794938400000 63805.0 64077.0 63637.0 63742.0 2120.53112
1794942000000 63743.0 63880.0 63635.0 63759.0 966.44602

metaAndAssetCtxs returns every market’s settings (size decimals, max leverage, margin table) beside its live context: mark price, the current hourly funding rate, open interest and volume. The max leverage it reports is the first margin tier; the full table for every market is on Hyperliquid max leverage.

Python
import requests

INFO = "https://api.hyperliquid.xyz/info"

meta, ctxs = requests.post(INFO, json={"type": "metaAndAssetCtxs"}, timeout=10).json()
for asset, ctx in zip(meta["universe"], ctxs):
    if asset["name"] in ("BTC", "ETH"):
        print(
            asset["name"],
            "max leverage", asset["maxLeverage"],
            "mark", ctx["markPx"],
            "funding", ctx["funding"],
            "open interest", ctx["openInterest"],
        )
Output, run November 17, 2026, 19:58 UTC
BTC max leverage 40 mark 63763.0 funding 0.0000100266 open interest 37574.2842
ETH max leverage 25 mark 1792.1 funding -0.0000092399 open interest 614280.1663999998

Funding here is the rate for the current hour. To compare it across markets, or see how it has moved, the Hyperliquid funding rates page ranks every market, and Hyperliquid historical data shows how far back each series goes.

Stream live data with the Hyperliquid WebSocket

Connect to wss://api.hyperliquid.xyz/ws and send a subscribe message. The first reply confirms the subscription; trade messages follow on the trades channel, each with a side, price, size and time in milliseconds.

Python
import asyncio
import json

import websockets

async def main():
    async with websockets.connect("wss://api.hyperliquid.xyz/ws") as ws:
        await ws.send(json.dumps({
            "method": "subscribe",
            "subscription": {"type": "trades", "coin": "BTC"},
        }))
        while True:
            msg = json.loads(await ws.recv())
            if msg["channel"] == "trades":
                for trade in msg["data"][:3]:
                    print(trade["side"], trade["px"], trade["sz"], trade["time"])
                break

asyncio.run(main())
Output, run November 17, 2026, 19:58 UTC
A 63759.0 0.00016 1794945476898
A 63759.0 0.00003 1794945476898
B 63760.0 0.02048 1794945478930

The same connection takes subscriptions for books, candles, mid prices and your own orders and fills. Hyperliquid’s WebSocket docs say servers may disconnect without notice, so a bot should reconnect on its own; data missed in between arrives in the snapshot sent when you subscribe again.

The Hyperliquid Python SDK

Hyperliquid lists hyperliquid-python-sdk on its API page (pip install hyperliquid-python-sdk). It wraps the same requests: Info for data, Exchange for signed actions. The universe in meta also lists delisted markets, flagged isDelisted, so filter them out:

Python
from hyperliquid.info import Info
from hyperliquid.utils import constants

info = Info(constants.MAINNET_API_URL, skip_ws=True)
print("BTC mid", info.all_mids()["BTC"])
live = [a for a in info.meta()["universe"] if not a.get("isDelisted")]
print("live perp markets", len(live))
Output, run November 17, 2026, 19:58 UTC
BTC mid 63759.5
live perp markets 179

Place orders: API wallets and signing

Hyperliquid has no API key in the usual exchange sense. Every action sent to the exchange endpoint is signed by a wallet. You could sign with your main wallet, but a bot normally signs with an API wallet (also called an agent wallet). Per the nonces and API wallets docs, a master account approves an API wallet to sign on behalf of itself or any of its sub-accounts. The API wallet only signs: to read balances, positions and fills you still query the master account’s address.

  • Approve one with the SDK’s approve_agent, signed by your main wallet. Keep the API wallet’s key on the server and the main key off it.
  • Nonces: Hyperliquid keeps the 100 highest nonces per signer. A new action needs a nonce above the smallest of them, never used before, and within two days before to one day after the current time in milliseconds. The SDK uses the current time, which satisfies this for one process.
  • The docs strongly suggest a fresh API wallet address rather than reusing an old one.

A limit order through the SDK, with the API wallet signing for your main account:

Python
import os

from eth_account import Account
from hyperliquid.exchange import Exchange
from hyperliquid.utils import constants

# Sign with an API wallet your main wallet approved; trade for the main account.
api_wallet = Account.from_key(os.environ["HL_API_WALLET_KEY"])
exchange = Exchange(
    api_wallet,
    constants.TESTNET_API_URL,  # switch to MAINNET_API_URL when you are ready
    account_address=os.environ["HL_ACCOUNT_ADDRESS"],
)

# Buy 0.01 ETH with a post-only limit order ("Alo" = add liquidity only).
result = exchange.order("ETH", True, 0.01, 1500.0, {"limit": {"tif": "Alo"}})
print(result)
Not run here: this sample signs with your key and places an order. Try it on testnet first.

An app that sends orders for its users can also attach a builder code to each one and charge a fee on the fill. The user approves a maximum first. How it works, and the caps: Hyperliquid builder codes.

Hyperliquid API rate limits

WhatLimit
REST requests per IPA shared weight budget of 1,200 per minute
Light info requestsWeight 2: l2Book, allMids, clearinghouseState, orderStatus, spotClearinghouseState, exchangeStatus
Other info requestsWeight 20 (userRole is 60); candleSnapshot and the history requests add weight for long responses
Exchange actionsWeight 1 + floor(batch length / 40)
WebSocket10 connections, 30 new connections a minute, 1,000 subscriptions, 2,000 messages a minute
Per address1 request per 1 USDC traded since the address was created, after an initial buffer of 10,000

From Hyperliquid’s rate limits docs, read November 17, 2026. A rate-limited address may send one request every 10 seconds. The WebSocket has limits of its own, so data you need often is usually better streamed than polled.

When you want results, not plumbing

Calling the API is the easy part. Testing a strategy on it also takes clean history, plus fees, slippage and funding charged the way the venue charges them. Keel does that work on Hyperliquid data:

Ask an assistant to write it with you

Open your assistant with this request already written. It reads this page, helps with your script, and shows you how to test the idea in Keel.

Ask AI
Hyperliquid can change its API, limits and rules; the docs lines above were read on November 17, 2026, and the outputs are from November 17, 2026, 19:58 UTC. Trading from code can lose money quickly; test on testnet first. Not financial advice.
Automate it

Trade systematically on Keel

Keel is a strategy builder for Hyperliquid. Describe an idea, backtest it with fees, slippage and funding, and run it live on Hyperliquid’s crypto perps. Stock and index perps are coming soon.

Start free. Connect a Hyperliquid wallet when you’re ready to trade.

What you can do
  • Backtest any strategy with realistic fees, slippage, and funding.
  • Change a parameter and run it again. Every backtest is kept.
  • Run it live on Hyperliquid with stop-losses and leverage caps.
  • Start from a sentence. Describe your idea and Keel builds a strategy you can test.
FAQ

Hyperliquid API questions

Does Hyperliquid have an API?

Yes, and it is public. The info endpoint (POST https://api.hyperliquid.xyz/info) serves prices, order books, candles, funding and account state without a key. The exchange endpoint takes signed orders, and a WebSocket at wss://api.hyperliquid.xyz/ws streams the same data live.

Is there a Hyperliquid Python SDK?

Yes. Hyperliquid lists hyperliquid-python-sdk on GitHub (pip install hyperliquid-python-sdk). Its Info class reads data and its Exchange class signs orders. Hyperliquid's docs also list community SDKs for Rust and TypeScript.

What are the Hyperliquid API rate limits?

REST requests from one IP share a weight budget of 1,200 per minute. Light info requests such as l2Book and allMids weigh 2, most others 20. A WebSocket allows 10 connections and 1,000 subscriptions per IP. Each address also gets 1 request per 1 USDC it has traded, after an initial buffer of 10,000.

Do I need a Hyperliquid API key?

Not to read data. To trade, there is no key in the usual exchange sense: you sign each request with a wallet. Most bots sign with an API wallet (also called an agent wallet) that your main wallet approves, so the main wallet's key never sits on a server.

What is a Hyperliquid API wallet or agent wallet?

A separate key that your main account approves to sign actions on its behalf, or on behalf of a sub-account. It only signs: to read your balances and positions you still query your main account's address. Hyperliquid's docs advise using a fresh API wallet address rather than reusing an old one.

Where are the Hyperliquid API docs?

In Hyperliquid's own docs, under For developers, API. The pages this guide quotes are linked beside each section: the info endpoint, the WebSocket, rate limits, and nonces and API wallets.