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 —Documentation Index
Fetch the complete documentation index at: https://docs.kash.bot/llms.txt
Use this file to discover all available pages before exploring further.
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
The market’s unique identifier (UUID). Use
GET /api/markets to discover market IDs.Query Parameters
Which outcome to price. Zero-indexed. For binary markets:
0 = YES, 1 = NO. Must be between 0 and numOutcomes - 1.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).Input size as a positive integer in atomic units, passed as a string to preserve precision. Units depend on
action:buy→ USDC atomic-6.1_000_000= 1 USDC.sell→ token 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 withBigInt(...).
| Field family | Unit | Example | Notes |
|---|---|---|---|
USDC (amountIn, usdcOut) | atomic-6 | "1000000" = 1 USDC | 6 decimals, matches USDC on Base. |
Tokens, prices, capital shares (tokensOut, tokensIn, grossRelease, reserveAfter, c, pAfter[], qAfter[]) | WAD-18 | "1000000000000000000" = 1.0 | Protocol-internal 18-decimal fixed point. |
units object reflecting the above so you never have to hardcode the convention on the caller side.
Response — Buy
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.{ "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:Always
"sell" for this variant.Outcome tokens you would burn, WAD-18 (echoed from
amount).USDC you would receive, atomic-6. This is already net of the AMM’s sell fee (
sellFeeBps) — it is what the user actually gets.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.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?”
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 — walkamount 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.
usdcOuton sells is post-fee. If you need to display the fee, computegrossRelease / 1e18 * 1e6 - Number(usdcOut)(or do it in bigint math).- Buy fee is zero on the current AMM;
tokensOutreflects the full reserve increase. pAfterandqAfteralways sum to1e18. The last element may absorb up to 1 wei of rounding dust.effectivePriceis 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 withBigInt(...).- Finding market IDs. Use
GET /api/marketsfor pagination/filtering orGET /api/markets/:idfor a single market. Both are public and CORS-enabled.