Skip to main content
Fetch a live buy-or-sell price quote for any outcome of a prediction market. The endpoint calls the AMM’s own on-chain view functions — quoteBuyExactAssetsIn and quoteSellExactTokensIn on the Market contract — and returns the full protocol response, so integrators have access to the same numbers the UI uses. No authentication is required.

Endpoint

Path Parameters

string
required
The market’s unique identifier (UUID). Use GET /api/markets to discover market IDs.

Query Parameters

number
required
Which outcome to price. Zero-indexed. For binary markets: 0 = YES, 1 = NO. Must be between 0 and numOutcomes - 1.
string
required
buy quotes how many outcome tokens you receive for a given USDC input.sell quotes how much USDC you receive for a given outcome-token input (already net of the AMM’s sell fee).
string
required
Input size as a positive integer in atomic units, passed as a string to preserve precision. Units depend on action:
  • buyUSDC atomic-6. 1_000_000 = 1 USDC.
  • selltoken WAD-18. 1_000_000_000_000_000_000 = 1.0 tokens.

Units

All bigint values in the response are serialised as decimal strings so that callers can parse them losslessly with BigInt(...). The response always includes a units object reflecting the above so you never have to hardcode the convention on the caller side.

Response — Buy

object
object
Summary of the market the quote was computed for: id, contractAddress (the on-chain Market contract), chainId (8453 = Base mainnet), outcomes (labels and DB-side probabilities), and status.
object
{ "usdc": "atomic-6", "token": "wad-18" } — spelling out the units so you don’t have to hardcode them.

Response — Sell

The sell response has the same shape as the buy response, with the following differences:
string
Always "sell" for this variant.
string
Outcome tokens you would burn, WAD-18 (echoed from amount).
string
USDC you would receive, atomic-6. This is already net of the AMM’s sell fee (sellFeeBps) — it is what the user actually gets.
string
The pre-fee reserve release in WAD-18. The difference between grossRelease (converted to atomic USDC) and usdcOut is the fee the protocol retains. Exposed for integrators who want to display the fee transparently.
All other fields (reserveAfter, c, pAfter, qAfter, effectivePrice, impliedProbability) behave identically to the buy response.

Rate Limit

100 requests per minute per IP address. Quotes are cached for 10 seconds on the server side; repeated requests for the same (id, outcomeIndex, action, amount) within that window are essentially free.

Example Requests

Example Responses

200 - Buy quote
200 - Sell quote
400 - Validation error
404 - Market not found

Worked Examples

Integrators rarely want the raw tuple — they want to answer real user questions. Here are the four most common ones, each mapped to one field.

”If I put in $100, how many YES tokens do I get?"

"What’s the average price I’d pay per token?"

"What’s the market probability after my trade?”

For all outcomes at once, read pAfter[]:

“How much USDC do I get if I sell 1 YES token?”

Advanced: “How much would it cost to move the market to 70%?”

There’s no single-call answer — walk amount up and watch pAfter[outcomeIndex] move. Quotes are cached 10s server-side, so a client-side binary search is cheap:

Notes & Gotchas

  • Quotes are view calls — nothing on-chain changes. You can poll at will within the rate limit.
  • usdcOut on sells is post-fee. If you need to display the fee, compute grossRelease / 1e18 * 1e6 - Number(usdcOut) (or do it in bigint math).
  • Buy fee is zero on the current AMM; tokensOut reflects the full reserve increase.
  • pAfter and qAfter always sum to 1e18. The last element may absorb up to 1 wei of rounding dust.
  • effectivePrice is a JS-number convenience field and can lose precision on tiny trades. For any authoritative display or accounting, derive values from the string bigint fields with BigInt(...).
  • Finding market IDs. Use GET /api/markets for pagination/filtering or GET /api/markets/:id for a single market. Both are public and CORS-enabled.