hl-api-samples
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHyperliquid API Sample Data Fetcher
Hyperliquid API 样本数据获取命令集
Generate ready-to-run bash/curl commands for fetching data from the Hyperliquid mainnet API.
生成可直接运行的bash/curl命令,用于从Hyperliquid主网API获取数据。
Base URL
基础URL
https://api.hyperliquid.xyz/infoAll requests are POST with .
Content-Type: application/jsonhttps://api.hyperliquid.xyz/info所有请求均为POST方法,且为。
Content-Typeapplication/jsonPublic Data Commands
公开数据命令
Get Exchange Metadata (assets, leverage, decimals)
获取交易所元数据(资产、杠杆、小数位数)
bash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "meta"}' | jqbash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "meta"}' | jqGet All Mid Prices
获取所有中间价
bash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "allMids"}' | jqbash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "allMids"}' | jqGet Meta + Asset Contexts (combined metadata)
获取元数据+资产上下文(合并元数据)
bash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "metaAndAssetCtxs"}' | jqbash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "metaAndAssetCtxs"}' | jqGet Order Book (L2)
获取订单簿(L2)
bash
undefinedbash
undefinedBTC order book
BTC订单簿
curl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "l2Book", "coin": "BTC"}' | jq
-H "Content-Type: application/json"
-d '{"type": "l2Book", "coin": "BTC"}' | jq
curl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "l2Book", "coin": "BTC"}' | jq
-H "Content-Type: application/json"
-d '{"type": "l2Book", "coin": "BTC"}' | jq
ETH order book
ETH订单簿
curl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "l2Book", "coin": "ETH"}' | jq
-H "Content-Type: application/json"
-d '{"type": "l2Book", "coin": "ETH"}' | jq
curl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "l2Book", "coin": "ETH"}' | jq
-H "Content-Type: application/json"
-d '{"type": "l2Book", "coin": "ETH"}' | jq
SOL order book
SOL订单簿
curl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "l2Book", "coin": "SOL"}' | jq
-H "Content-Type: application/json"
-d '{"type": "l2Book", "coin": "SOL"}' | jq
undefinedcurl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "l2Book", "coin": "SOL"}' | jq
-H "Content-Type: application/json"
-d '{"type": "l2Book", "coin": "SOL"}' | jq
undefinedGet Recent Trades
获取近期交易记录
bash
undefinedbash
undefinedBTC recent trades
BTC近期交易记录
curl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "recentTrades", "coin": "BTC"}' | jq
-H "Content-Type: application/json"
-d '{"type": "recentTrades", "coin": "BTC"}' | jq
curl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "recentTrades", "coin": "BTC"}' | jq
-H "Content-Type: application/json"
-d '{"type": "recentTrades", "coin": "BTC"}' | jq
ETH recent trades
ETH近期交易记录
curl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "recentTrades", "coin": "ETH"}' | jq
-H "Content-Type: application/json"
-d '{"type": "recentTrades", "coin": "ETH"}' | jq
undefinedcurl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "recentTrades", "coin": "ETH"}' | jq
-H "Content-Type: application/json"
-d '{"type": "recentTrades", "coin": "ETH"}' | jq
undefinedGet Candle Data (OHLCV)
获取K线数据(OHLCV)
bash
undefinedbash
undefinedBTC 1-hour candles (last 24 hours)
BTC 1小时K线(最近24小时)
Replace START_TIME and END_TIME with millisecond timestamps
替换START_TIME和END_TIME为毫秒级时间戳
curl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "candleSnapshot", "req": {"coin": "BTC", "interval": "1h", "startTime": 1704067200000, "endTime": 1704153600000}}' | jq
-H "Content-Type: application/json"
-d '{"type": "candleSnapshot", "req": {"coin": "BTC", "interval": "1h", "startTime": 1704067200000, "endTime": 1704153600000}}' | jq
curl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "candleSnapshot", "req": {"coin": "BTC", "interval": "1h", "startTime": 1704067200000, "endTime": 1704153600000}}' | jq
-H "Content-Type: application/json"
-d '{"type": "candleSnapshot", "req": {"coin": "BTC", "interval": "1h", "startTime": 1704067200000, "endTime": 1704153600000}}' | jq
ETH 15-minute candles
ETH 15分钟K线
curl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "candleSnapshot", "req": {"coin": "ETH", "interval": "15m", "startTime": 1704067200000, "endTime": 1704153600000}}' | jq
-H "Content-Type: application/json"
-d '{"type": "candleSnapshot", "req": {"coin": "ETH", "interval": "15m", "startTime": 1704067200000, "endTime": 1704153600000}}' | jq
**Candle Intervals**: `1m`, `5m`, `15m`, `1h`, `4h`, `1d`
---curl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "candleSnapshot", "req": {"coin": "ETH", "interval": "15m", "startTime": 1704067200000, "endTime": 1704153600000}}' | jq
-H "Content-Type: application/json"
-d '{"type": "candleSnapshot", "req": {"coin": "ETH", "interval": "15m", "startTime": 1704067200000, "endTime": 1704153600000}}' | jq
**K线时间间隔**:`1m`、`5m`、`15m`、`1h`、`4h`、`1d`
---User-Specific Commands
用户专属命令
Replace with your actual wallet address.
0xYOUR_ADDRESS将替换为您实际的钱包地址。
0xYOUR_ADDRESSGet Account State (positions, margin, balance)
获取账户状态(持仓、保证金、余额)
bash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "clearinghouseState", "user": "0xYOUR_ADDRESS"}' | jqbash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "clearinghouseState", "user": "0xYOUR_ADDRESS"}' | jqGet Open Orders
获取挂单
bash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "openOrders", "user": "0xYOUR_ADDRESS"}' | jqbash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "openOrders", "user": "0xYOUR_ADDRESS"}' | jqGet Frontend Open Orders (includes TP/SL info)
获取前端挂单(包含止盈/止损信息)
bash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "frontendOpenOrders", "user": "0xYOUR_ADDRESS"}' | jqbash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "frontendOpenOrders", "user": "0xYOUR_ADDRESS"}' | jqGet Trade Fills (history)
获取成交记录(历史)
bash
undefinedbash
undefinedGet fills from a start time (milliseconds)
从指定时间(毫秒)开始获取成交记录
curl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "userFills", "user": "0xYOUR_ADDRESS", "startTime": 1704067200000}' | jq
-H "Content-Type: application/json"
-d '{"type": "userFills", "user": "0xYOUR_ADDRESS", "startTime": 1704067200000}' | jq
undefinedcurl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "userFills", "user": "0xYOUR_ADDRESS", "startTime": 1704067200000}' | jq
-H "Content-Type: application/json"
-d '{"type": "userFills", "user": "0xYOUR_ADDRESS", "startTime": 1704067200000}' | jq
undefinedGet Funding Payments
获取资金费用记录
bash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "userFunding", "user": "0xYOUR_ADDRESS", "startTime": 1704067200000}' | jqbash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "userFunding", "user": "0xYOUR_ADDRESS", "startTime": 1704067200000}' | jqGet Spot Balances
获取现货余额
bash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "spotClearinghouseState", "user": "0xYOUR_ADDRESS"}' | jqbash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "spotClearinghouseState", "user": "0xYOUR_ADDRESS"}' | jqHIP-3 Builder-Deployed Markets
HIP-3 开发者部署市场
For HIP-3 markets, add the parameter:
dex对于HIP-3市场,需添加参数:
dexGet HIP-3 Market Metadata
获取HIP-3市场元数据
bash
undefinedbash
undefinedxyz dex metadata
xyz dex元数据
curl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "meta", "dex": "xyz"}' | jq
-H "Content-Type: application/json"
-d '{"type": "meta", "dex": "xyz"}' | jq
undefinedcurl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "meta", "dex": "xyz"}' | jq
-H "Content-Type: application/json"
-d '{"type": "meta", "dex": "xyz"}' | jq
undefinedGet HIP-3 Positions
获取HIP-3持仓
bash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "clearinghouseState", "user": "0xYOUR_ADDRESS", "dex": "xyz"}' | jqAvailable HIP-3 dexes: , , , ,
xyzflxvntlhynakmbash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "clearinghouseState", "user": "0xYOUR_ADDRESS", "dex": "xyz"}' | jq可用的HIP-3 dex:、、、、
xyzflxvntlhynakmSpot Market Commands
现货市场命令
For spot markets, use format for candles:
@{index}对于现货市场,K线需使用格式:
@{index}Get Spot Market Metadata
获取现货市场元数据
bash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "spotMeta"}' | jqbash
curl -X POST https://api.hyperliquid.xyz/info \
-H "Content-Type: application/json" \
-d '{"type": "spotMeta"}' | jqGet Spot Candles (use @index format)
获取现货K线(使用@index格式)
bash
undefinedbash
undefinedHYPE/USDC candles (index 107)
HYPE/USDC K线(索引107)
curl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "candleSnapshot", "req": {"coin": "@107", "interval": "1h", "startTime": 1704067200000, "endTime": 1704153600000}}' | jq
-H "Content-Type: application/json"
-d '{"type": "candleSnapshot", "req": {"coin": "@107", "interval": "1h", "startTime": 1704067200000, "endTime": 1704153600000}}' | jq
---curl -X POST https://api.hyperliquid.xyz/info
-H "Content-Type: application/json"
-d '{"type": "candleSnapshot", "req": {"coin": "@107", "interval": "1h", "startTime": 1704067200000, "endTime": 1704153600000}}' | jq
-H "Content-Type: application/json"
-d '{"type": "candleSnapshot", "req": {"coin": "@107", "interval": "1h", "startTime": 1704067200000, "endTime": 1704153600000}}' | jq
---Tips
小贴士
- Formatting: Pipe output to for pretty-printed JSON
jq - Timestamps: All times are in milliseconds (e.g., in JS,
Date.now()in bash)date +%s000 - Get current timestamp:
date +%s000 - Get timestamp from 24h ago:
echo $(($(date +%s) - 86400))000 - Asset names: Use symbols like ,
BTC,ETH,SOL(seeHYPEendpoint for full list)meta
- 格式化:将输出通过管道传递给以获得格式化的JSON
jq - 时间戳:所有时间均为毫秒级(例如JS中的,bash中的
Date.now())date +%s000 - 获取当前时间戳:
date +%s000 - 获取24小时前的时间戳:
echo $(($(date +%s) - 86400))000 - 资产名称:使用、
BTC、ETH、SOL等符号(完整列表请查看HYPE接口)meta