API reference
The Context API provides programmatic access to markets, orders, and portfolio data. All endpoints use the v2 API.Base URL
Authentication
Most endpoints require an API key passed as a Bearer token in theAuthorization header:
GET /markets- List marketsGET /markets/:id- Get market detailsGET /markets/:id/quotes- Get current bid/ask pricesGET /markets/:id/orderbook- Get orderbook (also supports SSE streaming)GET /markets/:id/simulate- Simulate a tradeGET /markets/:id/prices- Get price historyGET /markets/:id/oracle- Get oracle dataGET /markets/:id/oracle/quotes- Get oracle probability estimatesPOST /markets/:id/oracle/quotes- Request new oracle analysisGET /markets/:id/activity- Get market activityGET /activity- Global activity feed
- All
/orders/*endpoints - All
/portfolio/*endpoints - All
/balance/*endpoints - All
/gasless/*endpoints
Request format
Content types
- Request bodies:
application/json - Orderbook streaming:
text/event-stream(viaAcceptheader)
Response format
All responses are JSON with consistent structure:Success response
Error response
Bulk operation errors
HTTP status codes
| Code | Description |
|---|---|
| 200 | Success |
| 201 | Created (new order) |
| 400 | Bad Request (validation error, invalid signature) |
| 404 | Not Found |
| 409 | Conflict (duplicate order) |
| 429 | Rate Limited |
| 500 | Internal Server Error |
Pagination
The API uses cursor-based pagination for list endpoints. Cursors are opaque strings - don’t parse or construct them manually.cursor is null, you’ve reached the end of the results.
Price and size encoding
All prices and sizes use 6 decimal places (TUSD precision):| Human readable | Encoded value |
|---|---|
| $0.50 | 500000 |
| $0.01 | 10000 |
| 1 share | 1000000 |
| 0.5 shares | 500000 |
BigInt handling
All numeric values that could exceed JavaScript’s safe integer range (prices, sizes, balances) are returned as strings:Addresses and hashes
All Ethereum addresses and hashes are returned as checksummed hex strings:Real-time orderbook streaming
TheGET /markets/:id/orderbook endpoint supports Server-Sent Events (SSE) for real-time updates. Set the Accept header to text/event-stream to receive a stream instead of a JSON snapshot.
Event types
| Event | Description |
|---|---|
snapshot | Full orderbook state (sent on connection) |
price_change | A price level was added, updated, or removed |
last_trade | A trade was executed |
heartbeat | Keep-alive signal (every 5 seconds) |
Query parameters
| Param | Type | Default | Description |
|---|---|---|---|
depth | integer | 20 | Number of price levels (1-100) |
outcomeIndex | integer | 0 | Outcome to stream (0 = Yes) |
JSON snapshot mode
Without the SSEAccept header, the endpoint returns a JSON snapshot with ETag support for conditional requests. Use If-None-Match to avoid re-fetching unchanged data: