Skip to main content

Event Replay API

The Event Replay API provides a way to fetch events that your system may have missed. All events (market changes, trades, settlements, etc.) are persisted with incrementing sequence numbers and retained for 24 hours.

Authentication: X-Api-Key header required.

Why Event Replay?

If your webhook endpoint goes down or your WebSocket disconnects, you can replay missed events:

1. Store the last sequence number you processed
2. When reconnected, call GET /api/v1/events?since={lastSequence}
3. Process events in order
4. Update your stored sequence number

Replay Events

GET /api/v1/events

Query Parameters:

ParameterTypeDescription
sinceintegerReturn events with sequence > this value
eventTypestringFilter by event type (e.g. ORDER_MATCHED)
marketIdstring (UUID)Filter by market
limitintegerPage size (default: 100, max: 1000)

Example — fetch all events since sequence 42:

curl "https://polymarket.sandbox.playbatman.com/api/v1/events?since=42&limit=100" \
-H "X-Api-Key: your-api-key"

Response:

{
"success": true,
"data": {
"events": [
{
"id": "event-uuid-1",
"sequence": 43,
"operatorId": "operator-uuid",
"eventType": "ORDER_PLACED",
"marketId": "market-uuid",
"payload": {
"orderId": "order-uuid",
"marketId": "market-uuid",
"outcomeId": "outcome-uuid",
"operatorId": "operator-uuid",
"side": "BUY",
"type": "LIMIT",
"shares": 50,
"price": 0.65,
"status": "PENDING",
"filledShares": 0,
"timestamp": 1708293600000
},
"createdAt": "2026-02-18T23:00:00.000Z",
"expiresAt": "2026-02-19T23:00:00.000Z"
},
{
"id": "event-uuid-2",
"sequence": 44,
"operatorId": "operator-uuid",
"eventType": "ORDER_MATCHED",
"marketId": "market-uuid",
"payload": {
"orderId": "order-uuid",
"marketId": "market-uuid",
"outcomeId": "outcome-uuid",
"operatorId": "operator-uuid",
"tradeId": "trade-uuid",
"side": "BUY",
"price": 0.65,
"shares": 50,
"filledShares": 50,
"remainingShares": 0,
"status": "FILLED",
"timestamp": 1708293600000
},
"createdAt": "2026-02-18T23:00:01.000Z",
"expiresAt": "2026-02-19T23:00:01.000Z"
}
],
"hasMore": true,
"lastSequence": 44
}
}

Pagination

Use the lastSequence from the response as the since parameter in your next request:

# First page
GET /api/v1/events?limit=100

# Next page (using lastSequence from previous response)
GET /api/v1/events?since=44&limit=100

# Continue until hasMore is false

Filtering

By Event Type

# Only trade events
GET /api/v1/events?eventType=ORDER_MATCHED

# Only market resolution events
GET /api/v1/events?eventType=MARKET_RESOLVED

By Market

# Events for a specific market
GET /api/v1/events?marketId=market-uuid

# Combined filters
GET /api/v1/events?marketId=market-uuid&eventType=ORDER_MATCHED&since=100

Event Types

Event TypeDescription
MARKET_CREATEDA new market was created
MARKET_STATUS_CHANGEDMarket status changed (open, suspended, closed, etc.)
MARKET_RESOLVEDMarket resolved with a winning outcome
ORDER_BOOK_UPDATEOrder book changed
PRICE_UPDATEDMarket prices updated
ORDER_PLACEDA new order was submitted
ORDER_MATCHEDAn order was matched, trade executed
ORDER_CANCELLEDAn order was cancelled
POSITION_UPDATEDA position was updated
SETTLEMENT_COMPLETEDA settlement was processed

Event Fields

FieldTypeDescription
idstring (UUID)Unique event ID
sequenceintegerMonotonically increasing sequence number
operatorIdstring (UUID)Operator the event belongs to
eventTypestringOne of the event types above
marketIdstring (UUID) | nullAssociated market (null for non-market events)
payloadobjectEvent-specific data
createdAtstring (ISO 8601)When the event occurred
expiresAtstring (ISO 8601)When the event will be deleted (24h retention)

Retention

  • Events are retained for 24 hours from creation
  • Expired events are automatically cleaned up every hour
  • Store the lastSequence value on your side to resume after outages

Integration Pattern

Here's a recommended pattern for reliable event processing:

let lastSequence = loadLastSequence(); // Load from your database

async function syncEvents() {
let hasMore = true;

while (hasMore) {
const response = await fetch(
`https://polymarket.sandbox.playbatman.com/api/v1/events?since=${lastSequence}&limit=100`,
{ headers: { 'X-Api-Key': API_KEY } }
);

const { data } = await response.json();

for (const event of data.events) {
await processEvent(event);
lastSequence = event.sequence;
saveLastSequence(lastSequence); // Persist to your database
}

hasMore = data.hasMore;
}
}

// Run on startup and periodically as a safety net
syncEvents();
setInterval(syncEvents, 60000); // Every minute