{
  "openapi": "3.0.1",
  "info": {
    "title": "Kalshi Market Data Scraper",
    "description": "Scrape settled Kalshi prediction markets with candlesticks & trades. Alert mode monitors active markets via Slack/Discord webhooks. Any category, resumable runs, auto-generated reports & CSV exports.",
    "version": "0.1",
    "x-build-id": "m1pVFmEOTnrX12yzG"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/jy-labs~kalshi-market-data-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-jy-labs-kalshi-market-data-scraper",
        "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/jy-labs~kalshi-market-data-scraper/runs": {
      "post": {
        "operationId": "runs-sync-jy-labs-kalshi-market-data-scraper",
        "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/jy-labs~kalshi-market-data-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-jy-labs-kalshi-market-data-scraper",
        "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",
        "required": [
          "category",
          "lookbackDays",
          "candlestickPeriodInterval"
        ],
        "properties": {
          "category": {
            "title": "Category",
            "type": "string",
            "description": "Kalshi market category to collect. Any valid Kalshi category string.",
            "default": "Economics"
          },
          "lookbackDays": {
            "title": "Lookback days",
            "minimum": 1,
            "type": "integer",
            "description": "Maximum lookback window for settled markets.",
            "default": 365
          },
          "seriesAllowlist": {
            "title": "Series allowlist",
            "type": "array",
            "description": "Optional explicit series tickers. When empty, all series in the category are collected.",
            "items": {
              "type": "string"
            }
          },
          "candlestickPeriodInterval": {
            "title": "Candlestick period interval",
            "type": "integer",
            "description": "Kalshi period interval in minutes (1, 60, or 1440). May be auto-degraded for large runs.",
            "default": 60
          },
          "maxMarkets": {
            "title": "Max markets",
            "minimum": 1,
            "type": "integer",
            "description": "Optional ceiling on total market rows to emit."
          },
          "excludeMultivariate": {
            "title": "Exclude multivariate events",
            "type": "boolean",
            "description": "Skip mutually exclusive multivariate events.",
            "default": true
          },
          "requestRateLimitRps": {
            "title": "Request rate limit",
            "minimum": 1,
            "maximum": 10,
            "type": "number",
            "description": "Global Kalshi request cap (requests per second). Max 10.",
            "default": 8
          },
          "candlestickConcurrency": {
            "title": "Candlestick concurrency",
            "minimum": 1,
            "maximum": 5,
            "type": "integer",
            "description": "Concurrent candlestick fetches. Max 5.",
            "default": 2
          },
          "includeTrades": {
            "title": "Include trades",
            "type": "boolean",
            "description": "Fetch trade-level data for each market alongside candlesticks.",
            "default": false
          },
          "skipFailedMarkets": {
            "title": "Skip failed markets",
            "type": "boolean",
            "description": "When true, enrichment failures are logged and skipped instead of aborting the run.",
            "default": true
          },
          "logLevel": {
            "title": "Log level",
            "enum": [
              "debug",
              "info",
              "warn",
              "error"
            ],
            "type": "string",
            "description": "Minimum log level for structured JSON output.",
            "default": "info"
          },
          "degradationThresholds": {
            "title": "Degradation thresholds",
            "type": "object",
            "description": "Candlestick interval auto-degradation thresholds based on estimated market count.",
            "properties": {
              "minuteToHourly": {
                "title": "Minute to hourly threshold",
                "type": "integer",
                "description": "Degrade 1-min candles to 60-min when estimated market count exceeds this.",
                "default": 25,
                "minimum": 1
              },
              "hourlyToDaily": {
                "title": "Hourly to daily threshold",
                "type": "integer",
                "description": "Degrade 60-min candles to daily when estimated market count exceeds this.",
                "default": 400,
                "minimum": 1
              }
            }
          },
          "mode": {
            "title": "Mode",
            "enum": [
              "collect",
              "alert"
            ],
            "type": "string",
            "description": "Operating mode. 'collect' gathers settled market data. 'alert' monitors active markets and sends webhook notifications.",
            "default": "collect"
          },
          "generateReport": {
            "title": "Generate report",
            "type": "boolean",
            "description": "Generate HTML and Markdown settlement analysis reports after collection.",
            "default": false
          },
          "exportCsv": {
            "title": "Export CSV",
            "type": "boolean",
            "description": "Export collected data as a CSV file in the key-value store.",
            "default": false
          },
          "webhookUrl": {
            "title": "Webhook URL",
            "type": "string",
            "description": "Slack or Discord webhook URL for alert notifications. Required when mode is 'alert'."
          },
          "alertConditions": {
            "title": "Alert conditions",
            "type": "array",
            "description": "Price conditions to monitor in alert mode. Each condition specifies a ticker pattern, price field, comparison operator, and threshold.",
            "items": {
              "type": "object",
              "properties": {
                "tickerPattern": {
                  "title": "Ticker pattern",
                  "type": "string",
                  "description": "Market ticker pattern. Use * for wildcard (e.g. 'KXCPI*' matches all CPI markets)."
                },
                "field": {
                  "title": "Price field",
                  "type": "string",
                  "description": "Which price field to monitor: lastPrice, yesAsk, or yesBid.",
                  "enum": [
                    "lastPrice",
                    "yesAsk",
                    "yesBid"
                  ]
                },
                "operator": {
                  "title": "Operator",
                  "type": "string",
                  "description": "Comparison operator: above or below the threshold.",
                  "enum": [
                    "above",
                    "below"
                  ]
                },
                "thresholdDollars": {
                  "title": "Threshold",
                  "type": "string",
                  "description": "Dollar threshold value (e.g. '0.75')."
                }
              },
              "required": [
                "tickerPattern",
                "field",
                "operator",
                "thresholdDollars"
              ]
            }
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}