DEX · Hyperliquid

Hyperliquid API: Documentation, Agent Keys and Integrations

A technical guide to working with the Hyperliquid REST and WebSocket API. Set up programmatic access to the fully on-chain order book (CLOB), manage margin and automate HFT strategies powered by a high-performance Layer-1 blockchain architecture (HyperBFT).

API Architecture Overview: AppChain & HyperCore

Unlike most DEXs that rely on off-chain engines or L2 solutions, Hyperliquid operates as a purpose-built Layer-1 blockchain. All orders are matched on-chain in the HyperCore engine at up to 200,000 orders per second with a median latency of less than 0.2 seconds. The key architectural advantage is the complete absence of gas fees (Zero Gas Fees) for placing, modifying or canceling orders.

API Security: Delegation via Agent Wallets

Hyperliquid has abandoned the vulnerable concept of storing HMAC API keys on servers. Trading bots use a cryptographic delegation mechanism instead — Agent Wallets (API Wallets). You sign every trading command locally.

Key security practices:

  • Zero withdrawal rights: A generated Agent Key can only send trading orders. Built-in protection prevents it from initiating withdrawals.
  • Process separation (Nonce Space): You can create multiple Agent Wallets, one per trading bot, to avoid nonce collisions (transaction sequence numbers).
  • Secure storage: Keep `AGENT_PRIVATE_KEY` exclusively in protected environment variables (`.env`) on your trading server and never expose the private key of your Master Account (main wallet).

→ Inside Hyperliquid's on-chain architecture

API Use Cases: HFT, Market Making and AI Trading

Thanks to ultra-low fees (Base Tier: 0.015% maker / 0.045% taker) and collateral in native USDC, the Hyperliquid API is ideal for resource-intensive algorithmic strategies:

  • Market Making and HLP: Maintaining liquidity in the order book (quoting limit orders at the edges of the spread). Since canceling orders costs no gas, HFT bots can adjust quotes hundreds of times per minute. VIP tiers unlock negative maker fees (rebates).
  • Funding Rate Arbitrage: High-frequency delta-neutral strategies between Hyperliquid perps and centralized exchanges.
  • Trading Pre-Launch Markets: Using the API for fast scalping on exclusive HIP-3 markets and prediction markets unavailable on traditional CEXs.

→ Up-to-date Hyperliquid volumes and liquidity metrics

Key Generation: Master Account and API Wallet

The developer onboarding process involves creating an isolated agent:

  1. Connecting an L1 Wallet (Master Account): Connect your EVM wallet (MetaMask, Rabby) in the platform interface. Your public address (0x...) is your account identifier.
  2. Creating an Agent Wallet: In the exchange interface, go to the API section (or More -> API). Click "Generate API Wallet".
  3. Saving the Private Key: The system will generate a cryptographic pair. Make sure to copy the Private Key of this Agent Wallet. It is your equivalent of an "API Secret".
  4. Authorization (Approve): Sign an on-chain transaction in your Master Wallet to authorize the Agent Wallet. By default the delegation period is 90 days, but it can be extended up to a maximum of 180 days (the valid_until parameter in code or the MAX option in the platform interface).

Important: In your trading script you will specify the Master Account's public address as the target of trading, and use the Agent Wallet's Private Key to cryptographically sign the payload.

API Architecture: /info and /exchange

Unlike classic REST, Hyperliquid groups requests into two global endpoints. Almost all requests (even reads) are sent via POST with a JSON body specifying the action type.

  • Data reading (/info): The https://api.hyperliquid.xyz/info endpoint. Used to fetch the order book (l2Book), candles (candleSnapshot), trade history and user information. Requires no authorization.
  • Trading operations (/exchange): The https://api.hyperliquid.xyz/exchange endpoint. Used for placing/canceling orders and transfers. Requires a local EIP-712 signature created with your Agent Private Key.

Environments reference

  • Mainnet REST: https://api.hyperliquid.xyz
  • Mainnet WebSocket: wss://api.hyperliquid.xyz/ws
  • Testnet REST: https://api.hyperliquid-testnet.xyz

Error Handling and Rate Limits

Building a stable trading client requires handling errors at the L1 level:

Cause / Error type Description and Solution
Invalid Signature The transaction signature was built incorrectly. Make sure you pack the EIP-712 payload correctly and sign it with the Agent Wallet's private key (not the public address).
Invalid Nonce Transaction sequence number conflict. Every transaction from a signer must have a unique nonce (usually a timestamp in milliseconds). If you run multiple threads, use different Agent Wallets.
Rate Limit Exceeded / HTTP 429 L1 request limits exceeded (the public limit is 1200 requests per minute). For uninterrupted HFT operation switch to reading over WebSocket or use dedicated infrastructure RPC endpoints (e.g., QuickNode HyperCore API or HypeRPC).
Insufficient Margin Not enough collateral (USDC) to open/maintain a position.

Official and Community SDKs

Since building EIP-712 signatures "from scratch" can be challenging, it is recommended to use ready-made client libraries:

  • Python SDK (Official): hyperliquid-python-sdk — includes examples of connecting an API Wallet and signing orders.
  • Rust SDK: hypersdk — a high-performance community client for HFT strategies.
  • TypeScript/Node.js: Various community implementations or the CCXT library.

First Steps: Connection Examples

Availability Check and Metadata Retrieval (Public API)

Use a POST request to the /info endpoint to fetch the list of trading pairs:

curl -X POST https://api.hyperliquid.xyz/info \
  -H "Content-Type: application/json" \
  -d '{"type": "meta"}'

Node.js: Fetching the L2 Order Book (Axios)

An example of fetching the L2 Orderbook for BTC (all pairs are quoted against native USDC):

const axios = require('axios');

async function getOrderbook() {
  try {
    const response = await axios.post('https://api.hyperliquid.xyz/info', {
      type: 'l2Book',
      coin: 'BTC'
    });
    console.log("Ask ордера (верх стакана):", response.data.levels[1].slice(0, 5));
    console.log("Bid ордера (низ стакана):", response.data.levels[0].slice(0, 5));
  } catch (error) {
    console.error("Ошибка API:", error.response ? error.response.data : error.message);
  }
}

getOrderbook();

Third-Party Integrations: CCXT, Gainium and FMZ Quant

Algorithmic Trading via CCXT

Hyperliquid is officially supported by the universal crypto library CCXT. This lets developers use a standardized syntax (e.g., createOrder, fetchBalance) in Python, JavaScript and PHP. Simply pass walletAddress and privateKey (of your Agent wallet) when initializing the exchange class in CCXT.

Terminals and Bot Builders

Platforms such as Tealstreet, Gainium and FMZ Quant offer native Hyperliquid integration. To connect, copy your account's EVM address and the API-agent private key generated in the Hyperliquid interface, then paste them into the third-party terminal's settings. This spares you from deploying your own server infrastructure.

Frequently Asked Questions (FAQ) about the Hyperliquid API

What is the base URL of the Hyperliquid REST API?

The base URL for data requests (public and private): https://api.hyperliquid.xyz/info. Trading transactions are submitted to https://api.hyperliquid.xyz/exchange. For WebSocket use wss://api.hyperliquid.xyz/ws.

Why doesn't Hyperliquid use standard API keys?

The exchange runs as a fully on-chain L1 blockchain. Instead of vulnerable HMAC secrets on exchange servers, cryptographic delegation is used. You create an "Agent Wallet" whose private key is stored only on your own server and signs blockchain transactions locally (EIP-712). This key has trading rights only — no withdrawal rights.

Does the platform charge gas for placing or canceling orders via the API?

No, basic order operations (placing, modifying and canceling limit orders) are entirely gas-free. You only pay the standard Maker/Taker trading fee upon execution. That said, HFT algorithms have access to a Priority Fees mechanism: when needed, you can voluntarily pay a priority fee in $HYPE tokens for faster transaction-flow delivery (Gossip Priority) or prioritized execution of IOC orders (Order Priority). Canceling orders always remains strictly free of charge.

---