hyperliquid-python-sdk

repository·master·Indexed 23 days ago

https://github.com/hyperliquid-dex/hyperliquid-python-sdk

A Python SDK for interacting with the Hyperliquid API, enabling automated trading and data retrieval. Version 0.24.0 provides tools for managing account credentials, using API Wallets for security, and fetching user state via the Info class.

Tokens
507
Snippets
3
Records
5
Agent score
33%

What's inside hyperliquid-python-sdk

  1. Use an API Wallet for trading

    master

    For enhanced security, you can use an API Wallet instead of your main wallet's private key:

    1. Generate and authorize a new API private key at https://app.hyperliquid.xyz/API.
    2. Set the API wallet's private key as the secret_key in your configuration (e.g., examples/config.json).
    3. Important: You must still set the public key of your main wallet (not the API wallet) as the account_address in your configuration.
  2. Configure the SDK with account credentials

    master

    To use the SDK, you must configure your account details. If you are using the provided examples, you can set these in examples/config.json:

    • account_address: Your public key.
    • secret_key: Your private key.

    For more information on how to load this configuration, refer to examples/example_utils.py.

  3. Fetch user state using the Info class

    master

    You can use the Info class to retrieve information from the Hyperliquid API. The following example demonstrates how to initialize the Info client using the testnet URL and fetch the state for a specific address.

    from hyperliquid.info import Info
    from hyperliquid.utils import constants
    
    info = Info(constants.TESTNET_API_URL, skip_ws=True)
    user_state = info.user_state("0xcd5051944f780a621ee62e39e493c489668acf4d")
    print(user_state)