{
  "openapi": "3.0.1",
  "info": {
    "title": "Prediction Spread Scanner — Kalshi × Polymarket",
    "description": "Cross-venue prediction market data: normalized Kalshi + Polymarket markets, orderbooks, LLM-assisted event matching with confidence scores, and executable spread analysis against real orderbook depth including fees. Research/data tool for quants, dashboards and AI agents.",
    "version": "0.1",
    "x-build-id": "1mhii6AbIfueamtGV"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/nanare-sudo~prediction-spread-scanner/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-nanare-sudo-prediction-spread-scanner",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/nanare-sudo~prediction-spread-scanner/runs": {
      "post": {
        "operationId": "runs-sync-nanare-sudo-prediction-spread-scanner",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/nanare-sudo~prediction-spread-scanner/run-sync": {
      "post": {
        "operationId": "run-sync-nanare-sudo-prediction-spread-scanner",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "properties": {
          "mode": {
            "title": "Mode",
            "enum": [
              "scan",
              "markets",
              "orderbooks",
              "matches",
              "discover",
              "canary"
            ],
            "type": "string",
            "description": "`scan` = full pipeline: load both venues, 3-stage event matching, orderbook pairs, executable spread analysis. `markets` = normalized market list (one or both venues). `orderbooks` = normalized YES-side orderbooks. `matches` = cross-venue matching only, no orderbooks. `discover` = free category/counter overview of both venues. `canary` = free health self-test of every endpoint.",
            "default": "scan"
          },
          "venues": {
            "title": "Venues",
            "enum": [
              "both",
              "kalshi",
              "polymarket"
            ],
            "type": "string",
            "description": "Which venue(s) to load in `markets`, `orderbooks` and `discover` mode. `scan` and `matches` always use both.",
            "default": "both"
          },
          "maxMarketsPerVenue": {
            "title": "Max markets per venue",
            "minimum": 10,
            "maximum": 5000,
            "type": "integer",
            "description": "Cap on normalized markets loaded per venue (most liquid first). Larger = better matching coverage, longer runs.",
            "default": 800
          },
          "titleFilter": {
            "title": "Title filter",
            "type": "string",
            "description": "Case-insensitive substring filter on market/event titles, e.g. `fed`, `midterm`, `bitcoin`. Applied on both venues after loading."
          },
          "categoriesFilter": {
            "title": "Categories",
            "type": "array",
            "description": "Restrict to coarse categories: `politics`, `economics`, `crypto`, `sports`, `sci_tech`, `weather`, `culture`, `health`, `other`. Empty = all.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "minVolume24h": {
            "title": "Min 24h volume",
            "minimum": 0,
            "type": "integer",
            "description": "Drop markets with 24h volume below this (venue-native units: Kalshi contracts, Polymarket USD). 0 = no filter.",
            "default": 0
          },
          "minLiquidity": {
            "title": "Min liquidity (USD)",
            "minimum": 0,
            "type": "integer",
            "description": "Drop markets with reported liquidity below this. 0 = no filter.",
            "default": 0
          },
          "closeDateWindowDays": {
            "title": "Close-date window (days)",
            "minimum": 1,
            "maximum": 30,
            "type": "integer",
            "description": "Stage-1 blocking: only pair markets whose close times are within ± this many days. Markets with a missing close date pass with a note.",
            "default": 1
          },
          "minMatchScore": {
            "title": "Min token score",
            "minimum": 0,
            "maximum": 1,
            "type": "number",
            "description": "Stage-2 threshold (0..1): minimum IDF-weighted token overlap for a pair to reach verification.",
            "default": 0.2
          },
          "minConfidence": {
            "title": "Min match confidence",
            "minimum": 0,
            "maximum": 1,
            "type": "number",
            "description": "Stage-3 threshold (0..1): minimum verified confidence for a pair to count (and be charged) as a match.",
            "default": 0.65
          },
          "orderSizesUsd": {
            "title": "Order sizes (USD)",
            "type": "array",
            "description": "Target order sizes for the executable-spread simulation (level-walking against real orderbook depth). Default [100, 1000] produces `executable_spread_100` and `executable_spread_1000`.",
            "default": [
              100,
              1000
            ]
          },
          "spreadSignalThreshold": {
            "title": "Spread signal threshold ($/share)",
            "minimum": 0,
            "maximum": 1,
            "type": "number",
            "description": "A pair counts (and is charged) as `executable-spread-signal` only when the net executable spread per share at some order size reaches this value. `0.01` = 1 cent/share.",
            "default": 0.01
          },
          "maxPairsToScan": {
            "title": "Max orderbook pairs (scan)",
            "minimum": 1,
            "maximum": 200,
            "type": "integer",
            "description": "Cap on verified matches whose orderbook pairs are fetched and analyzed in `scan` mode.",
            "default": 40
          },
          "maxOrderbooks": {
            "title": "Max orderbooks (orderbooks mode)",
            "minimum": 1,
            "maximum": 500,
            "type": "integer",
            "description": "Cap on orderbooks fetched in `orderbooks` mode.",
            "default": 50
          },
          "includeCandidates": {
            "title": "Include near-miss candidates",
            "type": "boolean",
            "description": "Also push up to 20 below-threshold candidate pairs with their scores and diff notes (free, not charged) — useful to tune thresholds.",
            "default": false
          },
          "useMatchCache": {
            "title": "Use persistent match cache",
            "type": "boolean",
            "description": "Cache verification results in the named key-value store `match-cache`. Repeat runs skip re-verification (faster, and no repeated LLM cost).",
            "default": true
          },
          "cacheTtlHours": {
            "title": "Match cache TTL (hours)",
            "minimum": 1,
            "maximum": 2160,
            "type": "integer",
            "description": "Cached verifications older than this are re-verified.",
            "default": 168
          },
          "llmApiKey": {
            "title": "LLM API key (optional)",
            "type": "string",
            "description": "Optional OpenRouter-compatible API key. When set, stage-3 verification of top candidates is done by an LLM (resolution-rule comparison); otherwise verification is purely rule-based and records carry `llm_verified: false`."
          },
          "llmModel": {
            "title": "LLM model",
            "type": "string",
            "description": "Model id for the OpenRouter-compatible endpoint.",
            "default": "openai/gpt-4o-mini"
          },
          "llmBaseUrl": {
            "title": "LLM base URL",
            "type": "string",
            "description": "OpenAI-compatible chat-completions base URL.",
            "default": "https://openrouter.ai/api/v1"
          },
          "maxLlmCalls": {
            "title": "Max LLM calls per run",
            "minimum": 1,
            "maximum": 500,
            "type": "integer",
            "description": "Cost cap for LLM verification. Candidates beyond this fall back to rule-based confidence.",
            "default": 40
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}