Skip to Content
API ReferenceTrade API

Trade

Public market data. Paths take a market ticker: TERA for the spot market, TERA-PERP for the perp. No authentication.

Endpoints

MethodPathDescription
GET/api/tradeEvery listed market
GET/api/trade/:tickerOne market, its book, and recent trades
GET/api/trade/:ticker/candlesOHLCV history
GET/api/trade/:ticker/tradesTrades 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 } } ] }
FieldMeaning
typeSPOT or PERP
statusPENDING, LIVE, or DELISTED
kindPROPERTY, COMMODITY, CRYPTO, or INDEX
propertyNull when the asset is not a property
liquidity.statusactive, limited, or inactive
priceDecimals, quantityDecimalsNull until the market has a scale
volume24hThe 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.

StatuscodeMeaning
500{ "error": "Failed to fetch markets" }

One market

GET /api/trade/:ticker

curl 'https://api.loafmarkets.com/api/trade/TERA'

The response:

FieldMeaning
marketListEvery 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.
marketThe 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.
volume24hRolling 24 hour notional.
orderBook{ bids, asks }, each level { price, quantity }, or null.
recentTradesRecent prints without txHash. A liquidation take has isLiquidation: true.
dailyReferencePriceSession reference, or null.
liquidity{ status }.

Spot market.l2, present once the market is bound on the rollup:

FieldMeaning
chainIdChain the proxy and tokens sit on
proxyAddressZkLoaf proxy
l2ChainIdChain id inside every signature. 1 to 2130706432
signedPriceDecimals, signedQuantityDecimalsScales inside the signature
baseAssetId, quoteAssetIdAsset 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.

FieldMeaning
quoteAssetId3 (USDC)
statusACTIVE or EXPIRED
qemDecimal string
minBaseTokens, as a decimal string. The smallest size of an order that opens or grows a position
minQuoteUSD, as a decimal string. The smallest value of an order that opens or grows a position
quoteLimitUSD, 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
takerFeeInteger, per million: 100 is 1 bp. The most an order’s taker rate can be on this market
makerFeeInteger, per million. The most an order’s maker rate can be on this market
riskInteger
maxLeverageInteger
bandInteger
flagsInteger

A perp’s market.live:

FieldMeaning
marketIndexInteger
statusACTIVE or EXPIRED
indexPriceExact decimal string
markPriceExact decimal string
openInterestDecimal string
fundingIndexDecimal string
fundingRateCbpThe rate for one fundingPeriodMs, in centi-basis-points of the oracle price, or null
fundingPeriodMsMilliseconds
nextTickAtMsUnix milliseconds
observedAtMsUnix milliseconds
asOfMsUnix milliseconds
heldPrice{ price, observedAtMs }, or null. price is a decimal string
haltedBoolean
riskOnlyBoolean
tradingStateOPEN, REDUCE_ONLY, PRICE_STALE, or HALTED. Null when unset
stateReasonMARKET_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.

StatuscodeMeaning
400INVALID_REQUESTTicker 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=

ParamMeaning
resolution1m, 5m, 15m, 1h, 4h, 1d, or 1w
toA unix second. The page ends at that time
countBackThat many older bars, at most 1500
limitAn 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.

StatuscodeMeaning
400INVALID_REQUESTBad 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.

Last updated on