{
  "openapi": "3.0.1",
  "info": {
    "title": "UK Petition Threshold ETA & Velocity Tracker",
    "description": "Tracks open UK Parliament e-petitions and predicts, from signature velocity since the previous run, how many hours until each one crosses the 10,000-signature government-response line or the 100,000 debate line. Also flags the top signing constituencies and their MP.",
    "version": "0.1",
    "x-build-id": "BcGf5wWrbhyaDNzMx"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/hllerdgn80~uk-petition-threshold-tracker/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-hllerdgn80-uk-petition-threshold-tracker",
        "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/hllerdgn80~uk-petition-threshold-tracker/runs": {
      "post": {
        "operationId": "runs-sync-hllerdgn80-uk-petition-threshold-tracker",
        "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/hllerdgn80~uk-petition-threshold-tracker/run-sync": {
      "post": {
        "operationId": "run-sync-hllerdgn80-uk-petition-threshold-tracker",
        "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": {
          "state": {
            "title": "Petition state",
            "enum": [
              "open",
              "closed",
              "all"
            ],
            "type": "string",
            "description": "Which petitions to pull from the official UK Parliament Petitions site: 'open' (still collecting signatures), 'closed', or 'all'. 'open' is what almost every use of this Actor wants.",
            "default": "open"
          },
          "searchQuery": {
            "title": "Search text",
            "type": "string",
            "description": "Optional: only fetch petitions whose title/action text matches this search (same 'q' search box as petition.parliament.uk). Leave blank to scan every petition in the chosen state."
          },
          "watchPetitionIds": {
            "title": "Always-include petition IDs",
            "type": "array",
            "description": "Optional: specific petition IDs (the number in a petition's URL, e.g. 762640 for petition.parliament.uk/petitions/762640) to always fetch and score, even if they would otherwise be filtered out or fall outside the first pages scanned.",
            "default": []
          },
          "maxPetitionsToScan": {
            "title": "Max petitions to list-scan",
            "minimum": 25,
            "maximum": 2000,
            "type": "integer",
            "description": "How many petitions (newest/most-recently-updated first, 25 per page of the official listing) to pull from the summary listing before filtering by signature count. Raise this to cover more of a long tail; each one costs one extra lightweight listing request, not a charged event.",
            "default": 150
          },
          "minSignatureCount": {
            "title": "Minimum signature count",
            "minimum": 0,
            "type": "integer",
            "description": "Skip petitions with fewer signatures than this. Use it to cut noise from petitions that will never realistically approach 10,000.",
            "default": 500
          },
          "maxPetitionsToScore": {
            "title": "Max petitions to score in detail",
            "minimum": 1,
            "maximum": 500,
            "type": "integer",
            "description": "After the listing and minimum-signature filter, this caps how many petitions get a full detail fetch (constituency/region breakdown + velocity + ETA). Each scored petition is one dataset row and one charged event, so this is the main cost control.",
            "default": 40
          },
          "onlyApproachingOrJustCrossedThreshold": {
            "title": "Only approaching or just-crossed a threshold",
            "type": "boolean",
            "description": "If enabled, drop petitions that are neither within the 'ETA alert window' of their next threshold (10,000 government-response signatures, or 100,000 debate signatures) nor crossed one since the previous run. Use this for a lean day-to-day alert feed; leave off to see every scored petition's full status.",
            "default": false
          },
          "etaAlertWindowHours": {
            "title": "ETA alert window (hours)",
            "minimum": 1,
            "maximum": 336,
            "type": "integer",
            "description": "A petition counts as 'approaching' its next threshold when its predicted ETA (based on signature velocity since the previous run) is less than this many hours away. Only used when 'Only approaching or just-crossed a threshold' is on, or to set the 'approaching_threshold' flag.",
            "default": 24
          },
          "topConstituenciesCount": {
            "title": "Top constituencies per petition",
            "minimum": 0,
            "maximum": 50,
            "type": "integer",
            "description": "How many of the highest-signing parliamentary constituencies (with their sitting MP's name, from the petition's own official constituency breakdown) to include per scored petition.",
            "default": 5
          }
        }
      },
      "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
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "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
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}