Hyperliquid API
One line to trade Hyperliquid.
Your keys never leave your machine.
pip install hyperliquid-sdkfrom hyperliquid_sdk import HyperliquidSDK
sdk = HyperliquidSDK(endpoint, private_key=key)
# Market buy $100 of BTC
order = sdk.market_buy("BTC", notional=100)
print(f"Filled {order.filled_size} @ ${order.avg_price}")Everything you need
Trading, streaming, market data — one SDK, four languages
One-Line Trading
Market orders, limits, stops — all in a single call
sdk.market_buy("BTC", notional=100)Zero Custody
Sign locally. Your keys never leave your machine
# Private key stays localReal-Time Streaming
WebSocket and gRPC for live trades and order books
sdk.stream.trades(["BTC"], callback)Full Market Data
Prices, order books, positions, candles — all included
sdk.info.l2_book("ETH")HIP-3 Markets
Trade community perpetuals with the same API
sdk.buy("xyz:SILVER", notional=11)Advanced Orders
TWAP, triggers, stop loss, take profit built-in
sdk.twap_order("BTC", size=0.1, ...)REST API
Build without signature, send with signature. Click any endpoint to try it.
Exchange — Build (no signature)
Exchange — Send (with signature)
Enhanced Endpoints
Error Codes
Every error uses the appropriate HTTP status code and includes error, message, and guidance with exactly what to do next.
| HTTP | Error Code |
|---|---|
| 403 | NOT_APPROVED |
| 422 | BUILDER_MISMATCH |
| 422 | SIGNATURE_INVALID |
| 422 | HL_EXCHANGE_* |
| 400 | INVALID_JSON |
| 422 | INVALID_PARAMS |
| 500 | INTERNAL_ERROR |
Fees
Two fees apply per trade: our builder fee (injected into your order) and Hyperliquid's exchange fee (maker/taker, charged by the protocol).
| Market | Fee | Protocol Max |
|---|---|---|
| Perpetuals | 0.04% | 0.1% |
| Spot | 0.05% | 1% |
| Market | Taker | Maker |
|---|---|---|
| Perpetuals | 0.045% | 0.015% |
| Spot | 0.070% | 0.040% |
You approve a maxFeeRate ceiling (e.g. "1%") for the builder fee. The actual builder fee is always within your approved limit. You can revoke at any time.
FAQ
Common questions about Hyperliquid API.