Agent-friendly CLI for the Hyperliquid DEX.
Query market data, manage positions, and execute trades β all from your terminal or AI agent.
Part of the Hyperliquid toolset:
hyperliquid-mcpβ MCP server for Claude Desktop / LLM clients@erscoder/hyperliquid-cliβ CLI for agents, scripts, and developers β you are here
AI agents (OpenClaw, AutoGPT, CrewAI, etc.) work better with CLI tools than with MCP servers:
- No server to spin up β just
execa command and parse the JSON output - Scriptable, pipeable, composable
- Works in any shell, cron job, or automation workflow
npm install -g @erscoder/hyperliquid-cliVerify:
hl --version
hl --helpSet environment variables (recommended for agents):
export HL_WALLET_ADDRESS=0xYourWalletAddress
export HL_PRIVATE_KEY=0xYourPrivateKey # required for trading commandsOr persist to ~/.hl/config.json:
hl config set walletAddress 0xYourWalletAddress
hl config set privateKey 0xYourPrivateKeyMarket data commands (
hl price,hl markets) don't require any credentials.
# No auth needed
hl price BTC
# {"symbol":"BTC","price":74250.5}
hl markets
# [{"name":"BTC","szDecimals":5,"maxLeverage":50}, ...]
# With wallet set
hl balance --pretty
hl positions
hl orders list
# Trading
hl order place --symbol BTC --side buy --size 0.001 --price 70000
hl order cancel-allGet current mid price for a symbol.
hl price BTC
# {"symbol":"BTC","price":74250.5}
hl price ETH --pretty
# symbol: ETH
# price: 3521.2List all available perpetual markets.
hl markets
# [{"name":"BTC","szDecimals":5,"maxLeverage":50}, ...]
hl markets --prettyShow account value, margin, and withdrawable USDC.
hl balance
# {"accountValue":"10523.45","totalMarginUsed":"820.00","withdrawable":"9703.45"}Show open perpetual positions.
hl positions
# [{"coin":"BTC","size":"0.01","entryPrice":"72000","unrealizedPnl":"22.50",...}]Show recent trade fills (default: 20).
hl history --limit 5
hl history --limit 50 --prettyShow deposit/withdrawal history (default: 20).
hl transfers
hl transfers --limit 10 --prettyList all open orders.
hl orders list
# [{"oid":12345,"coin":"BTC","side":"buy","size":"0.001","price":"70000",...}]
hl orders list --prettyPlace a limit or market order.
# Limit order
hl order place --symbol BTC --side buy --size 0.001 --price 70000
# Market order (omit --price)
hl order place --symbol ETH --side sell --size 0.1
# Output
# {"status":"ok","response":{"type":"order","data":{"statuses":[...]}}}| Flag | Required | Description |
|---|---|---|
--symbol |
β | Symbol (BTC, ETH, etc.) |
--side |
β | buy or sell |
--size |
β | Order size |
--price |
β | Limit price. Omit for market order |
Cancel a specific order.
hl order cancel --symbol BTC --id 12345Cancel all open orders, optionally filtered by symbol.
hl order cancel-all
hl order cancel-all --symbol BTC
# {"cancelled":3,"result":{...}}Set cross leverage for a symbol.
hl leverage set --symbol BTC --value 10
hl leverage set --symbol ETH --value 5Show current config (private key is masked).
hl config get
# {"walletAddress":"0xAbc...","privateKey":"0x1234...","testnet":false}Set a config value. Keys: walletAddress, privateKey, testnet.
hl config set walletAddress 0xYourAddress
hl config set privateKey 0xYourKey
hl config set testnet trueConfig is stored in ~/.hl/config.json.
All commands output JSON by default β ideal for agents and scripts:
hl price BTC | jq '.price'
# 74250.5
hl positions | jq '[.[] | {coin, size, unrealizedPnl}]'Add --pretty for human-friendly output:
hl balance --pretty
# accountValue: 10523.45
# totalMarginUsed: 820.00
# withdrawable: 9703.45Add --testnet to any command to use the Hyperliquid testnet:
hl balance --testnet
hl order place --symbol BTC --side buy --size 0.001 --price 70000 --testnetOr set it globally:
hl config set testnet trueexec: hl price BTC
exec: hl positions --json
exec: hl order place --symbol BTC --side buy --size 0.001 --price 70000
PRICE=$(hl price BTC | jq -r '.price')
echo "BTC is at $PRICE"
# Check if you have open positions
POSITIONS=$(hl positions | jq 'length')
echo "Open positions: $POSITIONS"import subprocess, json
def hl(command: str) -> dict:
result = subprocess.run(
f"hl {command}",
shell=True, capture_output=True, text=True
)
return json.loads(result.stdout)
price = hl("price BTC")["price"]| Project | Use case |
|---|---|
| hyperliquid-mcp | MCP server for Claude Desktop and MCP-compatible clients |
| @erscoder/hyperliquid-cli | CLI for agents, scripts, and developers |
When to use which:
- MCP: You're using Claude Desktop, Cursor, or another MCP client
- CLI: You're building agents, scripts, or need shell-level access
PRs welcome! Please:
- Fork the repo
- Create a feature branch:
git checkout -b feat/my-feature - Commit with conventional commits:
feat:,fix:,docs: - Open a PR
MIT Β© Enrique Rubio