Skip to main content

SDK for Hyperliquid API trading with Python.

Project description

hyperliquid-python-sdk

Dependencies Status

Code style: black Security: bandit Pre-commit Semantic Versions License

SDK for Hyperliquid API trading with Python.

Installation

pip install hyperliquid-python-sdk

Configuration

  • Set the public key as the account_address in examples/config.json.
  • Set your private key as the secret_key in examples/config.json.
  • See the example of loading the config in examples/example_utils.py

[Optional] Generate a new API key for an API Wallet

Generate and authorize a new API private key on https://app.hyperliquid.xyz/API, and set the API wallet's private key as the secret_key in examples/config.json. Note that you must still set the public key of the main wallet not the API wallet as the account_address in examples/config.json

Usage Examples

import asyncio

from hyperliquid.info import Info
from hyperliquid.utils import constants


async def main():
    async with Info(constants.TESTNET_API_URL, skip_ws=True) as info:
        user_state = await info.user_state("0xcd5051944f780a621ee62e39e493c489668acf4d")
        print(user_state)


asyncio.run(main())

See examples for more complete examples. You can also checkout the repo and run any of the examples after configuring your private key e.g.

cp examples/config.json.example examples/config.json
vim examples/config.json
python examples/basic_order.py

Getting started with contributing to this repo

  1. Download Poetry: https://python-poetry.org/.

    • Note that in the install script you might have to set symlinks=True in venv.EnvBuilder.
    • Note that Poetry v2 is not supported, so you'll need to specify a specific version e.g. curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.4.1 python3 -
  2. Point poetry to correct version of python. For development we require python 3.10 exactly. Some dependencies have issues on 3.11, while older versions don't have correct typing support. brew install python@3.10 && poetry env use /opt/homebrew/Cellar/python@3.10/3.10.16/bin/python3.10

  3. Install dependencies:

make install

Makefile usage

CLI commands for faster development. See make help for more details.

check-safety          Run safety checks on dependencies
cleanup               Cleanup project
install               Install dependencies from poetry.lock
install-types         Find and install additional types for mypy
lint                  Alias for the pre-commit target
lockfile-update       Update poetry.lock
lockfile-update-full  Fully regenerate poetry.lock
poetry-download       Download and install poetry
pre-commit            Run linters + formatters via pre-commit, run "make pre-commit hook=black" to run only black
test                  Run tests with pytest
update-dev-deps       Update development dependencies to latest versions

Releases

You can see the list of available releases on the GitHub Releases page.

We follow the Semantic Versions specification and use Release Drafter. As pull requests are merged, a draft release is kept up-to-date listing the changes, ready to publish when you’re ready. With the categories option, you can categorize pull requests in release notes using labels.

List of labels and corresponding titles

Label Title in Releases
enhancement, feature Features
bug, refactoring, bugfix, fix Fixes & Refactoring
build, ci, testing Build System & CI/CD
breaking Breaking Changes
documentation Documentation
dependencies Dependencies updates

Building and releasing

Building a new version of the application contains steps:

  • Bump the version of your package with poetry version <version>. You can pass the new version explicitly, or a rule such as major, minor, or patch. For more details, refer to the Semantic Versions standard.
  • Make a commit to GitHub
  • Create a GitHub release
  • poetry publish --build

License

This project is licensed under the terms of the MIT license. See LICENSE for more details.

@misc{hyperliquid-python-sdk,
  author = {Hyperliquid},
  title = {SDK for Hyperliquid API trading with Python.},
  year = {2024},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/hyperliquid-dex/hyperliquid-python-sdk}}
}

Credits

This project was generated with python-package-template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hyperliquid_python_sdk_async-0.24.6.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hyperliquid_python_sdk_async-0.24.6-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file hyperliquid_python_sdk_async-0.24.6.tar.gz.

File metadata

  • Download URL: hyperliquid_python_sdk_async-0.24.6.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.11.2 Linux/6.1.0-49-amd64

File hashes

Hashes for hyperliquid_python_sdk_async-0.24.6.tar.gz
Algorithm Hash digest
SHA256 be37f0f06de3b604ad51039598cfd4fa41633f7303764ff884dd0ae722566e89
MD5 f1dccc3f4277d08040c28cba63d64fd7
BLAKE2b-256 ee638cf9700a44c1fc9fd9885c8c4fe6e8f1cac1eec617b8927f20adf4f25827

See more details on using hashes here.

File details

Details for the file hyperliquid_python_sdk_async-0.24.6-py3-none-any.whl.

File metadata

File hashes

Hashes for hyperliquid_python_sdk_async-0.24.6-py3-none-any.whl
Algorithm Hash digest
SHA256 6b9dd9b8dcc15c46edec77e49488bde12dd59bb87766de4ad29759bb86bdab14
MD5 b6e1ca4200ccd2e871dea91987f07a0d
BLAKE2b-256 f04d0cc49f315bf0f1cf6dff534bb63e681d6e22218f3b5fa384e128089c2d7d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page