### Python SDK Example for EVM Block Indexer Source: https://hyperliquid.gitbook.io/hyperliquid-docs/onboarding/how-to-use-the-hyperevm.md This example demonstrates how to use the Hyperliquid Python SDK to index blocks from the EVM. It requires the SDK to be installed and configured. ```python from hyperliquid_python_sdk.subgraphs.evm import get_evm_client def main(): client = get_evm_client() # Example: Fetch the latest block number latest_block = client.get_block_number() print(f"Latest EVM block number: {latest_block}") # Example: Fetch details of a specific block (e.g., block 1) block_details = client.get_block_by_number(1) print(f"Details for block 1: {block_details}") if __name__ == "__main__": main() ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://hyperliquid.gitbook.io/hyperliquid-docs/historical-data.md This example shows how to dynamically query the documentation by making an HTTP GET request to the page URL with 'ask' and optional 'goal' query parameters. Use this to retrieve information not explicitly present on the page or to get clarification. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/historical-data.md?ask=&goal= ``` -------------------------------- ### HTTP GET Request for Documentation Query Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket.md Example of performing an HTTP GET request to query the documentation dynamically. Use the 'ask' parameter for specific questions and optionally 'goal' for broader context. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket.md?ask=&goal= ``` -------------------------------- ### Querying Documentation with GET Request Source: https://hyperliquid.gitbook.io/hyperliquid-docs/support/faq/trade-outcome-looks-incorrect/what-does-action-already-expired-mean.md Use this GET request to query the documentation dynamically. Include your question in the `ask` parameter and optionally specify your broader goal in the `goal` parameter. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/support/faq/trade-outcome-looks-incorrect/what-does-action-already-expired-mean.md?ask=&goal= ``` -------------------------------- ### Query Documentation with GET Request Source: https://hyperliquid.gitbook.io/hyperliquid-docs/support/faq/building-on-hyperliquid/i-have-api-related-questions.md Use this HTTP GET request to query the documentation dynamically. Include your question in the `ask` parameter and an optional broader goal in the `goal` parameter. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/support/faq/building-on-hyperliquid/i-have-api-related-questions.md?ask=&goal= ``` -------------------------------- ### Querying Documentation with GET Request Source: https://hyperliquid.gitbook.io/hyperliquid-docs/hyperliquid-improvement-proposals-hips/hip-3-builder-deployed-perpetuals.md Use this GET request to ask questions about the documentation. Include your specific question in the 'ask' parameter and an optional broader goal in the 'goal' parameter. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/hyperliquid-improvement-proposals-hips/hip-3-builder-deployed-perpetuals.md?ask=&goal= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm/interacting-with-hypercore.md To query this documentation dynamically, perform an HTTP GET request on the current page URL with the `ask` query parameter and an optional `goal` parameter. The response will contain an answer and relevant excerpts. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm/interacting-with-hypercore.md?ask=&goal= ``` -------------------------------- ### Query Documentation with Agent Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/error-responses.md Perform an HTTP GET request to query the documentation. Use the `ask` parameter for your question and optionally the `goal` parameter for broader context. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/error-responses.md?ask=&goal= ``` -------------------------------- ### Querying Documentation Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/nodes/foundation-non-validating-node.md To get additional information not directly on a page, make an HTTP GET request to the page URL with the 'ask' query parameter and an optional 'goal' parameter. ```bash GET https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/nodes/foundation-non-validating-node.md?ask=&goal= ``` -------------------------------- ### Query Documentation with Ask and Goal Parameters Source: https://hyperliquid.gitbook.io/hyperliquid-docs/support/faq/deposit-or-transfer-issues-missing-lost/deposited-via-solana-network.md Use this GET request to query the documentation dynamically. The 'ask' parameter is for your specific question, and 'goal' is optional for tailoring the answer to a broader objective. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/support/faq/deposit-or-transfer-issues-missing-lost/deposited-via-solana-network.md?ask=&goal= ``` -------------------------------- ### Query Documentation GET Request Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint.md To get information not explicitly on the page, perform an HTTP GET request to the page URL with 'ask' and optional 'goal' query parameters. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint.md?ask=&goal= ``` -------------------------------- ### Querying Documentation Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm/dual-block-architecture.md Perform an HTTP GET request on the current page URL with the `ask` query parameter and an optional `goal` query parameter to query the documentation dynamically. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm/dual-block-architecture.md?ask=&goal= ``` -------------------------------- ### Query Documentation with Ask and Goal Parameters Source: https://hyperliquid.gitbook.io/hyperliquid-docs/support/faq/trade-outcome-looks-incorrect/why-was-i-liquidated.md Use this GET request to ask specific questions about the documentation. The 'goal' parameter can help tailor the response to a broader objective. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/support/faq/trade-outcome-looks-incorrect/why-was-i-liquidated.md?ask=&goal= ``` -------------------------------- ### Querying Documentation via HTTP GET Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm/wrapped-hype.md To get additional information not directly on the page, make an HTTP GET request to the page URL with the `ask` query parameter for a specific question and an optional `goal` parameter for broader context. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm/wrapped-hype.md?ask=&goal= ``` -------------------------------- ### Querying Documentation Dynamically Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/asset-ids.md To get additional information not directly on a page, perform an HTTP GET request to the page URL with 'ask' and optional 'goal' query parameters. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/asset-ids.md?ask=&goal= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees.md Perform an HTTP GET request to the current page URL with the `ask` query parameter for a specific question and an optional `goal` parameter for the broader objective. The response includes a direct answer, relevant excerpts, and sources. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees.md?ask=&goal= ``` -------------------------------- ### Query Documentation with HTTP GET Source: https://hyperliquid.gitbook.io/hyperliquid-docs/hypercore.md Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections. Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/hypercore.md?ask=&goal= ``` -------------------------------- ### Example: L2Book Info Request Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/post-requests.md An example of sending an L2Book info request via the WebSocket API to retrieve order book data for a specific coin. ```APIDOC ## Example: L2Book Info Request ### Description This example demonstrates how to send an L2Book info request to the WebSocket API to get detailed order book information. ### Method POST (via WebSocket) ### Request Body ```json { "method": "post", "id": 123, "request": { "type": "info", "payload": { "type": "l2Book", "coin": "ETH", "nSigFigs": 5, "mantissa": null } } } ``` ### Response Example (Success) ```json { "channel": "post", "data": { "id": 123, "response": { "type": "info", "payload": { "type": "l2Book", "data": { "coin": "ETH", "time": 1678886400000, "levels": [ [{"px":"3007.1","sz":"2.7954","n":1}], [{"px":"3040.1","sz":"3.9499","n":1}] ] } } } } } ``` ``` -------------------------------- ### AQAv2 Revenue Accrual Example Source: https://hyperliquid.gitbook.io/hyperliquid-docs/hypercore/aligned-quote-assets.md Illustrates the calculation and payment intervals for system interest address revenue under the AQAv2 specification. This example shows how daily balances (X) and effective rates (RATE) are used to calculate payments over 30-day intervals. ```plaintext Jan 1: X1 = balance at 0 UTC, RATE1 = AQA-publisher effective rate, published onchain by validators Jan 2: X2, RATE2 (analogously defined) ... Jan 31: X31, RATE31 Feb 1: X32, RATE32 Feb 7: X38, RATE38 Feb 28: X59, RATE59 Mar 1: X60, RATE60 System interest address pays X1 * RATE1 + X2 * RATE2 + ... X30 * RATE30 on Feb 7 at 0 UTC System interest address pays X31 * RATE31 + ... + X60 * RATE60 on Mar 9 at 0 UTC ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://hyperliquid.gitbook.io/hyperliquid-docs/support/faq Use this method to ask questions about the documentation dynamically. Include your question in the 'ask' parameter and an optional broader goal in the 'goal' parameter. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/support/faq.md?ask=&goal= ``` -------------------------------- ### Query HyperEVM Documentation Dynamically Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm.md Perform an HTTP GET request to query the documentation. Use the 'ask' parameter for specific questions and optionally the 'goal' parameter for broader context. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm.md?ask=&goal= ``` -------------------------------- ### Query Documentation Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint.md Perform an HTTP GET request to query the documentation dynamically. Use the 'ask' parameter for specific questions and optionally the 'goal' parameter for broader objectives. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint.md?ask=&goal= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://hyperliquid.gitbook.io/hyperliquid-docs/audits.md Use this mechanism to retrieve information not explicitly present on the current page, to get clarification, or to find related documentation sections. The 'ask' parameter is for the immediate question, and 'goal' is optional for specifying the broader objective. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/audits.md?ask=&goal= ``` -------------------------------- ### Connect to WebSocket and Subscribe to Trades Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket.md Example of connecting to the mainnet WebSocket API using wscat and subscribing to SOL trades. Automated users should handle disconnections gracefully and reconnect. ```bash $ wscat -c wss://api.hyperliquid.xyz/ws Connected (press CTRL+C to quit) > { "method": "subscribe", "subscription": { "type": "trades", "coin": "SOL" } } < {"channel":"subscriptionResponse","data":{"method":"subscribe","subscription":{"type":"trades","coin":"SOL"}}} ``` -------------------------------- ### Query Documentation API Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/deploying-hip-1-and-hip-2-assets.md Perform an HTTP GET request to query the documentation dynamically. Use the `ask` parameter for specific questions and the optional `goal` parameter to tailor the response. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/deploying-hip-1-and-hip-2-assets.md?ask=&goal= ``` -------------------------------- ### Query Hyperliquid Documentation API Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/rate-limits-and-user-limits.md Use this GET request to query the documentation dynamically. Include your specific question in the `ask` parameter and an optional broader goal in the `goal` parameter. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/rate-limits-and-user-limits.md?ask=&goal= ``` -------------------------------- ### Ask a Question via Documentation API Source: https://hyperliquid.gitbook.io/hyperliquid-docs/support Use this GET request to ask a specific question about the documentation. The 'ask' parameter is required for your question, and the 'goal' parameter is optional to tailor the response. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/hypercore.md?ask=&goal= ``` -------------------------------- ### Query Documentation with Ask and Goal Parameters Source: https://hyperliquid.gitbook.io/hyperliquid-docs/bug-bounty-program.md Use this GET request to ask questions about the documentation. The 'ask' parameter specifies the question, and the optional 'goal' parameter provides context for the desired outcome. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/bug-bounty-program.md?ask=&goal= ``` -------------------------------- ### Retrieve Perp Deploy Auction Status Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals.md Use this endpoint to get the status of the perpetual deploy auction. The response includes start time, duration, and gas-related information. ```json { "startTimeSeconds": 1747656000, "durationSeconds": 111600, "startGas": "500.0", "currentGas": "500.0", "endGas": null } ``` -------------------------------- ### Querying Documentation with Ask and Goal Parameters Source: https://hyperliquid.gitbook.io/hyperliquid-docs/hypercore/order-book.md Use this mechanism to query documentation dynamically. Perform an HTTP GET request with the `ask` query parameter for a specific question and an optional `goal` parameter for broader context. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/hypercore/order-book.md?ask=&goal= ``` -------------------------------- ### Perp Annotation Response Example Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals.md This is an example of a successful (200 OK) response when requesting perp annotation data. It includes category and description fields. ```json { "category": "other", "description": "other perps" } ``` -------------------------------- ### Example: Order Signed Action Request Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/post-requests.md An example of sending an order signed action request via the WebSocket API to place a limit order. ```APIDOC ## Example: Order Signed Action Request ### Description This example shows how to submit a signed order action request through the WebSocket API to place a new order on the exchange. ### Method POST (via WebSocket) ### Request Body ```json { "method": "post", "id": 256, "request": { "type": "action", "payload": { "action": { "type": "order", "orders": [ { "a": 4, "b": true, "p": "1100", "s": "0.2", "r": false, "t": {"limit": {"tif": "Gtc"}} } ], "grouping": "na" }, "nonce": 1713825891591, "signature": { "r": "...", "s": "...", "v": "..." }, "vaultAddress": "0x12...3" } } } ``` ### Response Example (Success) ```json { "channel": "post", "data": { "id": 256, "response": { "type": "action", "payload": { "status": "ok", "response": { "type": "order", "data": { "statuses": [ { "resting": { "oid": 88383 } } ] } } } } } } ``` ``` -------------------------------- ### Query Documentation Dynamically Source: https://hyperliquid.gitbook.io/hyperliquid-docs/builder-tools/read-me-builder-tools.md Perform an HTTP GET request to query the documentation. Use the `ask` parameter for specific questions and the optional `goal` parameter to tailor the response to your end objective. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/builder-tools/read-me-builder-tools.md?ask=&goal= ``` -------------------------------- ### Signed Hyperliquid Withdrawal Action Example (JSON) Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/bridge2.md An example of a signed withdrawal action payload in JSON format, used for submitting withdrawal requests. Note that the 'nonce' must match the 'time' field. ```json { "action": { "type": "withdraw3", "signatureChainId": "0xa4b1", "hyperliquidChain": "Mainnet" or "Testnet" "destination": "0x000....0", "amount": "12.3", "time": 1698693262 }, "nonce": 1698693262, // IMPORTANT: this must match "time", "signature": {"r": ..., "s": ..., "v": ... } // signedTypedData output based on Eip712 implementation above. See python sdk for equivalent python code } ``` -------------------------------- ### Query Documentation with Ask Parameter Source: https://hyperliquid.gitbook.io/hyperliquid-docs/trading/perpetual-assets.md Use this GET request to query the documentation dynamically. The 'ask' parameter specifies your question, and the optional 'goal' parameter helps tailor the answer to your broader objective. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/trading/perpetual-assets.md?ask=&goal= ``` -------------------------------- ### Query Documentation Dynamically Source: https://hyperliquid.gitbook.io/hyperliquid-docs/support/faq/connectivity-issues.md Perform an HTTP GET request to query the documentation. Use the `ask` parameter for specific questions and the optional `goal` parameter to tailor the answer to a broader objective. This is useful when information is not explicitly present on the current page. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/support/faq/connectivity-issues.md?ask=&goal= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://hyperliquid.gitbook.io/hyperliquid-docs/trading/liquidations.md Use this method to dynamically query the documentation when information is not explicitly present or when clarification is needed. The `ask` parameter is mandatory for specifying the question, and the `goal` parameter is optional for tailoring the answer. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/trading/liquidations.md?ask=&goal= ``` -------------------------------- ### Successful Response Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint.md This is an example of a successful response when updating isolated margin or performing other exchange actions. ```python {'status': 'ok', 'response': {'type': 'default'}} ``` -------------------------------- ### Query Documentation with AI Agent Source: https://hyperliquid.gitbook.io/hyperliquid-docs/hypercore/staking.md Use this HTTP GET request to ask questions about the documentation. Include a specific question in the `ask` parameter and an optional broader goal in the `goal` parameter to tailor the AI's response. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/hypercore/staking.md?ask=&goal= ``` -------------------------------- ### Query Documentation with GET Request Source: https://hyperliquid.gitbook.io/hyperliquid-docs/onboarding/export-your-email-wallet.md Use this mechanism to query the documentation dynamically when information is not explicitly present on the current page. The `ask` parameter is for the specific question, and the optional `goal` parameter helps tailor the answer to a broader objective. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/onboarding/export-your-email-wallet.md?ask=&goal= ``` -------------------------------- ### Retrieve Predicted Funding Rates Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals.md Use this endpoint to get predicted funding rates for perpetuals. Only the first perpetual DEX is supported. ```json [ [ "AVAX", [ [ "BinPerp", { "fundingRate": "0.0001", "nextFundingTime": 1733961600000 } ], [ "HlPerp", { "fundingRate": "0.0000125", "nextFundingTime": 1733958000000 } ], [ "BybitPerp", { "fundingRate": "0.0001", "nextFundingTime": 1733961600000 } ] ] ],... ] ``` -------------------------------- ### Query Documentation with HTTP GET Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions.md Use this method to ask questions about the documentation when the answer is not explicitly present on the current page. The 'ask' parameter takes a specific question, and the optional 'goal' parameter helps tailor the response. ```http GET https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions.md?ask=&goal= ``` -------------------------------- ### Example Order Status Schema Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/nodes/l1-data-schemas.md This JSON object details the status of an order, including its cancellation, user, and original order parameters. ```json { "time": "2024-07-26T08:31:48.717", "user": "0xc64cc00b46101bd40aa1c3121195e85c0b0918d8", "status": "canceled", "order": { "coin": "INJ", "side": "A", "limitPx": "25.381", // filled size "sz": "257.0", "oid": 12212359592, "timestamp": 1721982700270, "triggerCondition": "N/A", "isTrigger": false, "triggerPx": "0.0", "children": [], "isPositionTpsl": false, "reduceOnly": false, "orderType": "Limit", // original order size "origSz": "257.0", "tif": "Alo", "cloid": null } } ``` -------------------------------- ### Exchange Endpoint Request and Response Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint.md This snippet details the request body parameters for placing an order and provides examples of successful and error responses. ```APIDOC ## POST /exchange ### Description This endpoint is used for placing orders on the exchange. It requires a nonce for uniqueness and can optionally include vault address and expiration time. ### Method POST ### Endpoint /exchange ### Parameters #### Request Body - **nonce** (Number) - Required - Recommended to use the current timestamp in milliseconds - **signature** (Object) - Required - **vaultAddress** (String) - Optional - If trading on behalf of a vault or subaccount, its Onchain address in 42-character hexadecimal format; e.g. 0x0000000000000000000000000000000000000000 - **expiresAfter** (Number) - Optional - Timestamp in milliseconds ### Response #### Success Response (200 - resting) - **status** (String) - "ok" - **response** (Object) - **type** (String) - "order" - **data** (Object) - **statuses** (Array) - **resting** (Object) - **oid** (Number) #### Response Example (resting) { "status": "ok", "response": { "type": "order", "data": { "statuses": [ { "resting": { "oid": 77738308 } } ] } } } #### Success Response (200 - filled) (Details for filled response not provided in source) #### Error Response (200) - **status** (String) - "ok" - **response** (Object) - **type** (String) - "order" - **data** (Object) - **statuses** (Array) - **error** (String) #### Response Example (error) { "status": "ok", "response": { "type": "order", "data": { "statuses": [ { "error": "Order must have minimum value of $10." } ] } } } ``` -------------------------------- ### Retrieve Mids for All Coins Source: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint.md Use this endpoint to get the mid-prices for all available coins. If the order book is empty, the last trade price is used as a fallback. ```json { "APE": "4.33245", "ARB": "1.21695" } ```