### Place a Market Buy Order (Python) Source: https://hyperliquidapi.com/ Executes a market buy order for a specified notional amount of an asset. This example demonstrates a common trading operation using the Hyperliquid SDK. ```python order = sdk.market_buy("BTC", notional=100) print(f"Filled {order.filled_size} @ ${order.avg_price}") ``` -------------------------------- ### POST /exchange - Build and Send Exchange Actions Source: https://hyperliquidapi.com/llms.txt This endpoint is used for all exchange operations, including placing orders, canceling orders, modifying orders, and managing approvals. It follows a build-sign-send pattern: first, build the action to get a hash, then sign the hash locally, and finally, send the action with the signature. ```APIDOC ## POST /exchange ### Description Handles all exchange operations including orders, cancels, modifies, and approvals using a build-sign-send pattern. ### Method POST ### Endpoint `https://send.hyperliquidapi.com/exchange` ### Parameters #### Request Body - **action** (object) - Required - The exchange action to perform (e.g., order, cancel, approveBuilderFee, closePosition, batchModify). - **nonce** (number) - Optional - The nonce for the transaction, required for send operations. - **signature** (object) - Optional - The EIP-712 signature of the transaction hash, required for send operations. ### Request Example (Build Approval) ```json { "action": { "type": "approveBuilderFee", "maxFeeRate": "1%" } } ``` ### Request Example (Send Approval) ```json { "action": { "type": "approveBuilderFee", "maxFeeRate": "1%" }, "nonce": 12345, "signature": { "r": "0x...", "s": "0x...", "v": 27 } } ``` ### Request Example (Build Order) ```json { "action": { "type": "order", "orders": [ { "asset": "BTC", "side": "buy", "price": "100000", "size": "0.001", "tif": "ioc" } ] } } ``` ### Request Example (Send Order) ```json { "action": { "type": "order", "orders": [ { "asset": "BTC", "side": "buy", "price": "100000", "size": "0.001", "tif": "ioc" } ] }, "nonce": 12346, "signature": { "r": "0x...", "s": "0x...", "v": 27 } } ``` ### Response (Build) #### Success Response (200) - **hash** (string) - The hash of the action to be signed. - **nonce** (number) - The nonce for the transaction. - **details** (object) - Details about the action. - **typedData** (object) - The EIP-712 typed data for signing. ### Response Example (Build) ```json { "hash": "0x...", "nonce": 12345, "details": {}, "typedData": {} } ``` ### Response (Send) #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **user** (string) - The user's address. - **exchangeResponse** (object) - The response from the Hyperliquid exchange. ### Response Example (Send) ```json { "success": true, "user": "0x...", "exchangeResponse": {} } ``` ``` -------------------------------- ### GET /markets Source: https://hyperliquidapi.com/llms.txt Retrieves information about all available perpetual, spot, and HIP-3 markets. Supports filtering by DEX. ```APIDOC ## GET /markets ### Description Fetches a list of all available markets, including perpetual, spot, and HIP-3 markets. You can optionally filter the results by a specific DEX. ### Method GET ### Endpoint `/markets` ### Parameters #### Query Parameters - **dex** (string) - Optional - The name of the DEX to filter markets by (e.g., "Uniswap V3"). ### Response #### Success Response (200) - **markets** (array) - An array of market objects. - **name** (string) - The name of the market (e.g., "BTC-PERPETUAL"). - **type** (string) - The type of market (e.g., "Perpetual", "Spot", "HIP-3"). - **dex** (string) - The DEX the market belongs to. ### Response Example ```json { "markets": [ { "name": "BTC-PERPETUAL", "type": "Perpetual", "dex": "Hyperliquid" }, { "name": "ETH/USDC", "type": "Spot", "dex": "Hyperliquid" }, { "name": "ARB/USDC", "type": "HIP-3", "dex": "Camelot" } ] } ``` ``` -------------------------------- ### GET /approval Source: https://hyperliquidapi.com/llms.txt Checks the approval status for a given user address, including their current approval settings and trading permissions. ```APIDOC ## GET /approval ### Description Checks the approval status for a user, including their maximum fee rate and trading permissions for perpetual and spot markets. ### Method GET ### Endpoint `/approval?user=ADDRESS` ### Parameters #### Query Parameters - **user** (string) - Required - The user's Ethereum address. ### Response #### Success Response (200) - **approved** (boolean) - Indicates if the user is approved. - **maxFeeRate** (string) - The maximum fee rate the user is approved for. - **canTradePerps** (boolean) - Indicates if the user can trade perpetuals. - **canTradeSpot** (boolean) - Indicates if the user can trade spot. - **feeBreakdown** (object) - Details about the fee breakdown. ### Response Example ```json { "approved": true, "maxFeeRate": "0.5%", "canTradePerps": true, "canTradeSpot": true, "feeBreakdown": {} } ``` ``` -------------------------------- ### GET /health Source: https://hyperliquidapi.com/llms.txt Performs a health check on the Hyperliquid API service. ```APIDOC ## GET /health ### Description Checks the operational status of the Hyperliquid API. ### Method GET ### Endpoint `/health` ### Response #### Success Response (200) - **status** (string) - The health status of the API (e.g., "ok"). ### Response Example ```json { "status": "ok" } ``` ``` -------------------------------- ### GET /dexes Source: https://hyperliquidapi.com/llms.txt Retrieves a list of all supported HIP-3 DEX names and their corresponding indices. ```APIDOC ## GET /dexes ### Description Fetches a list of all DEXs that support HIP-3 markets, along with their unique indices. ### Method GET ### Endpoint `/dexes` ### Response #### Success Response (200) - **dexes** (array) - An array of DEX objects. - **name** (string) - The name of the DEX (e.g., "Camelot"). - **index** (number) - The index associated with the DEX. ### Response Example ```json { "dexes": [ { "name": "Camelot", "index": 1 }, { "name": "SpaceFi", "index": 2 } ] } ``` ``` -------------------------------- ### Get Open Orders - cURL Source: https://hyperliquidapi.com/ Retrieves a list of enriched open orders for a specified user, including pre-built cancel actions. This endpoint requires a POST request with a JSON body containing the user's address. ```curl curl -s -X POST https://send.hyperliquidapi.com/openOrders \ -H "Content-Type: application/json" \ -d '{ "user": "0x0000000000000000000000000000000000000000" }' ``` -------------------------------- ### Initialize Hyperliquid SDK (Python) Source: https://hyperliquidapi.com/ Initializes the Hyperliquid SDK with an endpoint and private key for programmatic trading. This is the first step to interacting with the Hyperliquid API using Python. ```python from hyperliquid_sdk import HyperliquidSDK endpoint = "YOUR_ENDPOINT" key = "YOUR_PRIVATE_KEY" sdk = HyperliquidSDK(endpoint, private_key=key) ``` -------------------------------- ### Build-Sign-Send Pattern Overview Source: https://hyperliquidapi.com/ Illustrates the fundamental three-step process for executing trades on Hyperliquid: building the order locally, signing it with a private key, and sending the signed payload to the API. ```text 1. Build the order locally (asset, size, price, type). 2. Sign the transaction with your private key on your machine. 3. Submit the signed payload to the Hyperliquid API endpoint. ``` -------------------------------- ### Build Market Order - POST /exchange Source: https://hyperliquidapi.com/ Builds a market order for exchange on Hyperliquid by specifying 'market' as the TIF. The system fetches the mid-price and applies slippage, returning a hash for signing. ```curl curl -s -X POST https://send.hyperliquidapi.com/exchange \ -H "Content-Type: application/json" \ -d '{ "action": { "type": "order", "orders": [ { "asset": "HYPE", "side": "buy", "size": "0.5", "tif": "market" } ] } }' ``` -------------------------------- ### POST /exchange - Build Order (No Signature) Source: https://hyperliquidapi.com/ Builds a limit order without requiring a signature. Accepts human-readable or wire format and returns a hash to be signed. Injects builder fee. ```APIDOC ## POST /exchange - Build Order ### Description Builds a limit order without requiring a signature. Accepts human-readable or wire format and returns a hash to be signed. Injects builder fee. ### Method POST ### Endpoint /exchange ### Parameters #### Request Body - **action** (object) - Required - Order details. - **type** (string) - Required - Must be "order". - **orders** (array) - Required - Array of order objects. - **asset** (string) - Required - Asset name (e.g., "BTC", "HYPE", "xyz:SILVER"). - **side** (string) - Required - "buy" or "sell". - **price** (string) - Optional - Limit price (omit for market orders). - **size** (string) - Required - Order size. - **tif** (string) - Required - Time-in-force: "ioc", "gtc", "alo", or "market". - **vaultAddress** (string) - Optional - Vault address. ### Request Example ```json { "action": { "type": "order", "orders": [ { "asset": "BTC", "side": "buy", "price": "100000", "size": "0.001", "tif": "ioc" } ] } } ``` ### Response #### Success Response (200) - **hash** (string) - Hash to sign. - **nonce** (number) - Nonce for the transaction. - **action** (object) - The constructed action object. - **isSpot** (boolean) - Indicates if the order is for spot trading. - **builderFee** (string) - The calculated builder fee. - **builder** (string) - The builder's address. ``` -------------------------------- ### Stream Real-Time Trades (Python) Source: https://hyperliquidapi.com/ Sets up a WebSocket stream to receive real-time trade data for specified assets. This is useful for applications requiring live market updates. ```python def callback(trade): print(trade) sdk.stream.trades(["BTC"], callback) ``` -------------------------------- ### Order Placement API Source: https://hyperliquidapi.com/ This section details the process of placing orders (market, limit, trigger) for perpetuals, spot, and HIP-3 markets using the Hyperliquid API. It emphasizes the build-sign-send pattern for secure transaction handling. ```APIDOC ## POST /orders ### Description This endpoint allows you to place various types of orders (market, limit, trigger) on Hyperliquid for perpetuals, spot, and HIP-3 markets. The process involves building the order parameters locally, signing the transaction with your private key, and then sending the signed payload to this API endpoint. ### Method POST ### Endpoint `/orders` ### Parameters #### Request Body - **orderType** (string) - Required - Type of order (e.g., 'MARKET', 'LIMIT', 'TRIGGER'). - **side** (string) - Required - 'BUY' or 'SELL'. - **baseAsset** (string) - Required - The base asset of the trading pair. - **quoteAsset** (string) - Required - The quote asset of the trading pair. - **quantity** (number) - Required - The amount of base asset to trade. - **price** (number) - Optional - The limit price for 'LIMIT' orders. - **triggerPrice** (number) - Optional - The trigger price for 'TRIGGER' orders. - **isTriggeringOrder** (boolean) - Optional - Indicates if this is a triggering order. - **metadata** (string) - Optional - Custom metadata for the order. ### Request Example ```json { "orderType": "LIMIT", "side": "BUY", "baseAsset": "BTC", "quoteAsset": "USDC", "quantity": 0.001, "price": 30000, "metadata": "my_limit_order_123" } ``` ### Response #### Success Response (200) - **orderId** (string) - The unique identifier for the placed order. - **status** (string) - The status of the order (e.g., 'OPEN', 'FILLED'). #### Response Example ```json { "orderId": "0xabc123...", "status": "OPEN" } ``` ``` -------------------------------- ### POST /exchange - Build Approval Source: https://hyperliquidapi.com/ Builds an action to approve the builder fee without requiring a signature. Returns hash and typedData. ```APIDOC ## POST /exchange - Build Approval ### Description Builds an action to approve the builder fee without requiring a signature. Returns hash and typedData. ### Method POST ### Endpoint /exchange ### Parameters #### Request Body - **action** (object) - Required - Approval details. - **type** (string) - Required - Must be "approveBuilderFee". - **maxFeeRate** (string) - Required - Maximum fee rate (e.g., "1%"). ### Request Example ```json { "action": { "type": "approveBuilderFee", "maxFeeRate": "1%" } } ``` ### Response #### Success Response (200) - **hash** (string) - Hash to sign. - **nonce** (number) - Nonce for the transaction. - **details** (object) - Approval details. - **builder** (string) - Builder's address. - **maxFeeRate** (string) - The approved maximum fee rate. - **chain** (string) - The chain ID. - **typedData** (object) - Typed data for signing. ``` -------------------------------- ### POST /exchange - Build Market Order Source: https://hyperliquidapi.com/ Builds a market order by fetching the mid-price and applying slippage. Returns a hash to sign. ```APIDOC ## POST /exchange - Build Market Order ### Description Builds a market order by fetching the mid-price and applying slippage. Returns a hash to sign. ### Method POST ### Endpoint /exchange ### Parameters #### Request Body - **action** (object) - Required - Order details. - **type** (string) - Required - Must be "order". - **orders** (array) - Required - Array of order objects. - **asset** (string) - Required - Asset name (e.g., "HYPE"). - **side** (string) - Required - "buy" or "sell". - **size** (string) - Required - Order size. - **tif** (string) - Required - Must be "market". - **slippage** (number) - Optional - Slippage tolerance as a decimal (e.g., 0.05 for 5%). Default is 3%. Range: 0.1%–10%. ### Request Example ```json { "action": { "type": "order", "orders": [ { "asset": "HYPE", "side": "buy", "size": "0.5", "tif": "market" } ] } } ``` ### Response #### Success Response (200) - **hash** (string) - Hash to sign. - **nonce** (number) - Nonce for the transaction. - **action** (object) - The constructed action object, including the computed price. - **isSpot** (boolean) - Indicates if the order is for spot trading. - **builderFee** (string) - The calculated builder fee. - **builder** (string) - The builder's address. - **appliedSlippage** (number) - The slippage that was applied. ``` -------------------------------- ### Place a Buy Order for HIP-3 Token (Python) Source: https://hyperliquidapi.com/ Executes a buy order for a HIP-3 token, which are community-driven perpetuals. This showcases the API's ability to handle diverse market types. ```python order = sdk.buy("xyz:SILVER", notional=11) print(f"Order placed for {order}") ``` -------------------------------- ### List Markets Source: https://hyperliquidapi.com/ Retrieve a list of all perpetual, spot, and HIP-3 markets available on Hyperliquid. An optional `?dex=` filter can be applied. ```APIDOC ## GET /markets ### Description Returns all perp, spot, and HIP-3 markets. Optional ?dex= filter. ### Method GET ### Endpoint /markets ### Query Parameters - **dex** (string) - Optional - Filter markets by DEX name. ### Response #### Success Response (200) - **perps** (array) - List of perpetual markets. - **spot** (array) - List of spot markets. - **hip3** (array) - List of HIP-3 markets. #### Response Example ```json { "perps": [], "spot": [], "hip3": [] } ``` ``` -------------------------------- ### Open Orders Source: https://hyperliquidapi.com/llms.txt Retrieves open orders for a given user, enriched with pre-built cancel actions. ```APIDOC ## POST /openOrders ### Description Retrieves open orders for a given user, enriched with pre-built cancel actions. ### Method POST ### Endpoint /openOrders ### Parameters #### Request Body - **user** (string) - Required - The user's address. ### Request Example ```json { "user": "0x..." } ``` ### Response #### Success Response (200) - **orders** (array) - Enriched order details with cancel actions. #### Response Example ```json { "orders": [ { "oid": 12345, "side": "buy", "price": 100.0, "amount": 1.0, "cancelAction": "..." } ] } ``` ``` -------------------------------- ### Build Limit Order - POST /exchange Source: https://hyperliquidapi.com/ Constructs a limit order for exchange on Hyperliquid. Accepts human-readable order details and returns a hash to be signed. Supports various Time-In-Force (TIF) options. ```curl curl -s -X POST https://send.hyperliquidapi.com/exchange \ -H "Content-Type: application/json" \ -d '{ "action": { "type": "order", "orders": [ { "asset": "BTC", "side": "buy", "price": "100000", "size": "0.001", "tif": "ioc" } ] } }' ``` -------------------------------- ### Send Approval for Builder Fee to Hyperliquid Exchange (curl) Source: https://hyperliquidapi.com/ Approves a maximum fee rate for builder fees on the Hyperliquid exchange. This action requires a wallet signature and specifies the `maxFeeRate`. The request is submitted to Hyperliquid for processing. ```curl curl -s -X POST https://send.hyperliquidapi.com/exchange \ -H "Content-Type: application/json" \ -d '{ "action": { "type": "approveBuilderFee", "maxFeeRate": "1%" }, "nonce": 0, "signature": { "r": "0x...", "s": "0x...", "v": 27 } }' ``` -------------------------------- ### POST /openOrders Source: https://hyperliquidapi.com/llms.txt Retrieves enriched open orders for a user, including pre-built cancel actions for each order. ```APIDOC ## POST /openOrders ### Description Retrieves a list of the user's open orders, with each order object containing a pre-built cancel action. ### Method POST ### Endpoint `/openOrders` ### Parameters #### Request Body - **user** (string) - Required - The user's Ethereum address. ### Request Example ```json { "user": "0x..." } ``` ### Response #### Success Response (200) - **openOrders** (array) - An array of open order objects, each including a `cancelAction`. ### Response Example ```json { "openOrders": [ { "orderId": 12345, "asset": "BTC", "side": "buy", "price": "100000", "size": "0.001", "tif": "ioc", "cancelAction": { "type": "cancel", "cancels": [ { "a": "BTC", "o": 12345 } ] } } ] } ``` ``` -------------------------------- ### POST /exchange - Build Close Position Source: https://hyperliquidapi.com/ Builds a market order to close an existing position. Allows specifying slippage tolerance. ```APIDOC ## POST /exchange - Build Close Position ### Description Builds a market order to close an existing position. Allows specifying slippage tolerance. ### Method POST ### Endpoint /exchange ### Parameters #### Request Body - **action** (object) - Required - Close position details. - **type** (string) - Required - Must be "closePosition". - **asset** (string) - Required - Asset name (e.g., "HYPE"). - **user** (string) - Required - Your wallet address (0x...). - **fraction** (number) - Optional - Fraction of the position to close (0-1). Defaults to 1.0 (full close). - **slippage** (number) - Optional - Slippage tolerance as a decimal (e.g., 0.05 for 5%). Default is 3%. Range: 0.1%–10%. ### Request Example ```json { "action": { "type": "closePosition", "asset": "HYPE", "user": "0x0000000000000000000000000000000000000000" } } ``` ### Response #### Success Response (200) - **hash** (string) - Hash to sign. - **nonce** (number) - Nonce for the transaction. - **action** (object) - The constructed close position action. - **appliedSlippage** (number) - The slippage that was applied. - **closePositionContext** (object) - Context related to the closed position. ``` -------------------------------- ### Build Close Position - POST /exchange Source: https://hyperliquidapi.com/ Constructs an order to close an existing position on Hyperliquid. It queries the current position and builds a market order, allowing for configurable slippage. ```curl curl -s -X POST https://send.hyperliquidapi.com/exchange \ -H "Content-Type: application/json" \ -d '{ "action": { "type": "closePosition", "asset": "HYPE", "user": "0x0000000000000000000000000000000000000000" } }' ``` -------------------------------- ### Retrieve L2 Order Book (Python) Source: https://hyperliquidapi.com/ Fetches the Level 2 order book for a given asset. This provides insight into the market depth and liquidity. ```python order_book = sdk.info.l2_book("ETH") print(order_book) ``` -------------------------------- ### Build Cancel Order - POST /exchange Source: https://hyperliquidapi.com/ Initiates the cancellation of one or more orders on Hyperliquid. This action returns a hash to be signed, along with a summary of the cancellation. ```curl curl -s -X POST https://send.hyperliquidapi.com/exchange \ -H "Content-Type: application/json" \ -d '{ "action": { "type": "cancel", "cancels": [ { "a": "BTC", "o": 12345 } ] } }' ``` -------------------------------- ### Build Approve Builder Fee - POST /exchange Source: https://hyperliquidapi.com/ Approves the builder fee for exchange actions on Hyperliquid. This action returns a hash and typed data necessary for signing the approval. ```curl curl -s -X POST https://send.hyperliquidapi.com/exchange \ -H "Content-Type: application/json" \ -d '{ "action": { "type": "approveBuilderFee", "maxFeeRate": "1%" } }' ``` -------------------------------- ### Hyperliquid API Overview Source: https://hyperliquidapi.com/ The Hyperliquid API is a zero-custody REST builder API for Hyperliquid, built by Quicknode. It allows users to trade perpetuals, spot, and HIP-3 markets programmatically while ensuring private keys never leave the user's machine. It follows a build-sign-send pattern for secure order execution. ```APIDOC ## Hyperliquid API Overview ### Description The Hyperliquid API provides a secure and non-custodial way to interact with the Hyperliquid exchange. It enables programmatic trading of various market types including perpetuals, spot, and HIP-3 markets. The core principle is the build-sign-send pattern, where orders are constructed and signed locally before being sent to the API for forwarding to Hyperliquid, ensuring your private keys remain on your machine. ### Key Features * **Zero-Custody:** Private keys are never shared or transmitted. * **Market Support:** Trade perpetuals, spot, and HIP-3 markets. * **Build-Sign-Send Pattern:** Secure order execution flow. * **SDKs:** Examples available for Python, TypeScript, and Rust. * **REST API:** A comprehensive REST API with multiple endpoints. ### Trading Fees * **Perpetuals:** 0.04% builder fee (on top of Hyperliquid's native fees). * **Spot:** 0.05% builder fee (on top of Hyperliquid's native fees). ### Supported Languages Python, TypeScript, Rust, and any language with an HTTP client. ``` -------------------------------- ### Approve Builder Fee Source: https://hyperliquidapi.com/llms.txt One-time approval required before trading to cover builder fees. ```APIDOC ## POST /exchange ### Description Approves the builder fee for trading via the Hyperliquid API. This is a one-time approval. ### Method POST ### Endpoint /exchange ### Parameters #### Request Body - **action** (object) - Required - The 'approveBuilderFee' action. ### Request Example ```json { "action": { "type": "approveBuilderFee" } } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the approval was successful. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### POST /preflight Source: https://hyperliquidapi.com/llms.txt Validates an order without requiring a signature, allowing for pre-trade checks. ```APIDOC ## POST /preflight ### Description Validates a potential order against current market conditions and user state without committing to a trade or requiring a signature. ### Method POST ### Endpoint `/preflight` ### Parameters #### Request Body - **user** (string) - Required - The user's Ethereum address. - **action** (object) - Required - The order action to validate. ### Request Example ```json { "user": "0x...", "action": { "type": "order", "orders": [ { "asset": "BTC", "side": "buy", "price": "100000", "size": "0.001", "tif": "ioc" } ] } } ``` ### Response #### Success Response (200) - **valid** (boolean) - Indicates if the order is valid. - **message** (string) - A message explaining the validation result. - **details** (object) - Additional details about the validation. ### Response Example ```json { "valid": true, "message": "Order is valid and can be submitted.", "details": {} } ``` ``` -------------------------------- ### POST /exchange - Build Revoke Source: https://hyperliquidapi.com/ Builds an action to revoke builder fee approval by setting maxFeeRate to "0%" without requiring a signature. Returns hash and typedData. ```APIDOC ## POST /exchange - Build Revoke ### Description Builds an action to revoke builder fee approval by setting maxFeeRate to "0%" without requiring a signature. Returns hash and typedData. ### Method POST ### Endpoint /exchange ### Parameters #### Request Body - **action** (object) - Required - Revoke details. - **type** (string) - Required - Must be "approveBuilderFee". - **maxFeeRate** (string) - Required - Set to "0%" to revoke. ### Request Example ```json { "action": { "type": "approveBuilderFee", "maxFeeRate": "0%" } } ``` ### Response #### Success Response (200) - **hash** (string) - Hash to sign. - **nonce** (number) - Nonce for the transaction. - **details** (object) - Revocation details. - **builder** (string) - Builder's address. - **maxFeeRate** (string) - Set to "0%". - **chain** (string) - The chain ID. - **typedData** (object) - Typed data for signing. ``` -------------------------------- ### POST /exchange - Build Cancel Source: https://hyperliquidapi.com/ Builds a cancel order action without requiring a signature. Returns a hash to sign. ```APIDOC ## POST /exchange - Build Cancel ### Description Builds a cancel order action without requiring a signature. Returns a hash to sign. ### Method POST ### Endpoint /exchange ### Parameters #### Request Body - **action** (object) - Required - Cancel details. - **type** (string) - Required - Must be "cancel". - **cancels** (array) - Required - Array of orders to cancel. - **a** (string) - Required - Asset name (e.g., "BTC"). - **o** (number) - Required - Order ID. - **vaultAddress** (string) - Optional - Vault address. - **expiresAfter** (number) - Optional - Expiry time in milliseconds. ### Request Example ```json { "action": { "type": "cancel", "cancels": [ { "a": "BTC", "o": 12345 } ] } } ``` ### Response #### Success Response (200) - **hash** (string) - Hash to sign. - **nonce** (number) - Nonce for the transaction. - **action** (object) - The constructed cancel action. - **summary** (string) - A summary of the cancellation. - **assets** (array) - List of assets involved in the cancellation. ``` -------------------------------- ### List Markets - cURL Source: https://hyperliquidapi.com/ Retrieves a list of all available perpetual, spot, and HIP-3 markets. An optional 'dex' query parameter can be used to filter markets by a specific DEX. ```curl curl -s https://send.hyperliquidapi.com/markets ``` -------------------------------- ### Send Order to Hyperliquid Exchange (curl) Source: https://hyperliquidapi.com/ Submits a new order to the Hyperliquid exchange. This requires a wallet signature and includes order details such as asset, side, price, size, and time-in-force. The API checks approval and forwards the order to Hyperliquid. ```curl curl -s -X POST https://send.hyperliquidapi.com/exchange \ -H "Content-Type: application/json" \ -d '{ "action": { "type": "order", "orders": [ { "asset": "BTC", "side": "buy", "price": "100000", "size": "0.001", "tif": "ioc" } ] }, "nonce": 0, "signature": { "r": "0x...", "s": "0x...", "v": 27 } }' ``` -------------------------------- ### POST /orderStatus Source: https://hyperliquidapi.com/llms.txt Retrieves the status of specific orders with a plain-English explanation. ```APIDOC ## POST /orderStatus ### Description Fetches the status of specified orders and provides a human-readable explanation for each status. ### Method POST ### Endpoint `/orderStatus` ### Parameters #### Request Body - **user** (string) - Required - The user's Ethereum address. - **orderIds** (array) - Required - An array of order IDs to check. ### Request Example ```json { "user": "0x...", "orderIds": [12345, 67890] } ``` ### Response #### Success Response (200) - **statuses** (object) - An object where keys are order IDs and values are status objects. - **status** (string) - The status of the order (e.g., "Filled", "Canceled", "Open"). - **explanation** (string) - A plain-English explanation of the status. ### Response Example ```json { "statuses": { "12345": { "status": "Filled", "explanation": "The order has been completely filled." }, "67890": { "status": "Canceled", "explanation": "The order was canceled by the user." } } } ``` ``` -------------------------------- ### Build Modify Order - POST /exchange Source: https://hyperliquidapi.com/ Allows for batch modification of existing orders on Hyperliquid. This endpoint returns a hash for signing and a summary of the modifications. ```curl curl -s -X POST https://send.hyperliquidapi.com/exchange \ -H "Content-Type: application/json" \ -d '{ "action": { "type": "batchModify", "modifies": [ { "oid": 12345, "order": { "a": "BTC", "b": true, "p": "100001", "s": "0.001", "r": false, "t": { "limit": { "tif": "Gtc" } } } } ] } }' ``` -------------------------------- ### List DEXes Source: https://hyperliquidapi.com/llms.txt Retrieves a list of available DEXes. ```APIDOC ## GET /dexes ### Description Retrieves a list of available DEXes. ### Method GET ### Endpoint /dexes ### Response #### Success Response (200) - **dexes** (array) - List of DEX objects, each containing 'name' and 'index'. #### Response Example ```json { "dexes": [ { "name": "DEX_A", "index": 0 }, { "name": "DEX_B", "index": 1 } ] } ``` ``` -------------------------------- ### POST /exchange - Send Approval Source: https://hyperliquidapi.com/ Sends a signed approveBuilderFee action to the Hyperliquid exchange. This submits the fee approval to Hyperliquid. ```APIDOC ## POST /exchange - Send Approval ### Description Sends a signed approveBuilderFee action to the Hyperliquid exchange. This submits the fee approval to Hyperliquid. ### Method POST ### Endpoint /exchange ### Parameters #### Request Body - **action** (object) - Required - The approveBuilderFee action details, including `maxFeeRate`. - **nonce** (number) - Required - A nonce from the build response. - **signature** (object) - Required - The signature object containing r, s, and v. ### Request Example ```json { "action": { "type": "approveBuilderFee", "maxFeeRate": "1%" }, "nonce": 0, "signature": { "r": "0x...", "s": "0x...", "v": 27 } } ``` ### Response #### Success Response (200) - **approved** (boolean) - Indicates if the fee was approved. - **builder** (string) - The builder identifier. - **maxFeeRate** (string) - The maximum fee rate. - **user** (string) - The user identifier. - **message** (string) - A message related to the approval. - **exchangeResponse** (object) - The response from the Hyperliquid exchange. ``` -------------------------------- ### POST /exchange - Build Modify Source: https://hyperliquidapi.com/ Builds a batch modify order action without requiring a signature. Returns a hash to sign. ```APIDOC ## POST /exchange - Build Modify ### Description Builds a batch modify order action without requiring a signature. Returns a hash to sign. ### Method POST ### Endpoint /exchange ### Parameters #### Request Body - **action** (object) - Required - Modify details. - **type** (string) - Required - Must be "batchModify". - **modifies** (array) - Required - Array of modifications. - **oid** (number) - Required - Order ID to modify. - **order** (object) - Required - The new order parameters. - **a** (string) - Asset name. - **b** (boolean) - Buy/Sell flag. - **p** (string) - Price. - **s** (string) - Size. - **r** (boolean) - Reduce only flag. - **t** (object) - Time-in-force details. - **limit** (object) - **tif** (string) - Time-in-force type (e.g., "Gtc"). - **vaultAddress** (string) - Optional - Vault address. - **expiresAfter** (number) - Optional - Expiry time in milliseconds. ### Request Example ```json { "action": { "type": "batchModify", "modifies": [ { "oid": 12345, "order": { "a": "BTC", "b": true, "p": "100001", "s": "0.001", "r": false, "t": { "limit": { "tif": "Gtc" } } } } ] } } ``` ### Response #### Success Response (200) - **hash** (string) - Hash to sign. - **nonce** (number) - Nonce for the transaction. - **action** (object) - The constructed modify action. - **summary** (string) - A summary of the modification. - **assets** (array) - List of assets involved in the modification. ``` -------------------------------- ### List Markets Source: https://hyperliquidapi.com/llms.txt Retrieves a list of available markets, with an optional DEX filter. ```APIDOC ## GET /markets ### Description Retrieves a list of available markets, with an optional DEX filter. ### Method GET ### Endpoint /markets ### Parameters #### Query Parameters - **dex** (string) - Optional - Filter markets by a specific DEX. ### Response #### Success Response (200) - **perps** (object) - Perpetual markets data. - **spot** (object) - Spot markets data. - **hip3** (object) - HIP3 markets data. #### Response Example ```json { "perps": { ... }, "spot": { ... }, "hip3": { ... } } ``` ``` -------------------------------- ### Order Status Source: https://hyperliquidapi.com/llms.txt Retrieves the status of a specific order with a plain-English explanation. ```APIDOC ## POST /orderStatus ### Description Retrieves the status of a specific order with a plain-English explanation. ### Method POST ### Endpoint /orderStatus ### Parameters #### Request Body - **user** (string) - Required - The user's address. - **oid** (integer) - Required - The order ID. ### Request Example ```json { "user": "0x...", "oid": 12345 } ``` ### Response #### Success Response (200) - **status** (string) - The order status. - **statusExplanation** (string) - A plain-English explanation of the status. #### Response Example ```json { "status": "filled", "statusExplanation": "The order has been completely filled." } ``` ``` -------------------------------- ### Check Approval Status - cURL Source: https://hyperliquidapi.com/ Checks the approval status for a given address, including fee rate details and trading capabilities for perpetuals and spot markets. It returns a JSON object with approval status and fee information. ```curl curl -s https://send.hyperliquidapi.com/approval?user=0x0000000000000000000000000000000000000000 ``` -------------------------------- ### POST /exchange - Send Order Source: https://hyperliquidapi.com/ Sends a signed order action to the Hyperliquid exchange. This endpoint checks approvals and forwards the order to Hyperliquid for execution. ```APIDOC ## POST /exchange - Send Order ### Description Sends a signed order action to the Hyperliquid exchange. This endpoint checks approvals and forwards the order to Hyperliquid for execution. ### Method POST ### Endpoint /exchange ### Parameters #### Request Body - **action** (object) - Required - The order action details. - **nonce** (number) - Required - A nonce from the build response. - **signature** (object) - Required - The signature object containing r, s, and v. - **vaultAddress** (string) - Optional - The vault address. - **expiresAfter** (number) - Optional - Expiry time in milliseconds. - **slippage** (number) - Optional - Slippage for market orders (default 3%). ### Request Example ```json { "action": { "type": "order", "orders": [ { "asset": "BTC", "side": "buy", "price": "100000", "size": "0.001", "tif": "ioc" } ] }, "nonce": 0, "signature": { "r": "0x...", "s": "0x...", "v": 27 } } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **user** (string) - The user identifier. - **exchangeResponse** (object) - The response from the Hyperliquid exchange. ``` -------------------------------- ### List DEXes - cURL Source: https://hyperliquidapi.com/ Returns a list of all available HIP-3 DEX names along with their corresponding indices. This endpoint helps in identifying and interacting with different decentralized exchanges. ```curl curl -s https://send.hyperliquidapi.com/dexes ``` -------------------------------- ### Preflight Order Validation Source: https://hyperliquidapi.com/llms.txt Validates an order in a human-readable format without requiring signing. ```APIDOC ## POST /preflight ### Description Validates an order in a human-readable format without requiring signing. ### Method POST ### Endpoint /preflight ### Parameters #### Request Body - **action** (object) - Required - The order action in a human-readable format. ### Request Example ```json { "action": { "type": "limit", "side": "buy", "price": 100.0, "amount": 1.0, "instrument": "ETH" } } ``` ### Response #### Success Response (200) - **isValid** (boolean) - Indicates if the order is valid. - **message** (string) - A message detailing the validation result. #### Response Example ```json { "isValid": true, "message": "Order is valid." } ``` ``` -------------------------------- ### Send Modify Order to Hyperliquid Exchange (curl) Source: https://hyperliquidapi.com/ Modifies an existing order on the Hyperliquid exchange using a batchModify action. This requires a wallet signature and includes the order ID and the new order parameters. The request is forwarded to Hyperliquid. ```curl curl -s -X POST https://send.hyperliquidapi.com/exchange \ -H "Content-Type: application/json" \ -d '{ "action": { "type": "batchModify", "modifies": [ { "oid": 12345, "order": { "a": "BTC", "b": true, "p": "100001", "s": "0.001", "r": false, "t": { "limit": { "tif": "Gtc" } } } } ] }, "nonce": 0, "signature": { "r": "0x...", "s": "0x...", "v": 27 } }' ``` -------------------------------- ### Build Revoke Builder Fee - POST /exchange Source: https://hyperliquidapi.com/ Revokes the builder fee approval for exchange actions on Hyperliquid by setting the maxFeeRate to '0%'. Returns a hash and typed data for signing. ```curl curl -s -X POST https://send.hyperliquidapi.com/exchange \ -H "Content-Type: application/json" \ -d '{ "action": { "type": "approveBuilderFee", "maxFeeRate": "0%" } }' ```