Installation

This guide covers how to install the Hyperliquid Python SDK for both regular use and for development purposes.

Standard Installation

For most users, installing the SDK is a simple process using pip.

pip install hyperliquid-python-sdk

This command will download and install the latest stable version of the package from the Python Package Index (PyPI).

Core Dependencies

The SDK relies on a few key libraries to function. These are automatically installed when you use pip:

  • eth-account: For handling Ethereum-style account creation and message signing.
  • eth-utils: Provides utility functions for Ethereum-related data.
  • requests: For making HTTP requests to the Hyperliquid REST API.
  • websocket-client: To connect to and handle real-time data from the WebSocket API.
  • msgpack: For efficient serialization of data in API requests.

Development Setup

If you plan to contribute to the SDK or want to install it from the source, you'll need to set up a development environment. This project uses Poetry for dependency management.

Prerequisites

  1. Python 3.10: The development environment requires Python 3.10. You can manage Python versions using a tool like pyenv.
  2. Poetry: Download and install Poetry by following their official installation guide. A recommended way is:
    curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.4.1 python3 -

Installation Steps

  1. Clone the Repository:

    git clone https://github.com/hyperliquid-dex/hyperliquid-python-sdk.git
    cd hyperliquid-python-sdk

  2. Configure Poetry Environment: Point Poetry to your Python 3.10 installation. For example, if you installed it with Homebrew on macOS:

    poetry env use /path/to/your/python3.10

  3. Install Dependencies: The project includes a Makefile to simplify common tasks. Use the install command to create a virtual environment and install all required dependencies from the poetry.lock file.

    make install
    This is equivalent to running poetry install.

  4. Install Type Stubs (Optional but Recommended): To ensure MyPy has all necessary type information for static analysis, you can install additional type stubs:

    make install-types

Your development environment is now set up. You can activate the virtual environment by running poetry shell within the project directory.