API basics tier · Reference card · API Academy

API basics.
One sheet.

Auth headers, the four core endpoints, order-status enum, position fields, decimal-units gotchas, and the error codes you’ll actually hit. Pin it; print it; come back to it.

Authentication: every request is HMAC-signed.

Every authenticated call carries three headers, lmts-api-key + lmts-timestamp + lmts-signature, computed per the scheme at docs.limitless.exchange/developers/authentication. The legacy X-API-Key header is deprecated and no longer issued to new users.

01

Authentication

M03

HMAC-signed on every authenticated call. Three headers, with EIP-712 wallet sig added for state-changing POSTs.

// Every authenticated request GET /portfolio/positions lmts-api-key: <apiKey / token id> lmts-timestamp: 2026-05-07T18:23:11.482Z lmts-signature: <base64 HMAC-SHA256> // State-changing requests POST /orders lmts-api-key: <apiKey> lmts-timestamp: … lmts-signature: … X-Wallet-Signature: 0xabc… X-Wallet-Nonce: 1714683600

HMAC headers prove the request, signed with your token secret, came from you. Wallet signature proves intent to move funds on-chain. Reads need only HMAC; orders need HMAC + wallet sig.

// Canonical signing string (what you HMAC) {ts}\n{METHOD}\n{path?query}\n{body} // HMAC-SHA256, base64-decoded secret, base64-encoded result sig = base64(HMAC_SHA256(base64_decode(secret), msg))

Body is the raw JSON for POSTs, an empty string for GET / DELETE. Server tolerates 30 s of clock skew, see docs.limitless.exchange/developers/authentication.

02

Core endpoints

M03–06
MethodPathReturnsModule
GET/marketsActive marketsM04
GET/markets/{slug}One market · metadata + bookM04
POST/ordersPlace order · needs wallet sigM05
DELETE/orders/{id}Cancel order · needs wallet sigM05
GET/portfolio/positionsCLOB + AMM positions, points, rewardsM06
GET/portfolio/tradesAMM fills · one call, no paginationM06
03

Order status enum

M05
pendingsigned, not yet on book
openresting on book
partialsome shares filled
filledfully executed
cancelledyou cancelled it
expiredTTL elapsed
rejectedsignature/nonce/balance fail

Default poll interval. 1s for pending/open, 5s for partial, stop on filled/cancelled/rejected.

04

Order side & type

M05
FieldValues
sidebuy · sell
outcomeyes · no
typelimit · market
tifgtc · ioc · fok

Default. Limit + GTC. Switch to market only when seconds matter; switch to IOC when partial fills are unacceptable.

05

Position fields

M06
costUSDC paid in (6 dec)
marketValueUSDC if closed now (6 dec)
tokensBalanceoutcome tokens (18 dec)
avgPriceUSDC per share
realizedPnlclosed cash flow
unrealizedPnlmarketValue − cost

Watch decimals. USDC = 6, outcome tokens = 18. Mixing them is the most common silent bug.

06

Decimal units

M06
AssetDecimalsDivisor
USDC61e6
Outcome tokens181e18
ETH181e18
WBTC81e8
// Helper. Always. fromUnits(amt, dec) => Number(amt) / 10 ** dec
07

PnL formulas

M06

Realised · from fills, deterministic.

realised = Σ (sell_flow) − Σ (buy_flow) − Σ (fees)

Unrealised · from open positions, live.

unrealised = (mark − avgEntry) × openSize

Total PnL = realised + unrealised. Quote unrealised with a timestamp; it’s a snapshot.

08

Errors you’ll actually hit

Cross-module
CodeMeaningFix
401Invalid API key or expired wallet sigRe-sign · check key in .env
409Nonce already usedRefresh nonce; never reuse
422Bad order shape (price out of range, etc.)Validate before signing
429Rate limitedBackoff with jitter; cache reads
503Indexer behindRetry with exp backoff; reconcile on chain

Idempotency. Always include a client-side nonce on POSTs. If the server returns 5xx, you can safely retry with the same nonce, the server dedupes.

09

Pitfalls that bite production bots

Cross-module
  1. Mixing decimal precisions. USDC at 1e6 next to outcome tokens at 1e18. Build fromUnits(), never inline divisors.
  2. Reading positions immediately after a fill. Indexer lag is 1–5s. Trust the order ack, reconcile on a separate cadence.
  3. Reconciling only /portfolio/trades. It returns AMM fills in one call (no pagination); CLOB fills live in /portfolio/history (paginated). Cache locally by txHash.
  4. Treating mid-price as fill price. Walk the book one or two levels past your size before sizing.
  5. Forgetting the spread + fee in PnL math. A 7% theoretical edge becomes a 3% realised one round-trip.
  6. Letting REST drift from chain. balanceOf on the outcome token contract is the truth. Reconcile on a cron; alert on any non-dust mismatch.