History
Your orders, fills, and funding. Each route takes a login token or the web app’s Privy JWT. GET /api/portfolio/component returns the same rows, except that its fills have no proof. These routes page them.
Reads wait briefly, as the portfolio summary does, so that they include the order changes, fills, and funding payments the portfolio socket already sent. If the wait times out, a read may not include them yet.
Endpoints
| Method | Path | Description |
|---|---|---|
GET | /api/history/orders | Order history, booked and conditional |
GET | /api/history/orders/active | Resting orders |
GET | /api/history/orders/cancelled | Cancelled orders |
GET | /api/history/trades | Fills, including perps closes that are not book trades |
GET | /api/history/funding | Funding payments |
page defaults to 1. pageSize defaults to 20 and is at most 100. cursor is the opaque nextCursor from the previous page. Pass it back unchanged: a cursor the API did not serve returns the first page, not a 400. Funding has pageSize and cursor only. It refuses any other parameter, page included, with 400. Cancelled orders read cursor only and ignore page and pageSize. Active orders take no parameters and are not paged. Orders and trades refuse a page beyond a maximum depth with 400. Follow nextCursor to page deeper. On an account with a long history, total can be lower than the real number of rows. Page until nextCursor is null.
curl 'https://api.loafmarkets.com/api/history/orders?page=1&pageSize=20' \
-H "authorization: Bearer $LOAF_LOGIN_TOKEN"Orders
GET /api/history/orders, /orders/active, and /orders/cancelled.
GET /api/history/orders:
{
"orders": [],
"total": 0,
"page": 1,
"pageSize": 20,
"nextCursor": null
}A booked order:
| Field | Meaning |
|---|---|
id | Order id |
type | MARKET or LIMIT |
status | OPEN, PARTIALLY_FILLED, FILLED, CANCELLED, REJECTED |
marketIndex, ticker | Market. ticker is TERA or TERA-PERP |
side | BUY or SELL |
timeInForce | GTC, IOC, or FOK. Placement also accepts POST_ONLY |
quantity, price | Human units. price is null when the row has none |
filledQuantity, filledAt | Fill progress. filledAt is unix seconds or null |
rejectionReason | Text when REJECTED, else null |
cancelReason | Why the engine cancelled the remainder, or null |
expiryMs | The signed expiry |
pool | Perp pool, or null on spot |
reduceOnly | Perp flag |
feeRateCap | The signed l2FeeRateCap, per million |
l2OrderIndex, orderTag | Present when the order has them |
cancelledAt, createdAt | Unix seconds. cancelledAt is null until then |
A conditional row has no filledQuantity, filledAt, or cancelReason. It adds:
| Field | Meaning |
|---|---|
type | STOP_LIMIT, STOP_MARKET, TAKE_LIMIT, or TAKE_MARKET |
status | PENDING, ARMED, PLACED, FAILED, or CANCELLED |
rejectionReason | Why it could not be placed, when FAILED. Else null |
triggerPrice | The trigger |
parentOrderId | The parent, when this leg was attached |
placedOrderId | The booked order, after the trigger fires |
triggeredAt | When it fired |
cancelReason is the engine’s text for a cancel, including a cancel the engine initiated. It is null when you cancelled the order with POST /api/orders/cancel, /api/orders/cancel-all, or /api/orders/cancel-by-index, and on some cancels the engine makes without giving a reason. It is also null on an order that is not cancelled.
GET /api/history/orders/cancelled:
{
"cancelledOrders": [{ "orderId": 880, "cancelledAt": 1764000000 }],
"nextCursor": null
}It lists your booked orders that were cancelled, newest order first. Conditionals are not listed. cancelledAt is unix seconds. A page can be short or empty while older cancelled orders remain. Keep paging until nextCursor is null.
GET /api/history/orders/active:
{
"activeOrders": [{ "orderId": 880, "quantityLeft": 1.5, "createdAt": 1764000000 }]
}It lists your booked orders that are OPEN or PARTIALLY_FILLED, newest first. Conditionals are not listed. quantityLeft is the unfilled quantity in tokens. createdAt is unix seconds.
Trades
GET /api/history/trades
{
"trades": [
{
"tradeId": 9001,
"marketIndex": 2048,
"ticker": "TERA",
"side": "BUY",
"role": "TAKER",
"quantity": "2.5",
"price": "167.49",
"executedAt": 1764000000,
"fee": "0.25",
"pool": null,
"direction": "BUY",
"closedPnl": null,
"orderId": 880,
"txHash": "0xabc…",
"source": "TRADE",
"proof": null
}
],
"total": 1,
"page": 1,
"pageSize": 20,
"nextCursor": null
}quantity, price, and fee are decimal strings. role is MAKER or TAKER. closedPnl is set when the fill closed part of a position.
source | Meaning |
|---|---|
TRADE | A book trade. Carries txHash and orderId |
LIQUIDATION, BACKSTOP_LIQUIDATION, DELEVERAGE, EXIT, SETTLE, FORCED, FORCED_DELEVERAGE | A perps event. txHash is null. orderId is null when the event had no order |
direction | When |
|---|---|
BUY, SELL | A spot trade |
OPEN_LONG, CLOSE_LONG, OPEN_SHORT, CLOSE_SHORT | A perps fill, including a book trade |
proof is always null when source is not TRADE. On a TRADE row it is null when proof status is unavailable, otherwise { "status": "PENDING" } or an IN_BATCH row:
| Field | Meaning |
|---|---|
status | IN_BATCH |
batchNumber | Batch number |
l2BlockNumber | L2 block number |
rowIndex | Row in the batch |
l2TradeDigest | Trade digest |
batchTxHash | Batch transaction hash. Null until the batch executes on L1 |
final | Whether the batch is final |
Funding
GET /api/history/funding?pageSize=20
{
"funding": [
{
"journalSeq": 1200,
"marketIndex": 4,
"ticker": "TERA-PERP",
"pool": 0,
"base": "2.5",
"payment": "0.006281",
"rateCbp": 15,
"atMs": 1764000000000
}
],
"nextCursor": null
}payment is the USD the account paid (positive) or received (negative). rateCbp is the rate for one funding period, in centi-basis-points of the oracle price. It is the payment rate on Funding, the funding rate ÷ 8, within the market’s cap. base is the position size in tokens, negative for a short. Page with cursor set to nextCursor. There is no page or total.
Errors
| Status | code | Meaning |
|---|---|---|
401 | UNAUTHENTICATED | No login token or Privy JWT, or a refused one |
400 | INVALID_REQUEST | page or pageSize failed validation, or cursor is empty or too long |
429 | RATE_LIMITED | Too many requests for this account. Retry after the Retry-After seconds |
503 | SERVICE_UNAVAILABLE | The login token could not be checked right now. Try again in a moment |
500 | INTERNAL_ERROR | { "error": "Failed to authenticate request" }. Authentication of a Privy JWT failed on the server, not because of the JWT. Try again in a moment |
500 | { "error": "Failed to fetch order history" }, "Failed to fetch trade history", "Failed to fetch funding history", "Failed to fetch cancelled orders", or "Failed to fetch active orders" |