Trade
Public market data. Paths take a market ticker: TERA for the spot market, TERA-PERP for the perp. No authentication.
Endpoints
| Method | Path | Description |
|---|---|---|
GET | /api/trade | Every listed market |
GET | /api/trade/:ticker | One market, its book, and recent trades |
GET | /api/trade/:ticker/candles | OHLCV history |
GET | /api/trade/:ticker/trades | Trades after a tradeId, including liquidation takes |
GET /api/trade, GET /api/trade/:ticker, and candles are cached briefly. The trades route is not cached.
List markets
GET /api/trade
curl 'https://api.loafmarkets.com/api/trade'{
"markets": [
{
"marketIndex": 2048,
"ticker": "TERA",
"type": "SPOT",
"status": "LIVE",
"isHalted": false,
"tradingStartsAt": null,
"priceDecimals": 2,
"quantityDecimals": 1,
"minOrderValue": 10,
"name": "Tera",
"kind": "PROPERTY",
"tokenAddress": "0xabc…",
"headerImageUrl": "https://…/header.webp",
"videoUrl": null,
"marketPrice": 167.49,
"dailyReferencePrice": 165.0,
"volume24h": 1204.5,
"candlesticks": [],
"liquidity": { "status": "active" },
"hasL2Market": true,
"property": {
"streetAddress": "1 Example St",
"country": "AU",
"latitude": -33.86,
"longitude": 151.21,
"propertyType": "APARTMENT",
"totalTokens": 10000,
"rentalYieldPercentage": 5.2
}
}
]
}| Field | Meaning |
|---|---|
type | SPOT or PERP |
status | PENDING, LIVE, or DELISTED |
kind | PROPERTY, COMMODITY, CRYPTO, or INDEX |
property | Null when the asset is not a property |
liquidity.status | active, limited, or inactive |
priceDecimals, quantityDecimals | Null until the market has a scale |
volume24h | The rolling 24 hour notional |
A perp row uses ticker TERA-PERP and type PERP. Its live mark, funding, and open interest are on GET /api/trade/TERA-PERP in market.live, and on the perps:markets socket.
| Status | code | Meaning |
|---|---|---|
500 | { "error": "Failed to fetch markets" } |
One market
GET /api/trade/:ticker
curl 'https://api.loafmarkets.com/api/trade/TERA'The response:
| Field | Meaning |
|---|---|
marketList | Every listed market, one row per ticker. An offering is a row with type IPO until its spot market is LIVE. A perp row’s live is { markPrice, openInterest, fundingRateCbp, fundingPeriodMs } or null. |
market | The market. type SPOT carries l2. type PERP carries l2 and live. Their fields are below. |
asset | { ticker, name, kind, videoUrl, stakeholders, property }. property is null when the asset is not a property. |
volume24h | Rolling 24 hour notional. |
orderBook | { bids, asks }, each level { price, quantity }, or null. |
recentTrades | Recent prints without txHash. A liquidation take has isLiquidation: true. |
dailyReferencePrice | Session reference, or null. |
liquidity | { status }. |
Spot market.l2, present once the market is bound on the rollup:
| Field | Meaning |
|---|---|
chainId | Chain the proxy and tokens sit on |
proxyAddress | ZkLoaf proxy |
l2ChainId | Chain id inside every signature. 1 to 2130706432 |
signedPriceDecimals, signedQuantityDecimals | Scales inside the signature |
baseAssetId, quoteAssetId | Asset ids the order must name |
A perp’s l2 has the spot fields except baseAssetId. live is null when the market’s live data is unavailable.
| Field | Meaning |
|---|---|
quoteAssetId | 3 (USDC) |
status | ACTIVE or EXPIRED |
qem | Decimal string |
minBase | Tokens, as a decimal string. The smallest size of an order that opens or grows a position |
minQuote | USD, as a decimal string. The smallest value of an order that opens or grows a position |
quoteLimit | USD, as a decimal string. The largest value of an order. A reduce-only stop or take-profit is not held to it. 0 is no limit |
takerFee | Integer, per million: 100 is 1 bp. The most an order’s taker rate can be on this market |
makerFee | Integer, per million. The most an order’s maker rate can be on this market |
risk | Integer |
maxLeverage | Integer |
band | Integer |
flags | Integer |
A perp’s market.live:
| Field | Meaning |
|---|---|
marketIndex | Integer |
status | ACTIVE or EXPIRED |
indexPrice | Exact decimal string |
markPrice | Exact decimal string |
openInterest | Decimal string |
fundingIndex | Decimal string |
fundingRateCbp | The rate for one fundingPeriodMs, in centi-basis-points of the oracle price, or null |
fundingPeriodMs | Milliseconds |
nextTickAtMs | Unix milliseconds |
observedAtMs | Unix milliseconds |
asOfMs | Unix milliseconds |
heldPrice | { price, observedAtMs }, or null. price is a decimal string |
halted | Boolean |
riskOnly | Boolean |
tradingState | OPEN, REDUCE_ONLY, PRICE_STALE, or HALTED. Null when unset |
stateReason | MARKET_HALTED, MARKET_CLOSED, REDUCE_ONLY, PRICE_STALE, or MARKET_NOT_FOUND. Null when unset |
Perp market indexes are 0 to 254. Spot market indexes are 2048 to 4094. Sign l2MarketIndex from market.marketIndex. Do not guess it from the ticker.
| Status | code | Meaning |
|---|---|---|
400 | INVALID_REQUEST | Ticker is not ^[A-Z0-9]{1,10}(-PERP)?$ |
404 | { "error": "Market not found" } | |
500 | { "error": "Failed to fetch market" } |
Seed the book from orderBook, then subscribe to orderbook:TERA. The socket keeps sending the book, its best levels on each side.
Candles
GET /api/trade/:ticker/candles?resolution=&to=&countBack=
| Param | Meaning |
|---|---|
resolution | 1m, 5m, 15m, 1h, 4h, 1d, or 1w |
to | A unix second. The page ends at that time |
countBack | That many older bars, at most 1500 |
limit | An alias of countBack. Used only when countBack is absent. 1 to 1500 |
curl 'https://api.loafmarkets.com/api/trade/TERA/candles?resolution=1h&countBack=100'{
"resolution": "1h",
"candles": [
{ "time": 1764000000, "open": 166.1, "high": 168.0, "low": 165.4, "close": 167.49, "volume": 40.2 }
],
"oldestTs": 1764000000,
"hasMore": true
}Pass oldestTs back as to to page older bars. hasMore is false on the last page. An empty page has oldestTs: null.
| Status | code | Meaning |
|---|---|---|
400 | INVALID_REQUEST | Bad ticker, resolution, to, countBack, or limit |
404 | { "error": "Market not found" } | |
503 | { "error": "Candle history is busy. Please try again shortly." } and Retry-After | |
500 | { "error": "Failed to fetch candles" } |
Then subscribe to chart:TERA. Frames are candle_update with one candle.
Trades
GET /api/trade/:ticker/trades?afterTradeId=&limit=
Public tape, oldest first, after afterTradeId (default 0). limit is 1 to 1000, default 100. A liquidation take is a row with isLiquidation: true and no txHash.
curl 'https://api.loafmarkets.com/api/trade/TERA-PERP/trades?afterTradeId=0&limit=50'{
"trades": [
{
"tradeId": 9001,
"txHash": "0xabc…",
"aggressorSide": "BUY",
"price": 167.49,
"quantity": 2.5,
"timestamp": 1764000000
},
{
"tradeId": 9002,
"aggressorSide": "SELL",
"price": 167.1,
"quantity": 1,
"timestamp": 1764000060,
"isLiquidation": true
}
]
}Page with afterTradeId set to the last tradeId you kept. For the live tail, subscribe to trades:TERA-PERP. A new subscriber first receives the market’s recent trades, then each new batch.