{
  "openapi": "3.0.1",
  "info": {
    "title": "UK Food Hygiene Rating Downgrade Watchdog",
    "description": "Tracks UK Food Standards Agency hygiene ratings run over run and flags actual changes: rating downgrades, upgrades, and overdue re-inspections. Keyless official FSA API - no other Store Actor compares ratings across time.",
    "version": "0.1",
    "x-build-id": "5dYTDpmXGEMtoYPrb"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/hllerdgn80~uk-food-hygiene-rating-watchdog/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-hllerdgn80-uk-food-hygiene-rating-watchdog",
        "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-food-hygiene-rating-watchdog/runs": {
      "post": {
        "operationId": "runs-sync-hllerdgn80-uk-food-hygiene-rating-watchdog",
        "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-food-hygiene-rating-watchdog/run-sync": {
      "post": {
        "operationId": "run-sync-hllerdgn80-uk-food-hygiene-rating-watchdog",
        "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": {
          "localAuthorities": {
            "title": "Local authorities to watch",
            "type": "array",
            "description": "Council/local-authority names to check, e.g. \"Manchester\" or \"Westminster\". Every food business currently registered with that authority is checked each run. Matched against the FSA's own authority list (exact match first, then contains).",
            "default": [
              "Westminster"
            ],
            "items": {
              "type": "string"
            }
          },
          "addressesOrPostcodes": {
            "title": "Addresses or postcodes to watch",
            "type": "array",
            "description": "Free-text addresses or postcodes to search, e.g. \"SW1A 1AA\" or \"Camden High Street\". Uses the FSA API's own address search, same as the public ratings.food.gov.uk site.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "watchFhrsids": {
            "title": "Specific establishments to watch (FHRSID)",
            "type": "array",
            "description": "Exact FSA establishment IDs (FHRSID, visible in a ratings.food.gov.uk business URL) to track individually run after run, regardless of area, e.g. for a specific restaurant or franchise site.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "maxResultsPerArea": {
            "title": "Max establishments per local authority/address area",
            "minimum": 1,
            "maximum": 2000,
            "type": "integer",
            "description": "Upper limit on how many establishments to pull back for each local-authority or address search area, to keep large council areas (some cover 2,000+ businesses) from ballooning a single run.",
            "default": 200
          },
          "overdueMonths": {
            "title": "Overdue re-inspection threshold (months)",
            "minimum": 3,
            "maximum": 60,
            "type": "integer",
            "description": "An establishment that is not already top-rated (FHRS 5, or FHIS 'Pass') and has had no new inspection in at least this many months is flagged as 'overdue_for_reinspection' - the group most worth a fresh check, and a status no other FSA-data scraper surfaces.",
            "default": 18
          },
          "onlyAlerts": {
            "title": "Only return real alerts (downgrades + overdue)",
            "type": "boolean",
            "description": "If enabled, only push 'downgrade' and 'overdue_for_reinspection' rows - the two event types someone monitoring food safety actually needs to act on. Overrides 'Only return changed records' when both are set.",
            "default": false
          },
          "onlyChangedRecords": {
            "title": "Only return changed records",
            "type": "boolean",
            "description": "If enabled, skip establishments whose rating and inspection date have not changed since this Actor's last run against the same area. Leave off for a full snapshot on the first run (nothing has 'changed' yet, so everything is new_establishment).",
            "default": false
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}