{
  "openapi": "3.0.1",
  "info": {
    "title": "Restaurant Health Inspection Intelligence",
    "description": "Find failed inspections, repeated violations, closures, and compliance trends from official public records (NYC, Chicago). Returns normalized records plus derived intelligence: risk score, repeat-offender flags, and likely service needs.",
    "version": "1.0",
    "x-build-id": "xcWZZabN6n7qwwes0"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/c0rrupt3d~restaurant-health-inspection-intelligence/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-c0rrupt3d-restaurant-health-inspection-intelligence",
        "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/c0rrupt3d~restaurant-health-inspection-intelligence/runs": {
      "post": {
        "operationId": "runs-sync-c0rrupt3d-restaurant-health-inspection-intelligence",
        "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/c0rrupt3d~restaurant-health-inspection-intelligence/run-sync": {
      "post": {
        "operationId": "run-sync-c0rrupt3d-restaurant-health-inspection-intelligence",
        "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": [
          "jurisdiction"
        ],
        "properties": {
          "jurisdiction": {
            "title": "Jurisdiction",
            "enum": [
              "nyc",
              "chicago"
            ],
            "type": "string",
            "description": "Public open-data source to query. v1 fully supports 'nyc' (DOHMH Restaurant Inspection Results, updated daily). 'chicago' is supported as an expansion target.",
            "default": "nyc"
          },
          "restaurantName": {
            "title": "Restaurant name (contains)",
            "type": "string",
            "description": "Case-insensitive substring match on the business name (DBA). Leave empty to match all.",
            "default": ""
          },
          "zipCode": {
            "title": "ZIP code",
            "type": "string",
            "description": "Filter to a single ZIP/postal code. Leave empty to match all.",
            "default": ""
          },
          "dateFrom": {
            "title": "Inspection date from",
            "type": "string",
            "description": "Include inspections on or after this date (YYYY-MM-DD). Leave empty for no lower bound.",
            "default": ""
          },
          "dateTo": {
            "title": "Inspection date to",
            "type": "string",
            "description": "Include inspections on or before this date (YYYY-MM-DD). Leave empty for no upper bound.",
            "default": ""
          },
          "inspectionResults": {
            "title": "Inspection results",
            "type": "array",
            "description": "Normalized result categories to keep. Leave empty to include all. Controlled vocabulary: pass, fail, conditional, closed, pending, not_scored, unknown.",
            "items": {
              "type": "string",
              "enum": [
                "pass",
                "fail",
                "conditional",
                "closed",
                "pending",
                "not_scored",
                "unknown"
              ],
              "enumTitles": [
                "Pass",
                "Fail",
                "Conditional",
                "Closed",
                "Pending",
                "Not scored",
                "Unknown"
              ]
            },
            "default": []
          },
          "minScore": {
            "title": "Minimum inspection score",
            "type": "number",
            "description": "Keep inspections with score >= this value (NYC: higher score = more violations). Leave empty for no minimum.",
            "default": 0
          },
          "maxScore": {
            "title": "Maximum inspection score",
            "type": "number",
            "description": "Keep inspections with score <= this value. Leave empty (0) for no maximum.",
            "default": 0
          },
          "violationCategories": {
            "title": "Violation categories",
            "type": "array",
            "description": "Keep inspections containing at least one violation in these categories. Leave empty to include all. Categories: food_temp, food_protection, pest_control, sanitation, plumbing_water, equipment, hygiene, structural, signage, other.",
            "items": {
              "type": "string",
              "enum": [
                "food_temp",
                "food_protection",
                "pest_control",
                "sanitation",
                "plumbing_water",
                "equipment",
                "hygiene",
                "structural",
                "signage",
                "other"
              ],
              "enumTitles": [
                "Food temperature",
                "Food protection/handling",
                "Pest control",
                "Sanitation/cleaning",
                "Plumbing/water",
                "Equipment",
                "Employee hygiene",
                "Structural/facility",
                "Signage/permit",
                "Other"
              ]
            },
            "default": []
          },
          "criticalViolationsOnly": {
            "title": "Critical violations only",
            "type": "boolean",
            "description": "Keep only inspections that contain at least one critical violation.",
            "default": false
          },
          "closureOnly": {
            "title": "Closures only",
            "type": "boolean",
            "description": "Keep only inspections where the establishment was closed (DOHMH action).",
            "default": false
          },
          "reinspectionOpportunityOnly": {
            "title": "Reinspection opportunities only",
            "type": "boolean",
            "description": "Keep only inspections that represent a reinspection opportunity (failed/conditional with no later passing inspection in the returned set).",
            "default": false
          },
          "maxResults": {
            "title": "Maximum number of results",
            "type": "integer",
            "description": "Cap on the number of inspection records (post-aggregation, one row per inspection) returned to the dataset. 0 = unlimited (capped at 100,000 for safety).",
            "default": 1000
          },
          "sortOrder": {
            "title": "Sort order",
            "enum": [
              "date_desc",
              "date_asc",
              "score_desc",
              "risk_desc"
            ],
            "type": "string",
            "description": "Order of output records.",
            "default": "date_desc"
          },
          "includeViolationDetails": {
            "title": "Include violation details",
            "type": "boolean",
            "description": "Populate the nested 'violations' array with per-violation code/description/category/severity. Disable for a lighter output.",
            "default": true
          },
          "includeHistoricalInspections": {
            "title": "Aggregate historical inspections per business",
            "type": "boolean",
            "description": "Enrich each business with its inspection history within the returned set to compute repeat_offender, declining_performance, and inspection counts. Recommended.",
            "default": true
          },
          "keyword": {
            "title": "Keyword (violation text contains)",
            "type": "string",
            "description": "Case-insensitive substring match on violation description text (e.g. 'rodent', 'cockroach', 'grease'). Leave empty to skip.",
            "default": ""
          },
          "socrataAppToken": {
            "title": "Socrata app token (optional)",
            "type": "string",
            "description": "Optional free Socrata app token to raise rate limits. The Actor runs without it. Register at https://dev.socrata.com/ if needed."
          },
          "requestDelayMs": {
            "title": "Request delay (ms)",
            "type": "integer",
            "description": "Polite delay between paginated Socrata requests.",
            "default": 150
          },
          "maxConsecutiveErrors": {
            "title": "Max consecutive request errors",
            "type": "integer",
            "description": "Abort after this many consecutive failed page requests.",
            "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
                  }
                }
              },
              "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}