Liquid

Type definitions

Models

Complete reference for every request, response, and enum type in the Liquid API.

Overview

Link

Every response from the Liquid API is wrapped in a standard envelope. The data field contains one of the typed models documented below. In the Python SDK these are frozen dataclasses; over the wire they are JSON objects.

Deep links

Each model heading has a Link button — use it to grab a permalink you can reference from other docs, issues, or code comments.

ApiResponse

Link

Every endpoint returns this envelope. Check success before reading data.

FieldTypeDescription
successbooleanWhether the request succeeded
dataT | nullResponse payload — type varies per endpoint
errorApiErrorDetail | nullPresent only when success is false
Success
json
{
  "success": true,
  "data": { ... },
  "error": null
}
Error
json
{
  "success": false,
  "data": null,
  "error": {
    "code": "INSUFFICIENT_BALANCE",
    "message": "Not enough available margin for this order"
  }
}

ApiErrorDetail

Link
FieldTypeDescription
codestringMachine-readable error code (e.g. INSUFFICIENT_BALANCE)
messagestringHuman-readable explanation

OrderSide

Link

Direction of an order or position.

ValueDescription
buyBuy / long
sellSell / short

OrderType

Link

Execution strategy for an order.

ValueDescription
marketExecute immediately at best available price
limitExecute at the specified price or better

TimeInForce

Link

How long an order remains active.

ValueDescription
gtcGood-Till-Canceled — stays open until filled or explicitly canceled
iocImmediate-Or-Cancel — fills what it can, cancels the rest

Market

Link

Metadata for a tradeable perpetual contract. Returned by GET /v1/markets.

FieldTypeDescription
symbolstringTrading symbol (e.g. BTC-PERP)
tickerstringExchange-native ticker (e.g. BTC)
exchangestringExchange name — always hyperliquid
max_leverageint | nullMaximum allowed leverage
sz_decimalsint | nullDecimal precision for order sizes
Example
json
{
  "symbol": "BTC-PERP",
  "ticker": "BTC",
  "exchange": "hyperliquid",
  "max_leverage": 200,
  "sz_decimals": 5
}

Ticker

Link

24-hour market snapshot. Returned by GET /v1/markets/{symbol}/ticker.

FieldTypeDescription
symbolstringTrading symbol
mark_pricestringCurrent mark / mid price
volume_24hstring | null24h trading volume in USD
change_24hstring | null24h price change as a decimal (e.g. 0.042 = +4.2%)
funding_ratestring | nullCurrent funding rate
Example
json
{
  "symbol": "ETH-PERP",
  "mark_price": "3821.50",
  "volume_24h": "148230000",
  "change_24h": "0.042",
  "funding_rate": "0.0001"
}
SDK note

The Python SDK converts string numeric fields to float automatically. mark_price, volume_24h, change_24h, and funding_rate are all float or float | None on the Ticker dataclass.

Orderbook

Link

L2 orderbook snapshot. Returned by GET /v1/markets/{symbol}/orderbook.

FieldTypeDescription
symbolstringTrading symbol
bidsOrderbookLevel[]Bid levels, sorted price descending
asksOrderbookLevel[]Ask levels, sorted price ascending
timestampint | nullSnapshot timestamp in milliseconds
Example
json
{
  "symbol": "BTC-PERP",
  "bids": [
    { "price": "104200.0", "size": "1.25", "count": 1 },
    { "price": "104199.0", "size": "3.10", "count": 1 }
  ],
  "asks": [
    { "price": "104201.0", "size": "0.80", "count": 1 },
    { "price": "104202.0", "size": "2.50", "count": 1 }
  ],
  "timestamp": 1710000000000
}

OrderbookLevel

Link

A single price level in the orderbook.

FieldTypeDescription
pricestringPrice at this level
sizestringTotal size at this level
countintNumber of orders at this level (default 1)

Candle

Link

OHLCV candlestick bar. Returned by GET /v1/markets/{symbol}/candles.

FieldTypeDescription
timestampintBar open time in milliseconds
openstringOpening price
highstringHighest price
lowstringLowest price
closestringClosing price
volumestringVolume traded during the bar
Example
json
{
  "timestamp": 1710000000000,
  "open": "104100.0",
  "high": "104500.0",
  "low": "104050.0",
  "close": "104350.0",
  "volume": "2450000.0"
}

Account

Link

Account-level margin summary. Returned by GET /v1/account.

FieldTypeDescription
equitystringTotal account equity
margin_usedstringMargin currently allocated to positions
available_balancestringBalance available for new orders
account_valuestringTotal account value including unrealized P&L
Example
json
{
  "equity": "50000.00",
  "margin_used": "12500.00",
  "available_balance": "37500.00",
  "account_value": "50250.00"
}

Balance

Link

Detailed balance breakdown. Returned by GET /v1/account/balances.

FieldTypeDescription
exchangestringExchange name (hyperliquid)
equitystringTotal equity
available_balancestringAvailable for trading
margin_usedstringMargin allocated to positions
cross_marginCrossMargin | nullCross-margin details if applicable
Example
json
{
  "exchange": "hyperliquid",
  "equity": "50000.00",
  "available_balance": "37500.00",
  "margin_used": "12500.00",
  "cross_margin": {
    "account_value": "50250.00",
    "total_margin_used": "12500.00",
    "total_ntl_pos": "125000.00"
  }
}

CrossMargin

Link

Cross-margin account details, nested inside Balance.

FieldTypeDescription
account_valuestringTotal cross-margin account value
total_margin_usedstringTotal margin used across all cross positions
total_ntl_posstringTotal notional position size

Position

Link

An open perpetual position. Returned by GET /v1/account/positions and GET /v1/positions/{symbol}.

FieldTypeDescription
symbolstringTrading symbol (e.g. BTC-PERP)
sidestringPosition direction — long or short
sizestringPosition size in asset units
entry_pricestringAverage entry price
mark_pricestring | nullCurrent mark price
leveragestringPosition leverage
unrealized_pnlstringUnrealized profit and loss
liquidation_pricestring | nullEstimated liquidation price
margin_usedstring | nullMargin allocated to this position
Example
json
{
  "symbol": "ETH-PERP",
  "side": "long",
  "size": "5.0",
  "entry_price": "3800.00",
  "mark_price": "3821.50",
  "leverage": "10",
  "unrealized_pnl": "107.50",
  "liquidation_price": "3420.00",
  "margin_used": "1900.00"
}

Order

Link

Full order details returned after placing or querying a single order. Returned by POST /v1/orders and GET /v1/orders/{order_id}.

FieldTypeDescription
order_idstring | nullExchange order ID
symbolstringTrading symbol
sidestringbuy or sell
typestringmarket or limit
sizefloatOrder size in USD notional
pricefloat | nullLimit price or execution price
leverageintLeverage multiplier (default 1)
statusstringfilled, open, accepted, or cancelled
exchangestringExchange name (hyperliquid)
tpfloat | nullTake-profit trigger price
slfloat | nullStop-loss trigger price
reduce_onlybooleanWhether this order only reduces an existing position
created_atstring | nullISO 8601 timestamp
Example
json
{
  "order_id": "0x1a2b3c...",
  "symbol": "BTC-PERP",
  "side": "buy",
  "type": "limit",
  "size": 50000.0,
  "price": 104000.0,
  "leverage": 10,
  "status": "open",
  "exchange": "hyperliquid",
  "tp": 110000.0,
  "sl": 100000.0,
  "reduce_only": false,
  "created_at": "2025-03-10T14:30:00Z"
}

OpenOrder

Link

Lightweight representation of an open order. Returned by GET /v1/orders.

FieldTypeDescription
order_idstringExchange order ID
symbolstringTrading symbol
sidestringbuy or sell
sizestringOrder size in asset units
pricestringLimit price
timestampintPlacement time in milliseconds
Example
json
{
  "order_id": "0x1a2b3c...",
  "symbol": "BTC-PERP",
  "side": "buy",
  "size": "0.48",
  "price": "104000.0",
  "timestamp": 1710000000000
}

PlaceOrderRequest

Link

Request body for POST /v1/orders.

FieldTypeRequiredDescription
symbolstringYesTrading symbol (e.g. BTC-PERP)
sideOrderSideYesbuy or sell
typeOrderTypeYesmarket or limit
sizefloatYesOrder size in USD notional (must be > 0)
pricefloatLimit onlyLimit price (required when type is limit)
leverageintNoLeverage 1–200 (default 1)
time_in_forceTimeInForceNogtc (default) or ioc
tpfloatNoTake-profit trigger price
slfloatNoStop-loss trigger price
reduce_onlybooleanNoOnly reduce an existing position (default false)
Market order
json
{
  "symbol": "BTC-PERP",
  "side": "buy",
  "type": "market",
  "size": 50000,
  "leverage": 10
}
Limit order with TP/SL
json
{
  "symbol": "ETH-PERP",
  "side": "sell",
  "type": "limit",
  "size": 10000,
  "price": 3900.0,
  "leverage": 5,
  "time_in_force": "gtc",
  "tp": 3700.0,
  "sl": 4000.0
}

ClosePositionRequest

Link

Request body for POST /v1/positions/{symbol}/close. Send an empty body to close the full position.

FieldTypeRequiredDescription
sizefloatNoPartial close size in coin units. Omit to close the entire position.
Partial close
json
{ "size": 0.5 }

SetTpSlRequest

Link

Request body for PATCH /v1/positions/{symbol}/tp-sl. At least one of tp or sl must be provided.

FieldTypeRequiredDescription
tpfloat | nullConditionalTake-profit trigger price (> 0)
slfloat | nullConditionalStop-loss trigger price (> 0)
Example
json
{ "tp": 110000.0, "sl": 100000.0 }

AdjustMarginRequest

Link

Request body for PATCH /v1/positions/{symbol}/margin.

FieldTypeRequiredDescription
amountfloatYesPositive to add margin, negative to remove
Add margin
json
{ "amount": 500.0 }

UpdateLeverageRequest

Link

Request body for PATCH /v1/positions/{symbol}/leverage.

FieldTypeRequiredDescription
leverageintYesNew leverage value (1–200)
is_crossbooleanNoUse cross margin mode (default false)
Example
json
{ "leverage": 20, "is_cross": false }

CloseResult

Link

Returned in the data field after closing a position via POST /v1/positions/{symbol}/close.

FieldTypeDescription
symbolstringTrading symbol that was closed
statusstringResult status (e.g. closed, failed)
messagestringHuman-readable result description
Example
json
{
  "symbol": "BTC-PERP",
  "status": "closed",
  "message": "Position fully closed"
}

TpSlResult

Link

Returned after setting take-profit / stop-loss via PATCH /v1/positions/{symbol}/tp-sl.

FieldTypeDescription
tpobject | nullTake-profit order details, or null if not set
slobject | nullStop-loss order details, or null if not set
Example
json
{
  "tp": { "status": "ok", "price": 110000.0 },
  "sl": { "status": "ok", "price": 100000.0 }
}

MarginResult

Link

Returned after adjusting margin via PATCH /v1/positions/{symbol}/margin.

FieldTypeDescription
symbolstringTrading symbol
margin_adjustedfloatAmount of margin added (positive) or removed (negative)
Example
json
{
  "symbol": "BTC-PERP",
  "margin_adjusted": 500.0
}

LeverageResult

Link

Returned after updating leverage via PATCH /v1/positions/{symbol}/leverage.

FieldTypeDescription
symbolstringTrading symbol
leverageintNew leverage value
is_crossbooleanWhether cross margin mode is active
Example
json
{
  "symbol": "ETH-PERP",
  "leverage": 20,
  "is_cross": false
}

ApiKeyResponse

Link

API key metadata returned when listing keys. The secret is never included.

FieldTypeDescription
idstringAPI key identifier
labelstringUser-assigned label
key_prefixstringFirst 8 characters of the key for identification
permissionsintPermission bitmask (1 = READ, 2 = TRADE, 3 = both)
ip_whiteliststring[]Allowed IP addresses or CIDR ranges
is_revokedbooleanWhether the key has been revoked
created_atstringISO 8601 creation timestamp
expires_atstring | nullISO 8601 expiration timestamp
last_used_atstring | nullISO 8601 last usage timestamp
Example
json
{
  "id": "key_abc123",
  "label": "production-bot",
  "key_prefix": "lq_a1b2c3",
  "permissions": 3,
  "ip_whitelist": ["203.0.113.0/24"],
  "is_revoked": false,
  "created_at": "2025-03-01T00:00:00Z",
  "expires_at": null,
  "last_used_at": "2025-03-10T14:30:00Z"
}

ApiKeyCreatedResponse

Link

Returned once when a new API key is created. This is the only time the secret is visible — store it securely.

FieldTypeDescription
idstringAPI key identifier
keystringThe API key (lq_... prefix)
secretstringThe API secret (sk_... prefix) — shown only once
labelstringUser-assigned label
permissionsintPermission bitmask
ip_whiteliststring[]Allowed IP addresses or CIDR ranges
Store your secret

The secret field is only returned at creation time. It cannot be retrieved later. If you lose it, revoke the key and create a new one.