{
  "info": {
    "name": "Prediction Market API",
    "description": "Operator integration API for the Prediction Market Engine.\n\nSet the `baseUrl` and `apiKey` variables before using.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "apikey",
    "apikey": [
      { "key": "key", "value": "X-Api-Key", "type": "string" },
      { "key": "value", "value": "{{apiKey}}", "type": "string" },
      { "key": "in", "value": "header", "type": "string" }
    ]
  },
  "variable": [
    { "key": "baseUrl", "value": "https://polymarket.sandbox.playbatman.com", "type": "string" },
    { "key": "apiKey", "value": "your-api-key", "type": "string" },
    { "key": "marketId", "value": "", "type": "string" },
    { "key": "outcomeId", "value": "", "type": "string" },
    { "key": "categoryId", "value": "", "type": "string" },
    { "key": "orderId", "value": "", "type": "string" },
    { "key": "webhookId", "value": "", "type": "string" }
  ],
  "item": [
    {
      "name": "Health",
      "item": [
        {
          "name": "Health Check",
          "request": {
            "method": "GET",
            "header": [],
            "url": { "raw": "{{baseUrl}}/health", "host": ["{{baseUrl}}"], "path": ["health"] },
            "auth": { "type": "noauth" }
          }
        },
        {
          "name": "Ready Check",
          "request": {
            "method": "GET",
            "header": [],
            "url": { "raw": "{{baseUrl}}/ready", "host": ["{{baseUrl}}"], "path": ["ready"] },
            "auth": { "type": "noauth" }
          }
        }
      ]
    },
    {
      "name": "Categories",
      "item": [
        {
          "name": "Create Category",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Sports\",\n  \"slug\": \"sports\",\n  \"description\": \"Sports prediction markets\",\n  \"sortOrder\": 1\n}"
            },
            "url": { "raw": "{{baseUrl}}/api/v1/categories", "host": ["{{baseUrl}}"], "path": ["api", "v1", "categories"] }
          }
        },
        {
          "name": "List Categories",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/api/v1/categories?includeGlobal=true&activeOnly=true",
              "host": ["{{baseUrl}}"],
              "path": ["api", "v1", "categories"],
              "query": [
                { "key": "includeGlobal", "value": "true" },
                { "key": "activeOnly", "value": "true" }
              ]
            }
          }
        },
        {
          "name": "Get Category",
          "request": {
            "method": "GET",
            "header": [],
            "url": { "raw": "{{baseUrl}}/api/v1/categories/{{categoryId}}", "host": ["{{baseUrl}}"], "path": ["api", "v1", "categories", "{{categoryId}}"] },
            "auth": { "type": "noauth" }
          }
        }
      ]
    },
    {
      "name": "Markets",
      "item": [
        {
          "name": "Create Market",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "var jsonData = pm.response.json();",
                  "if (jsonData.success && jsonData.data) {",
                  "  pm.collectionVariables.set('marketId', jsonData.data.id);",
                  "  if (jsonData.data.outcomes && jsonData.data.outcomes.length > 0) {",
                  "    pm.collectionVariables.set('outcomeId', jsonData.data.outcomes[0].id);",
                  "  }",
                  "}"
                ],
                "type": "text/javascript"
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"title\": \"Will it rain tomorrow?\",\n  \"description\": \"Resolves YES if rainfall > 0mm recorded by 11:59 PM\",\n  \"currency\": \"USD\",\n  \"tradingStartsAt\": \"2026-03-01T00:00:00Z\",\n  \"tradingEndsAt\": \"2026-06-01T00:00:00Z\",\n  \"outcomes\": [\n    { \"name\": \"Yes\", \"description\": \"It rains\" },\n    { \"name\": \"No\", \"description\": \"It does not rain\" }\n  ]\n}"
            },
            "url": { "raw": "{{baseUrl}}/api/v1/markets", "host": ["{{baseUrl}}"], "path": ["api", "v1", "markets"] }
          }
        },
        {
          "name": "List Markets",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/api/v1/markets?status=OPEN,DRAFT&limit=20",
              "host": ["{{baseUrl}}"],
              "path": ["api", "v1", "markets"],
              "query": [
                { "key": "status", "value": "OPEN,DRAFT" },
                { "key": "limit", "value": "20" },
                { "key": "categoryId", "value": "", "disabled": true },
                { "key": "search", "value": "", "disabled": true },
                { "key": "cursor", "value": "", "disabled": true }
              ]
            }
          }
        },
        {
          "name": "Get Market",
          "request": {
            "method": "GET",
            "header": [],
            "url": { "raw": "{{baseUrl}}/api/v1/markets/{{marketId}}", "host": ["{{baseUrl}}"], "path": ["api", "v1", "markets", "{{marketId}}"] }
          }
        },
        {
          "name": "Update Market",
          "request": {
            "method": "PATCH",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"title\": \"Updated Market Title\",\n  \"description\": \"Updated description\"\n}"
            },
            "url": { "raw": "{{baseUrl}}/api/v1/markets/{{marketId}}", "host": ["{{baseUrl}}"], "path": ["api", "v1", "markets", "{{marketId}}"] }
          }
        },
        {
          "name": "Open Market",
          "request": {
            "method": "POST",
            "header": [],
            "url": { "raw": "{{baseUrl}}/api/v1/markets/{{marketId}}/open", "host": ["{{baseUrl}}"], "path": ["api", "v1", "markets", "{{marketId}}", "open"] }
          }
        },
        {
          "name": "Suspend Market",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"reason\": \"Irregular trading activity detected\"\n}"
            },
            "url": { "raw": "{{baseUrl}}/api/v1/markets/{{marketId}}/suspend", "host": ["{{baseUrl}}"], "path": ["api", "v1", "markets", "{{marketId}}", "suspend"] }
          }
        },
        {
          "name": "Resume Market",
          "request": {
            "method": "POST",
            "header": [],
            "url": { "raw": "{{baseUrl}}/api/v1/markets/{{marketId}}/resume", "host": ["{{baseUrl}}"], "path": ["api", "v1", "markets", "{{marketId}}", "resume"] }
          }
        },
        {
          "name": "Close Market",
          "request": {
            "method": "POST",
            "header": [],
            "url": { "raw": "{{baseUrl}}/api/v1/markets/{{marketId}}/close", "host": ["{{baseUrl}}"], "path": ["api", "v1", "markets", "{{marketId}}", "close"] }
          }
        },
        {
          "name": "Resolve Market",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"winningOutcomeId\": \"{{outcomeId}}\",\n  \"resolutionSource\": \"Official result\",\n  \"resolutionNotes\": \"Outcome confirmed\"\n}"
            },
            "url": { "raw": "{{baseUrl}}/api/v1/markets/{{marketId}}/resolve", "host": ["{{baseUrl}}"], "path": ["api", "v1", "markets", "{{marketId}}", "resolve"] }
          }
        },
        {
          "name": "Cancel Market",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"reason\": \"Event cancelled\"\n}"
            },
            "url": { "raw": "{{baseUrl}}/api/v1/markets/{{marketId}}/cancel", "host": ["{{baseUrl}}"], "path": ["api", "v1", "markets", "{{marketId}}", "cancel"] }
          }
        }
      ]
    },
    {
      "name": "Orders",
      "item": [
        {
          "name": "Place Order (Limit Buy)",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "var jsonData = pm.response.json();",
                  "if (jsonData.success && jsonData.data && jsonData.data.order) {",
                  "  pm.collectionVariables.set('orderId', jsonData.data.order.id);",
                  "}"
                ],
                "type": "text/javascript"
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"marketId\": \"{{marketId}}\",\n  \"outcomeId\": \"{{outcomeId}}\",\n  \"playerId\": \"player-123\",\n  \"side\": \"BUY\",\n  \"type\": \"LIMIT\",\n  \"shares\": 50,\n  \"price\": 0.65,\n  \"transactionId\": \"txn-001\"\n}"
            },
            "url": { "raw": "{{baseUrl}}/api/v1/orders", "host": ["{{baseUrl}}"], "path": ["api", "v1", "orders"] }
          }
        },
        {
          "name": "Place Order (Limit Sell)",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"marketId\": \"{{marketId}}\",\n  \"outcomeId\": \"{{outcomeId}}\",\n  \"playerId\": \"player-456\",\n  \"side\": \"SELL\",\n  \"type\": \"LIMIT\",\n  \"shares\": 25,\n  \"price\": 0.70\n}"
            },
            "url": { "raw": "{{baseUrl}}/api/v1/orders", "host": ["{{baseUrl}}"], "path": ["api", "v1", "orders"] }
          }
        },
        {
          "name": "Place Order (Market Buy)",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"marketId\": \"{{marketId}}\",\n  \"outcomeId\": \"{{outcomeId}}\",\n  \"playerId\": \"player-789\",\n  \"side\": \"BUY\",\n  \"type\": \"MARKET\",\n  \"shares\": 10\n}"
            },
            "url": { "raw": "{{baseUrl}}/api/v1/orders", "host": ["{{baseUrl}}"], "path": ["api", "v1", "orders"] }
          }
        },
        {
          "name": "Get Order",
          "request": {
            "method": "GET",
            "header": [],
            "url": { "raw": "{{baseUrl}}/api/v1/orders/{{orderId}}", "host": ["{{baseUrl}}"], "path": ["api", "v1", "orders", "{{orderId}}"] }
          }
        },
        {
          "name": "List Orders",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/api/v1/orders?limit=20",
              "host": ["{{baseUrl}}"],
              "path": ["api", "v1", "orders"],
              "query": [
                { "key": "limit", "value": "20" },
                { "key": "playerId", "value": "", "disabled": true },
                { "key": "marketId", "value": "", "disabled": true },
                { "key": "outcomeId", "value": "", "disabled": true },
                { "key": "side", "value": "", "disabled": true },
                { "key": "type", "value": "", "disabled": true },
                { "key": "status", "value": "", "disabled": true },
                { "key": "cursor", "value": "", "disabled": true }
              ]
            }
          }
        },
        {
          "name": "List Orders by Player",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/api/v1/orders?playerId=player-123&status=PENDING,PARTIAL",
              "host": ["{{baseUrl}}"],
              "path": ["api", "v1", "orders"],
              "query": [
                { "key": "playerId", "value": "player-123" },
                { "key": "status", "value": "PENDING,PARTIAL" }
              ]
            }
          }
        },
        {
          "name": "Cancel Order",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": { "raw": "{{baseUrl}}/api/v1/orders/{{orderId}}", "host": ["{{baseUrl}}"], "path": ["api", "v1", "orders", "{{orderId}}"] }
          }
        }
      ]
    },
    {
      "name": "Positions",
      "item": [
        {
          "name": "Get All Positions",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/api/v1/positions",
              "host": ["{{baseUrl}}"],
              "path": ["api", "v1", "positions"],
              "query": [
                { "key": "marketId", "value": "", "disabled": true }
              ]
            }
          }
        },
        {
          "name": "Get Positions by Market",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/api/v1/positions?marketId={{marketId}}",
              "host": ["{{baseUrl}}"],
              "path": ["api", "v1", "positions"],
              "query": [
                { "key": "marketId", "value": "{{marketId}}" }
              ]
            }
          }
        }
      ]
    },
    {
      "name": "Trades",
      "item": [
        {
          "name": "List Trades",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/api/v1/trades?limit=20",
              "host": ["{{baseUrl}}"],
              "path": ["api", "v1", "trades"],
              "query": [
                { "key": "limit", "value": "20" },
                { "key": "marketId", "value": "", "disabled": true },
                { "key": "outcomeId", "value": "", "disabled": true },
                { "key": "cursor", "value": "", "disabled": true }
              ]
            }
          }
        },
        {
          "name": "List Trades by Market",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/api/v1/trades?marketId={{marketId}}",
              "host": ["{{baseUrl}}"],
              "path": ["api", "v1", "trades"],
              "query": [
                { "key": "marketId", "value": "{{marketId}}" }
              ]
            }
          }
        }
      ]
    },
    {
      "name": "Market Data",
      "item": [
        {
          "name": "Get Order Book",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/api/v1/markets/{{marketId}}/orderbook/{{outcomeId}}?depth=10",
              "host": ["{{baseUrl}}"],
              "path": ["api", "v1", "markets", "{{marketId}}", "orderbook", "{{outcomeId}}"],
              "query": [
                { "key": "depth", "value": "10" }
              ]
            },
            "auth": { "type": "noauth" }
          }
        },
        {
          "name": "Get Market Prices",
          "request": {
            "method": "GET",
            "header": [],
            "url": { "raw": "{{baseUrl}}/api/v1/markets/{{marketId}}/prices", "host": ["{{baseUrl}}"], "path": ["api", "v1", "markets", "{{marketId}}", "prices"] },
            "auth": { "type": "noauth" }
          }
        },
        {
          "name": "Get Outcome Price",
          "request": {
            "method": "GET",
            "header": [],
            "url": { "raw": "{{baseUrl}}/api/v1/markets/{{marketId}}/prices/{{outcomeId}}", "host": ["{{baseUrl}}"], "path": ["api", "v1", "markets", "{{marketId}}", "prices", "{{outcomeId}}"] },
            "auth": { "type": "noauth" }
          }
        }
      ]
    },
    {
      "name": "Stats",
      "item": [
        {
          "name": "Overview",
          "request": {
            "method": "GET",
            "header": [],
            "url": { "raw": "{{baseUrl}}/api/v1/stats/overview", "host": ["{{baseUrl}}"], "path": ["api", "v1", "stats", "overview"] }
          }
        }
      ]
    },
    {
      "name": "Settlements",
      "item": [
        {
          "name": "Settle Market",
          "request": {
            "method": "POST",
            "header": [],
            "url": { "raw": "{{baseUrl}}/api/v1/markets/{{marketId}}/settle", "host": ["{{baseUrl}}"], "path": ["api", "v1", "markets", "{{marketId}}", "settle"] }
          }
        },
        {
          "name": "Get Settlement Status",
          "request": {
            "method": "GET",
            "header": [],
            "url": { "raw": "{{baseUrl}}/api/v1/markets/{{marketId}}/settlement-status", "host": ["{{baseUrl}}"], "path": ["api", "v1", "markets", "{{marketId}}", "settlement-status"] }
          }
        },
        {
          "name": "Retry Failed Settlements",
          "request": {
            "method": "POST",
            "header": [],
            "url": { "raw": "{{baseUrl}}/api/v1/markets/{{marketId}}/retry-settlements", "host": ["{{baseUrl}}"], "path": ["api", "v1", "markets", "{{marketId}}", "retry-settlements"] }
          }
        },
        {
          "name": "Get Operator Settlements",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/api/v1/settlements",
              "host": ["{{baseUrl}}"],
              "path": ["api", "v1", "settlements"],
              "query": [
                { "key": "marketId", "value": "", "disabled": true }
              ]
            }
          }
        },
        {
          "name": "Get Settlements by Market",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/api/v1/settlements?marketId={{marketId}}",
              "host": ["{{baseUrl}}"],
              "path": ["api", "v1", "settlements"],
              "query": [
                { "key": "marketId", "value": "{{marketId}}" }
              ]
            }
          }
        }
      ]
    },
    {
      "name": "Webhooks",
      "item": [
        {
          "name": "Register Webhook",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "var jsonData = pm.response.json();",
                  "if (jsonData.success && jsonData.data) {",
                  "  pm.collectionVariables.set('webhookId', jsonData.data.id);",
                  "}"
                ],
                "type": "text/javascript"
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"url\": \"https://example.com/webhooks/prediction\",\n  \"events\": [\"ORDER_MATCHED\", \"MARKET_RESOLVED\", \"SETTLEMENT_COMPLETED\"],\n  \"description\": \"Production webhook\"\n}"
            },
            "url": { "raw": "{{baseUrl}}/api/v1/webhooks", "host": ["{{baseUrl}}"], "path": ["api", "v1", "webhooks"] }
          }
        },
        {
          "name": "List Webhooks",
          "request": {
            "method": "GET",
            "header": [],
            "url": { "raw": "{{baseUrl}}/api/v1/webhooks", "host": ["{{baseUrl}}"], "path": ["api", "v1", "webhooks"] }
          }
        },
        {
          "name": "Update Webhook",
          "request": {
            "method": "PATCH",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"events\": [\"ORDER_MATCHED\", \"MARKET_RESOLVED\"],\n  \"isActive\": true\n}"
            },
            "url": { "raw": "{{baseUrl}}/api/v1/webhooks/{{webhookId}}", "host": ["{{baseUrl}}"], "path": ["api", "v1", "webhooks", "{{webhookId}}"] }
          }
        },
        {
          "name": "Delete Webhook",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": { "raw": "{{baseUrl}}/api/v1/webhooks/{{webhookId}}", "host": ["{{baseUrl}}"], "path": ["api", "v1", "webhooks", "{{webhookId}}"] }
          }
        }
      ]
    },
    {
      "name": "Events",
      "item": [
        {
          "name": "Replay Events",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/api/v1/events?limit=100",
              "host": ["{{baseUrl}}"],
              "path": ["api", "v1", "events"],
              "query": [
                { "key": "limit", "value": "100" },
                { "key": "since", "value": "", "disabled": true },
                { "key": "eventType", "value": "", "disabled": true },
                { "key": "marketId", "value": "", "disabled": true }
              ]
            }
          }
        },
        {
          "name": "Replay Events (with filters)",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/api/v1/events?since=0&eventType=ORDER_MATCHED&marketId={{marketId}}&limit=50",
              "host": ["{{baseUrl}}"],
              "path": ["api", "v1", "events"],
              "query": [
                { "key": "since", "value": "0" },
                { "key": "eventType", "value": "ORDER_MATCHED" },
                { "key": "marketId", "value": "{{marketId}}" },
                { "key": "limit", "value": "50" }
              ]
            }
          }
        }
      ]
    }
  ]
}
