Markets.xyz

Trading API

Trading stocks, commodities and other third-party markets on HIP-3 dexes.

Last updated

HIP-3 markets are perpetuals deployed on Hyperliquid by third parties, each on its own dex: stocks, commodities, indices and more. Through the API they trade exactly like the main perpetuals, with the same endpoints and the same builder fee.

Market names

A HIP-3 market is named dex:ticker, the dex prefix followed by the ticker:

Market

Dex

Ticker

xyz:TSLA

xyz

TSLA

xyz:GOLD

xyz

GOLD

Use the full name anywhere a coin goes: orders, market orders, closes, cancels, modifies and leverage.

bash
curl -s -X POST https://hl-api-production-65c8.up.railway.app/v1/orders \
  -H "Authorization: Bearer $API_KEY" \
  -H 'content-type: application/json' \
  -d '{
    "orders": [{
      "coin": "xyz:TSLA",
      "side": "buy",
      "px": "250",
      "sz": "1",
      "type": { "limit": { "tif": "Alo" } },
      "cloid": "0b8f5d0e-3c1a-4f6e-9a2b-7d4c1e8f2a90"
    }]
  }'

To list a dex's markets with their size and price precision, call GET /v1/market/meta?dex=xyz.

Collateral

On Hyperliquid each dex normally has its own margin balance, so you would have to move funds to every dex you trade. Unified account mode removes that: one balance margins the main perpetuals, every HIP-3 dex and spot.

Managed accounts are switched to unified account mode during onboarding, so there's nothing to do. To check, call GET /v1/account/status:

json
{ "account_mode": "unifiedAccount", "hip3_collateral_shared": true }

If hip3_collateral_shared is false (an account onboarded before this was automatic, or one switched back by hand), POST /v1/account/unified-account returns the switch as an approval for your master wallet to sign, in the same way as the scripted onboarding approvals.

Isolated-only markets

Many HIP-3 markets only support isolated margin, such as xyz:PLTR (xyz:TSLA and xyz:GOLD support cross). Markets flagged onlyIsolated in GET /v1/market/meta?dex=xyz are isolated-only. Setting cross margin on one returns 400; use is_cross: false:

json
{ "coin": "xyz:PLTR", "leverage": 3, "is_cross": false }

Reading HIP-3 data

Positions, open orders, mid prices and market metadata cover one dex per request. They default to the main perpetuals; add ?dex= for a HIP-3 dex:

bash
curl -s "https://hl-api-production-65c8.up.railway.app/v1/positions?dex=xyz" -H "Authorization: Bearer $API_KEY"
curl -s "https://hl-api-production-65c8.up.railway.app/v1/open-orders?dex=xyz" -H "Authorization: Bearer $API_KEY"
curl -s "https://hl-api-production-65c8.up.railway.app/v1/market/mids?dex=xyz" -H "Authorization: Bearer $API_KEY"

To see everything, call each dex you trade. An unknown dex returns 400. Fills, order status and the order book take the full market name and need no dex parameter.