API Quickstart
Quickstart for HyperLink's API: base URLs, request signing, and a working code example to start trading Hyperliquid markets programmatically today.
Last updated
pip install hyperlink-python-sdkimport os
from eth_account import Account
from hyperliquid.exchange import Exchange
from hyperliquid.utils.types import Cloid
# Your API key is the agent private key. Keep it in an env var, never hardcode.
agent = Account.from_key(os.environ["AGENT_PRIVATE_KEY"])
# The HyperLink SDK defaults to the HyperLink base URL. Set it explicitly if your client code passes a URL.
exchange = Exchange(agent, base_url="https://api.hyperlink.xyz")
# Place a resting limit buy: 0.1 BTC at 50000, good-till-cancel.
result = exchange.order(
name="BTC",
is_buy=True,
sz=0.1,
limit_px=50000,
order_type={"limit": {"tif": "Gtc"}},
cloid=Cloid.from_str("0x1234567890abcdef1234567890abcdef"), # required
)
print(result)