{
  "openapi": "3.0.1",
  "info": {
    "title": "US Restaurant Inspection & Food Establishment Scraper",
    "description": "Scrape US restaurant & food-establishment leads with official health-inspection data from 5 city portals (NYC, Chicago, Seattle, Austin, SF): name, address, phone, cuisine, latest grade/score, violations, risk, closures, new-opening signals + lead score & monitoring. No browser.",
    "version": "0.1",
    "x-build-id": "VJcGxrbQh5FILSIdp"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/scrapesage~us-restaurant-inspection-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-scrapesage-us-restaurant-inspection-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/scrapesage~us-restaurant-inspection-scraper/runs": {
      "post": {
        "operationId": "runs-sync-scrapesage-us-restaurant-inspection-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/scrapesage~us-restaurant-inspection-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-scrapesage-us-restaurant-inspection-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",
        "properties": {
          "sources": {
            "title": "Cities / data sources",
            "type": "array",
            "description": "Which official city / county health-department open-data portals to query. <b>nyc</b> = New York City (DOHMH — phone, cuisine, A/B/C letter grade). <b>chicago</b> = Chicago (facility type, risk level, full violation text). <b>king-wa</b> = Seattle / King County, WA (phone, score, grade, closures). <b>austin</b> = Austin / Travis County, TX (inspection score). <b>sf</b> = San Francisco (phone, score — note: SF's dataset updates less frequently than the others). Leave empty for all.",
            "items": {
              "type": "string",
              "enum": [
                "nyc",
                "chicago",
                "king-wa",
                "austin",
                "sf"
              ],
              "enumTitles": [
                "New York City (DOHMH)",
                "Chicago, IL",
                "Seattle / King County, WA",
                "Austin / Travis County, TX",
                "San Francisco, CA"
              ]
            },
            "default": [
              "nyc",
              "chicago",
              "king-wa",
              "austin",
              "sf"
            ]
          },
          "nameQuery": {
            "title": "Business name contains",
            "type": "string",
            "description": "Only return establishments whose name contains this text (case-insensitive), e.g. <code>Pizza</code>, <code>Starbucks</code>, or <code>Taqueria</code>."
          },
          "categoryQuery": {
            "title": "Cuisine / facility type contains",
            "type": "string",
            "description": "Filter by cuisine or facility type (case-insensitive contains). NYC uses cuisine (<code>Italian</code>, <code>Mexican</code>, <code>Bakery</code>, <code>Coffee/Tea</code>); Chicago & Seattle use facility type (<code>Restaurant</code>, <code>Grocery Store</code>, <code>Bakery</code>, <code>Mobile Food</code>, <code>School</code>)."
          },
          "cities": {
            "title": "Cities / boroughs",
            "type": "array",
            "description": "Filter by the establishment's city / borough (case-insensitive exact match). Useful inside multi-city sources — e.g. <code>Manhattan</code>/<code>Brooklyn</code> (NYC), <code>Bellevue</code>/<code>Redmond</code>/<code>Kent</code> (King County), <code>Evanston</code> (Cook County). Single-city sources ignore this.",
            "items": {
              "type": "string"
            }
          },
          "zipCodes": {
            "title": "ZIP codes (prefix)",
            "type": "array",
            "description": "Filter by ZIP — full ZIP (<code>10001</code>) or a prefix (<code>100</code> matches all 100xx).",
            "items": {
              "type": "string"
            }
          },
          "categoryFilters": {
            "title": "Compliance & inspection filters",
            "type": "string",
            "description": "The filters below target establishments by their latest health inspection."
          },
          "grades": {
            "title": "Letter grades (advanced)",
            "type": "array",
            "description": "Filter by the source's own letter grade. Applies to NYC (<code>A</code>, <code>B</code>, <code>C</code>, <code>P</code>=grade pending, <code>N</code>=not yet graded) and Seattle/King County (<code>1</code>=excellent … <code>4</code>=needs improvement). For a portable filter across all sources use <b>Compliance tiers</b> instead.",
            "items": {
              "type": "string"
            }
          },
          "complianceTiers": {
            "title": "Compliance tiers",
            "type": "array",
            "description": "Unified hygiene tier derived from each source's latest grade / score / result. <b>good</b> = passing / Grade A. <b>needs_improvement</b> = conditional / Grade B. <b>poor</b> = failing / Grade C. <b>closed</b> = shut by the health department / out of business. <b>unknown</b> = no grade posted yet. Great for targeting clean operators (good) or compliance / pest-control / remediation prospects (needs_improvement, poor).",
            "items": {
              "type": "string",
              "enum": [
                "good",
                "needs_improvement",
                "poor",
                "closed",
                "unknown"
              ],
              "enumTitles": [
                "Good (Pass / Grade A)",
                "Needs improvement (Conditional / Grade B)",
                "Poor (Fail / Grade C)",
                "Closed by health dept.",
                "Unknown (no grade yet)"
              ]
            }
          },
          "hasCriticalViolationsOnly": {
            "title": "Critical violations only",
            "type": "boolean",
            "description": "Only establishments whose latest inspection has at least one critical / priority / high-risk violation. High-intent for pest control, food-safety consulting, remediation and compliance software.",
            "default": false
          },
          "highRiskOnly": {
            "title": "High-risk establishments only",
            "type": "boolean",
            "description": "Only establishments classified high-risk by the health department (Chicago Risk 1, Seattle Risk Category III–IV, SF high-risk). High-risk = high-volume food prep = bigger buyers.",
            "default": false
          },
          "excludeClosed": {
            "title": "Exclude closed / out-of-business",
            "type": "boolean",
            "description": "Drop establishments whose latest inspection shows they were closed by the health department or marked out of business. Recommended for active-lead lists.",
            "default": false
          },
          "closedOnly": {
            "title": "Closed establishments only",
            "type": "boolean",
            "description": "Only establishments shut by the health department / out of business (turnover & distressed-asset intelligence). Overrides 'exclude closed'.",
            "default": false
          },
          "newlyOpenedOnly": {
            "title": "Newly opened only (GTM intent)",
            "type": "boolean",
            "description": "Only establishments whose FIRST inspection on record is recent (a new opening). Brand-new restaurants are the highest-intent buyers — they need POS, suppliers, insurance, payroll, delivery, marketing & more. Uses the accurate first-inspection date from each portal.",
            "default": false
          },
          "newOpeningDays": {
            "title": "New-opening window (days)",
            "minimum": 1,
            "type": "integer",
            "description": "How recent the first inspection must be to count as 'newly opened'. Default 365 (opened within the last year).",
            "default": 365
          },
          "withPhoneOnly": {
            "title": "With phone number only",
            "type": "boolean",
            "description": "Only establishments that have a phone number (available from NYC, Seattle/King County and San Francisco). Best for tele-prospecting lists.",
            "default": false
          },
          "inspectionDateFrom": {
            "title": "Inspected on/after",
            "type": "string",
            "description": "Only include inspections on/after this date (YYYY-MM-DD)."
          },
          "inspectionDateTo": {
            "title": "Inspected on/before",
            "type": "string",
            "description": "Only include inspections on/before this date (YYYY-MM-DD)."
          },
          "includeInspectionHistory": {
            "title": "Include inspection history",
            "type": "boolean",
            "description": "Attach a per-establishment inspection history (dates, results, grades, violation counts) and resolve the accurate first-inspection date & total inspection count from the portal. Turn off for a slightly faster, latest-inspection-only run.",
            "default": true
          },
          "maxResults": {
            "title": "Max results",
            "minimum": 1,
            "type": "integer",
            "description": "Maximum number of establishment records to return in this run (across all selected sources).",
            "default": 1000
          },
          "maxResultsPerSource": {
            "title": "Max results per source (optional)",
            "minimum": 1,
            "type": "integer",
            "description": "Cap how many establishments are taken from each source before the global limit and sorting. Leave blank to use the same value as Max results."
          },
          "sortBy": {
            "title": "Sort by",
            "enum": [
              "recentInspection",
              "newlyOpened",
              "leadScore",
              "worstCompliance",
              "none"
            ],
            "type": "string",
            "description": "Order of the returned records. <b>recentInspection</b> = most recently inspected first (freshest). <b>newlyOpened</b> = newest openings first (best GTM-intent leads). <b>leadScore</b> = best leads first. <b>worstCompliance</b> = closures & failing grades first (compliance/turnover targeting). <b>none</b> = natural order (fastest).",
            "default": "recentInspection"
          },
          "deduplicateResults": {
            "title": "Deduplicate within a run",
            "type": "boolean",
            "description": "Skip duplicate establishment records within this run (recommended).",
            "default": true
          },
          "monitorMode": {
            "title": "Monitoring mode — only new records",
            "type": "boolean",
            "description": "Remember which establishments were already returned (in a named key-value store) and emit ONLY records that are new since the last run — each tagged <code>monitorEvent: \"new\"</code>. A new inspection, a grade change or a brand-new establishment also surfaces as new. Run on a Schedule to capture new openings, grade changes and closures as fresh leads. Works alongside Apify Schedules (the schedule starts the run; monitoring decides what's new).",
            "default": false
          },
          "monitorKey": {
            "title": "Monitor key",
            "type": "string",
            "description": "Names the memory used by monitoring mode. Use a distinct key per saved watch (e.g. per city or filter) so different monitors don't share state.",
            "default": "default"
          },
          "socrataAppToken": {
            "title": "Socrata app token (optional)",
            "type": "string",
            "description": "Optional Socrata app token for higher rate limits on very large runs. Not required — leave blank for normal use. Get one free at any of the open-data portals (e.g. data.cityofnewyork.us)."
          },
          "proxyConfiguration": {
            "title": "Proxy configuration",
            "type": "object",
            "description": "Optional proxy. The government open-data portals are fetched directly and need no proxy — leave this off for the fastest runs. Enable Apify Proxy only if your network requires it.",
            "default": {
              "useApifyProxy": 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
                  }
                }
              },
              "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}