Get Price
Get a price for a single token.
Public endpoint — no authentication required.
Mirrors Polymarket’s GET /price?token_id=...&side=BUY|SELL.
side=BUY returns the best BID; side=SELL returns the best
ASK — matching Polymarket’s LIVE CLOB wire behaviour and its API
reference (“Returns the best bid price for BUY side or best ask
price for SELL side” — docs.polymarket.com/api-reference/
market-data/get-market-price). NOTE: PM’s own docs are
self-contradictory here — the orderbook guide
(trading/orderbook#prices) claims “getPrice BUY → Best ask”, which
contradicts PM’s actual wire. PolySim originally mirrored the guide
text and was therefore INVERTED vs live PM until 2026-06-10 (Fable
API evaluation P0, verified twice with back-to-back live probes:
PM /price?side=BUY == PM /book best bid). The wire is the
authority. side is treated as REQUIRED at the handler level —
both missing and invalid values return 400 {"error": "Invalid side"} matching Polymarket’s CLOB contract.
Migration note (2026-06-10): before this fix, side=BUY returned
the best ask and side=SELL the best bid. Any PolySim-native
consumer that adapted to the inverted semantics will now see
values flipped to the other side of the book; bots ported from
py-clob-client / live PM become correct without changes.
Implementation note (post-PR #1091 Codex/Copilot review): side
is declared Optional in the FastAPI signature (not Query(...))
precisely so the missing-side case lands in this handler — not in
api_validation_error_handler as a 422 — and yields the PM-style
400 uniformly. The earlier required-Query variant routed missing
side through FastAPI’s validator before reaching this code, giving
422 instead of 400. PM SDK porters branching on {"error": "Invalid side"} would otherwise hit two different envelopes for
the same logical error.
Migration note (2026-05-11): the prior PolySim-extension behaviour
where side was optional and missing-side returned the cached
last-traded price has been removed. SDK consumers relying on that
fallback should switch to GET /v1/last-trade-price (last fill)
or GET /v1/midpoint (best-bid/best-ask average). Fresh-brain
audit PR #1075 flagged the silent fallback as drift that bites
Polymarket SDK ports on first use.
Query Parameters
Required (handler-validated) — CLOB outcome token ID. Missing OR empty returns 400 {"error": "Invalid token_id"} uniformly (no 422 leak). Same handler-validation pattern as side per Polymarket's CLOB contract.
Required (handler-validated) — BUY returns the best BID, SELL returns the best ASK, matching Polymarket's live CLOB wire ("Returns the best bid price for BUY side or best ask price for SELL side" — PM api-reference, get-market-price). Mirrors Polymarket's strict-side contract: missing OR invalid side returns 400 {"error": "Invalid side"} uniformly (no 422 leak). For midpoint use GET /v1/midpoint; for last-traded price use GET /v1/last-trade-price.