> ## Documentation Index
> Fetch the complete documentation index at: https://docs.baibai.cx/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Use the Hyperliquid SDK to place, modify, cancel, and track individual orders.

Complete [onboarding](/makers/onboarding), obtain Spire approval for your master wallet, and fund its [available inventory](/makers/http-api#get-/v0/makers/maker/limits). Spire confirms the base URL serving the order adapter. The examples below send real resting orders once your account is enabled.

## Install

```sh theme={null}
python3 -m venv .venv
. .venv/bin/activate
pip install hyperliquid-python-sdk==0.24.0
```

Supply your signing key through a secret manager or private environment file as `MM_PRIVATE_KEY`. Set `MM_BASE_URL` to the endpoint from Spire and `MM_MASTER_ADDRESS` to the master that owns your inventory.

```python theme={null}
import os
from eth_account import Account
from hyperliquid.exchange import Exchange

exchange = Exchange(
    Account.from_key(os.environ["MM_PRIVATE_KEY"]),
    os.environ["MM_BASE_URL"],
    account_address=os.environ["MM_MASTER_ADDRESS"],
)
```

This is the ordinary SDK constructor. It reads the adapter's metadata and discovers spot markets without a custom signer or request wrapper.

## Approve an API wallet

Direct signing with your master needs no delegation. To create a hot API wallet, construct `Exchange` with your **master key**, then call:

```python theme={null}
response, agent_private_key = exchange.approve_agent("quoting")
assert response["status"] == "ok", response
```

Store `agent_private_key` in your secret manager without logging it. Reconstruct `Exchange` with that key and the same `account_address`. Approving another key under `quoting` retires the previous key. Approval delegates signing; it does not grant maker access. See [API wallets and signing](/makers/authentication).

## Place an order

Choose a current, non-marketable price and size on the market grid. Prices are USDC per WETH; sizes are WETH. The SDK uses spot symbol `WETH/USDC`:

```python theme={null}
import time
from hyperliquid.utils.types import Cloid

# Arm the account-wide deadline before placing fresh quotes.
response = exchange.schedule_cancel(int(time.time() * 1000) + 30_000)
assert response["status"] == "ok", response

# Allocate a unique client ID in your own order store.
cloid = Cloid.from_str("0x0123456789abcdef0123456789abcdef")
result = exchange.order(
    "WETH/USDC", True, 0.001, 2000.00,
    {"limit": {"tif": "Alo"}}, cloid=cloid,
)
status = result["response"]["data"]["statuses"][0]
if "error" in status:
    raise RuntimeError(status["error"])
oid = status["resting"]["oid"]
```

The price is illustrative. `Alo` rejects an order that would cross the current book. Every subsequent `order()` adds another order; it does not remove this one. The scheduled deadline applies to all orders owned by the master and bounds newly published curves. An already published curve keeps its previous expiry.

## Modify and cancel

```python theme={null}
result = exchange.modify_order(
    oid, "WETH/USDC", True, 0.002, 1999.00,
    {"limit": {"tif": "Alo"}}, cloid=cloid,
)
status = result["response"]["data"]["statuses"][0]
if "error" in status:
    raise RuntimeError(status["error"])
oid = status["resting"]["oid"]  # Save the new ID; old fills keep the old ID.

print(exchange.info.open_orders(os.environ["MM_MASTER_ADDRESS"]))
print(exchange.cancel("WETH/USDC", oid))
# Alternatively: exchange.cancel_by_cloid("WETH/USDC", cloid)
```

After a timeout, query order status by client ID before retrying. An error in a bulk request does not undo its successful entries.

## Protect and reconcile

```python theme={null}
import time

# Renew only with a fresh pricing decision, before updating your orders.
response = exchange.schedule_cancel(int(time.time() * 1000) + 30_000)
assert response["status"] == "ok", response
# exchange.schedule_cancel(None) disarms it.

fills = exchange.info.user_fills(os.environ["MM_MASTER_ADDRESS"])
```

The deadline must be at least five seconds ahead; at most ten deadlines can trigger per UTC day. A disconnect leaves orders open. Persist fills, deduplicate by master and `tid`, and reconcile after reconnect. See [fill reporting](/makers/fills).

A runnable command-line version is available as [examples-maker.py](/makers/python-example). It manages individual orders using the same SDK calls.
