Skip to main content

API Reference

These are the actual REST endpoints the aggregator exposes from magma-backend-v2. Every route group below is registered with the /v1 prefix (server.register(<p>Routes, { prefix: '/v1' })), so the route file's '/dflow/markets' is served at /v1/dflow/markets.

Base URL: https://api.magmaprotocol.xyz.

/v1/<platform>/v1/markets

The aggregator lives at /v1/<platform> (e.g. /v1/polymarket/markets). MAGMA's native binary markets live at /v1/markets and are a different product (Solana magma_binary_vault, with create/resolve/finalize/refund). Do not confuse the two — see Native binary markets at the bottom and Binary Markets → Program & API.

All trade/build endpoints return unsigned payloads only; the user signs in the browser (see Trading & Settlement).

DFlow / Kalshi — /v1/dflow/*

Kalshi prediction markets via the DFlow (Pond) execution engine on Solana.

MethodEndpointPurpose
GET/v1/dflow/marketsActive Kalshi markets/events (cached 30s); category, limit, offset.
GET/v1/dflow/markets/:tickerSingle market detail by ticker.
GET/v1/dflow/markets/:ticker/orderbookMarket orderbook.
POST/v1/dflow/tradeBuild a trade via DFlow's /order; returns a base64 unsigned tx (Proof-KYC gated on buys → PROOF_REQUIRED).
GET/v1/dflow/positions/:walletWallet's outcome-token balances (on-chain Token-2022, joined to market metadata).
POST/v1/dflow/redeemRedeem winning outcome tokens (sell back to settlement).
GET/v1/dflow/order-status?signature=Poll async CLP fill status to terminal.
GET/v1/dflow/sponsor-statusIs gasless enabled + the sponsor pubkey.
POST/v1/dflow/sponsor-submitCo-sign a user-signed sponsored tx + broadcast (orderId, signedTransaction).

Polymarket — /v1/polymarket/*

Polygon CLOB; data via Gamma (discovery) + Data API (positions). Trading is client-side (@polymarket/clob-client-v2), so there is no backend order/relay route.

MethodEndpointPurpose
GET/v1/polymarket/marketsActive markets (Gamma, cached 60s); category, limit, offset.
GET/v1/polymarket/markets/search?q=Keyword search.
GET/v1/polymarket/markets/:conditionIdSingle market by condition id.
GET/v1/polymarket/positions/:walletPolygon positions (Data API, read-only).

Limitless — /v1/limitless/*

Base CLOB via the partner SDK; sign-only (backend builds, browser signs, backend relays under HMAC).

MethodEndpointPurpose
GET/v1/limitless/marketsActive markets; category, limit, offset.
GET/v1/limitless/markets/search?q=Keyword search.
GET/v1/limitless/markets/:slugSingle market (slug or address).
GET/v1/limitless/positions/:walletBase portfolio positions (public).
GET/v1/limitless/signing-messageMessage to sign for partner sub-account registration.
POST/v1/limitless/registerRegister the wallet as a partner sub-account (account, signingMessage, signature).
GET/v1/limitless/trade-config/:walletProfile id + feeRateBps + hasCreds.
POST/v1/limitless/order/buildBuild the unsigned FOK order + EIP-712 typed data.
POST/v1/limitless/orderRelay the signed order under partner HMAC.

Predict.fun — /v1/predict/*

BNB Chain CLOB via @predictdotfun/sdk; sign-only + one-time referral fee enrolment.

MethodEndpointPurpose
GET/v1/predict/marketsActive markets, volume-sorted (cached 60s); limit, category, all.
GET/v1/predict/markets/:idSingle market detail.
GET/v1/predict/markets/:id/orderbookCLOB orderbook.
POST/v1/predict/order/buildBuild the unsigned order + EIP-712 typed data (SDK selects exchange via isNegRisk/isYieldBearing).
POST/v1/predict/orderRelay the signed order (x-api-key).
GET/v1/predict/positions/:walletWallet's positions.
GET/v1/predict/trade-configfeeRateBps, hasCreds, hasReferral, testnet, chainId.
GET/v1/predict/auth-messageMessage to sign for referral enrolment.
POST/v1/predict/referralSet MAGMA as the user's referrer (signer, signature, message).

Rain — /v1/rain/*

Cross-chain AMM; backend returns an unsigned EVM tx for the browser to send. Rain is the only aggregated venue with a create-market route.

MethodEndpointPurpose
GET/v1/rain/marketsOpen AMM markets (cross-chain, cached 60s); category, limit, offset.
GET/v1/rain/markets/search?q=Search (any language; language optional).
GET/v1/rain/markets/:idSingle market.
GET/v1/rain/positions/:walletWallet's Rain positions.
POST/v1/rain/markets/createCreate a market via Rain (Rain-unique; question ≥ 20 chars, endDate).
POST/v1/rain/trade/quoteLive AMM quote (marketId, outcome, amount).
POST/v1/rain/trade/buildBuild the unsigned trade tx (contractAddress + txData); eligibility-gated.

Opinion — /v1/opinion/*

BNB Chain CLOB for macro / economics markets.

MethodEndpointPurpose
GET/v1/opinion/marketsActive macro markets (cached 60s); category, limit, offset.
GET/v1/opinion/markets/search?q=Search.
GET/v1/opinion/markets/:idSingle market.
GET/v1/opinion/markets/:id/orderbookCLOB orderbook.
GET/v1/opinion/positions/:walletWallet's positions.
POST/v1/opinion/order/buildBuild the order (eligibility-gated; returns EIP-712 typed data when the CLOB SDK path is active).
POST/v1/opinion/order/submitSubmit the (optionally signed) order.

Overtime V2 — /v1/overtime/*

Optimism sports AMM; quote on the backend, bet placed on-chain via SportsAMMV2.trade().

MethodEndpointPurpose
GET/v1/overtime/marketsOpen sports markets (cached 60s); leagueId, limit, offset.
GET/v1/overtime/live-marketsIn-play markets.
GET/v1/overtime/markets/search?q=Search by team / league.
GET/v1/overtime/markets/:gameIdSingle market (with child markets).
GET/v1/overtime/positions/:walletWallet's ticket history.
GET/v1/overtime/configOn-chain contract config (SportsAMMV2, USDC, referrer, chainId).
POST/v1/overtime/quoteBuy-in quote (payout/profit); eligibility-gated. Bet itself is on-chain.

Conventions

  • Prefix: all of the above are under /v1 (registered in src/server.ts).
  • Reads are cached (Redis for DFlow/Polymarket/Limitless; in-memory TTL for Predict/Rain/Opinion/Overtime) and return a markets array with a total/count (some wrap it in success).
  • :wallet / :id / :ticker / :conditionId / :slug / :gameId are path params keyed to each platform's identifier (see Market Normalization).
  • Trade endpoints never sign — they build/quote/relay. The signature is produced by the user's wallet in the browser.

Native binary markets (NOT the aggregator)

For contrast — these are MAGMA's own markets, not third-party venues. They share the /v1 prefix but are a separate product served by routes/markets.ts (Solana magma_binary_vault):

MethodEndpointPurpose
GET/v1/marketsList native binary markets (filterable).
GET/v1/markets/:idSingle native market.
POST/v1/marketsCreate a native binary market (fee-gated).
POST/v1/markets/:id/resolveSubmit oracle resolution.
POST/v1/markets/:id/finalizeFinalize after timelock.
POST/v1/markets/:id/refundTrigger refund (admin).
GET/v1/markets/:id/positionsPositions for a native market.
GET/v1/markets/user/:walletA wallet's native binary positions.

These are documented in full at Binary Markets → Program & API. The aggregator never uses /v1/markets.

See also