{
  "openapi": "3.0.1",
  "info": {
    "title": "SF Restaurant Inspection Scraper",
    "description": "Scrape the official SF Dept. of Public Health restaurant/food-facility inspection dataset. Filter by neighborhood, district, rating status, permit/inspection type, violations, or date; lookup by permit number. Free Socrata API, no login.",
    "version": "1.0",
    "x-build-id": "uCh2bNH6ScDWu8Zcv"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/crawlerbros~sf-restaurant-inspection-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-crawlerbros-sf-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/crawlerbros~sf-restaurant-inspection-scraper/runs": {
      "post": {
        "operationId": "runs-sync-crawlerbros-sf-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/crawlerbros~sf-restaurant-inspection-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-crawlerbros-sf-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",
        "required": [
          "mode"
        ],
        "properties": {
          "mode": {
            "title": "Mode",
            "enum": [
              "search",
              "byPermitNumber"
            ],
            "type": "string",
            "description": "What to fetch.",
            "default": "search"
          },
          "searchQuery": {
            "title": "Full-text search",
            "type": "string",
            "description": "Free-text search across facility name, address, and other text fields (mode=search). Leave blank to browse without a text query."
          },
          "dbaKeyword": {
            "title": "Facility name contains",
            "type": "string",
            "description": "Case-insensitive substring match on the facility's DBA (\"doing business as\") name (mode=search). Example: `pizza`."
          },
          "permitNumbers": {
            "title": "Permit numbers (mode=byPermitNumber)",
            "type": "array",
            "description": "Facility permit numbers to fetch full inspection history for. Example: `93127`.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "analysisNeighborhood": {
            "title": "Neighborhood",
            "enum": [
              "",
              "Bayview Hunters Point",
              "Bernal Heights",
              "Castro/Upper Market",
              "Chinatown",
              "Excelsior",
              "Financial District/South Beach",
              "Glen Park",
              "Golden Gate Park",
              "Haight Ashbury",
              "Hayes Valley",
              "Inner Richmond",
              "Inner Sunset",
              "Japantown",
              "Lakeshore",
              "Lincoln Park",
              "Lone Mountain/USF",
              "Marina",
              "McLaren Park",
              "Mission",
              "Mission Bay",
              "Nob Hill",
              "Noe Valley",
              "North Beach",
              "Oceanview/Merced/Ingleside",
              "Outer Mission",
              "Outer Richmond",
              "Pacific Heights",
              "Portola",
              "Potrero Hill",
              "Presidio",
              "Presidio Heights",
              "Russian Hill",
              "Seacliff",
              "South of Market",
              "Sunset/Parkside",
              "Tenderloin",
              "Treasure Island",
              "Twin Peaks",
              "Visitacion Valley",
              "Western Addition",
              "West of Twin Peaks"
            ],
            "type": "string",
            "description": "Filter to a single SF analysis neighborhood.",
            "default": ""
          },
          "supervisorDistrict": {
            "title": "Supervisor district",
            "enum": [
              "",
              "1",
              "2",
              "3",
              "4",
              "5",
              "6",
              "7",
              "8",
              "9",
              "10",
              "11"
            ],
            "type": "string",
            "description": "Filter to a single SF Board of Supervisors district (1-11).",
            "default": ""
          },
          "facilityRatingStatus": {
            "title": "Facility rating status",
            "enum": [
              "",
              "Pass",
              "Conditional Pass",
              "Closure"
            ],
            "type": "string",
            "description": "Filter by the outcome/status assigned after the inspection.",
            "default": ""
          },
          "inspectionType": {
            "title": "Inspection type",
            "enum": [
              "",
              "Change of Ownership",
              "Complaint (I)",
              "Complaint (R)",
              "Consultation",
              "Foodborne Illness",
              "New Ownership (I)",
              "New Ownership (R)",
              "Plan Check",
              "Plan Check (I)",
              "Plan Check (R)",
              "Reinspection",
              "Routine",
              "Site Visit",
              "Structural"
            ],
            "type": "string",
            "description": "Filter by the type of inspection performed.",
            "default": ""
          },
          "inspectionFrequencyType": {
            "title": "Inspection frequency type",
            "enum": [
              "",
              "1",
              "2",
              "High Hazard",
              "N/A"
            ],
            "type": "string",
            "description": "Filter by the DPH inspection frequency code assigned to the facility.",
            "default": ""
          },
          "permitType": {
            "title": "Permit type",
            "enum": [
              "",
              "Child and Adult Care Food Program",
              "H03 - RETAIL MKTS W/O PREP (UNDER 5001)",
              "H03R - RETAIL MKTS W/O PREP (UNDER 5001)",
              "H04 - RETAIL MKTS W/O PREP (5001 - 10000)",
              "H04R - RETAIL MKTS W/O PREP (5001 - 10000)",
              "H05 - RETAIL MKTS W/O PREP (10001 - 20000)",
              "H05R - RETAIL MKTS W/O PREP (10001 - 20000)",
              "H06 - RETAIL MKTS W/O PREP (OVER 20000)",
              "H06R - RETAIL MKTS W/O PREP (OVER 20000)",
              "H07 - RETAIL MKTS W/FOOD PREP (UNDER 5001)",
              "H07R - RETAIL MKTS W/FOOD PREP (UNDER 5001)",
              "H08 - RETAIL MKTS W/FOOD PREP (10001 - 20000)",
              "H08R - RETAIL MKTS W/FOOD PREP (10001 - 20000)",
              "H09 - RETAIL MKTS W/FOOD PREP (5001 - 10000)",
              "H09R - RETAIL MKTS W/FOOD PREP (5001 - 10000)",
              "H101 - Community Event Food Vendor - Low Hazard",
              "H102 - Community Event Food Vendor - High Hazard",
              "H14 - CERTIFIED FARMERS MARKETS",
              "H15 - WHOLESALE FOOD MARKETS",
              "H15R - WHOLESALE FOOD MARKETS",
              "H18 - WHOLESALE FOOD MARKETS",
              "H21 - WHOLESALE FOOD MARKETS",
              "H21R - WHOLESALE FOOD MARKETS",
              "H22 - FOOD MANUFACTURING/PROCESSING",
              "H23 - FOOD PREP AND SERVICE (FEE EXEMPT)",
              "H23R- FOOD PREP AND SERVICE (FEE EXEMPT)",
              "H24 - RESTAURANT UNDER 1,000 SQFT",
              "H24R - RESTAURANT UNDER 1,000 SQFT",
              "H25 - RESTAURANT 1,000 - 2,000 SQFT",
              "H25R - RESTAURANT 1,000 - 2,000 SQFT",
              "H26 - RESTAURANT OVER 2,000 SQFT",
              "H26R - RESTAURANT OVER 2,000 SQFT",
              "H28 - TAKE-OUTS",
              "H28R - TAKE-OUTS",
              "H29 - FAST FOOD OUTLETS",
              "H29R - FAST FOOD OUTLETS",
              "H30 - CATERING FACILITIES",
              "H30R - CATERING FACILITIES",
              "H31 - TOBACCO SALES - ANNUAL LICENSE FEE",
              "H33 - COMMISSARIES",
              "H33R - COMMISSARIES",
              "H34 - PUSHCARTS (RETAIL FOOD VEHICLE)",
              "H36 - STADIUM CONCESSIONS (PERM)",
              "H36R - STADIUM CONCESSIONS (PERM)",
              "H37 - BED AND BREAKFAST",
              "H40 - HOSPITAL KITCHENS",
              "H42 - PET SHOP - OVERNIGHT",
              "H43 - PET HOSPITAL - OVERNIGHT",
              "H44 - DOG KENNEL - OVERNIGHT",
              "H46 - AUTOMATIC LAUNDRY - FACILITIES",
              "H48 - WASH LAUNDRIES",
              "H56 - SWIMMING POOLS (YEAR-ROUND)",
              "H61 - VENDING MACHINES - COMPANIES",
              "H61R - VENDING MACHINES - COMPANIES",
              "H67 - MASSAGE ESTABLISHMENT",
              "H68 - GENERAL MASSAGE PRACTITIONER",
              "H69 - OUTCALL MASSAGE SERVICE",
              "H70 - SOLO MASSAGE ESTABLISHMENT",
              "H74 - CATERER",
              "H74R - CATERER",
              "H75 - MOBILE FOOD FACILITY CLASS 1",
              "H76 - MOBILE FOOD FACILITY CLASS 2",
              "H77 - MOBILE FOOD FACILITY CLASS 3",
              "H78 - MOBILE FOOD FACILITY CLASS 4",
              "H79 - MOBILE FOOD FACILITY CLASS 5",
              "H79R - MOBILE FOOD FACILITY CLASS 5",
              "H80 - SUPERMARKETS W/2-3 FOOD PREP",
              "H81 - SUPERMARKETS W/4+ FOOD PREP",
              "H81R - SUPERMARKETS W/4+ FOOD PREP",
              "H83 - SUPERMARKETS GREATER THAN 20,000 SQFT W/1 FOOD PREP",
              "H84 - EMPLOYEE CAFETERIAS W/FOOD PREP",
              "H84R - EMPLOYEE CAFETERIAS W/FOOD PREP",
              "H85 - EMPLOYEE CAFETERIA LIMITED FOOD PREP",
              "H85R - EMPLOYEE CAFETERIA LIMITED FOOD PREP",
              "H86 - BARS/TAVERNS W/O FOOD PREP",
              "H86R - BARS/TAVERNS W/O FOOD PREP",
              "H87 - BARS/TAVERNS W/FOOD PREP",
              "H87R- BARS/TAVERNS W/FOOD PREP",
              "H88 - RETAIL BAKERIES WITH FOOD PREP",
              "H88R - RETAIL BAKERIES WITH FOOD PREP",
              "H89 - RETAIL BAKERIES W/O FOOD PREP",
              "H89R - RETAIL BAKERIES W/O FOOD PREP",
              "H90 - SCHOOL CAFETERIAS (PRIVATE W/O FOOD PREP)",
              "H91 - SCHOOL CAFETERIAS (PRIVATE W/FOOD PREP)",
              "H91R - SCHOOL CAFETERIAS (PRIVATE W/FOOD PREP)",
              "H98 - COTTAGE FOOD OPERATIONS - TIER A (DIRECT SALES)",
              "H98R - COTTAGE FOOD OPERATIONS - TIER A (DIRECT SALES)",
              "H99 - COTTAGE FOOD OPERATIONS - TIER B (INDIRECT SALES)",
              "H99R - COTTAGE FOOD OPERATIONS - TIER B (INDIRECT SALES)",
              "J01 - TATTOO & PIERCING FACILITIES",
              "J06 - SKILLED NURSING FACILITIES",
              "J07 - CATERING FACILITY – NO COOKING",
              "J07R - CATERING FACILITY - NO COOKING",
              "J08 - COMMISSARY FOR MFF SERVICING",
              "J09 - COOKING SCHOOL",
              "J10 - HOST FACILITY",
              "J10R - HOST FACILITY",
              "J11 - SHARED KITCHEN COMPLEX, LESS THAN 2,000 SQ. FT.",
              "J12 - SHARED KITCHEN COMPLEX, GREATER THAN 2,000 SQ. FT.",
              "J12R - SHARED KITCHEN COMPLEX, GREATER THAN 2,000 SQ. FT.",
              "Limited Service Charitable Feeding Operation",
              "PUBLIC SCHOOL CAFETERIA WITH FOOD PREP",
              "Senior Nutrition Center",
              "Snack/Supper",
              "Summer Meals"
            ],
            "type": "string",
            "description": "Filter to a single DPH permit/facility type.",
            "default": ""
          },
          "inspectionDateFrom": {
            "title": "Inspection date from (YYYY-MM-DD)",
            "type": "string",
            "description": "Drop inspections before this date."
          },
          "inspectionDateTo": {
            "title": "Inspection date to (YYYY-MM-DD)",
            "type": "string",
            "description": "Drop inspections after this date."
          },
          "minViolationCount": {
            "title": "Min violation count",
            "minimum": 0,
            "maximum": 50,
            "type": "integer",
            "description": "Drop inspections with fewer cited violations than this."
          },
          "maxViolationCount": {
            "title": "Max violation count",
            "minimum": 0,
            "maximum": 50,
            "type": "integer",
            "description": "Drop inspections with more cited violations than this."
          },
          "hasViolationsOnly": {
            "title": "Only inspections with violations",
            "type": "boolean",
            "description": "Only include inspections that had at least one cited violation.",
            "default": false
          },
          "nearLatitude": {
            "title": "Near latitude",
            "minimum": -90,
            "maximum": 90,
            "type": "number",
            "description": "Latitude of a point to search near (mode=search). Must be combined with `nearLongitude` — both are required together to activate the radius filter. Example: `37.7749` (SF Civic Center)."
          },
          "nearLongitude": {
            "title": "Near longitude",
            "minimum": -180,
            "maximum": 180,
            "type": "number",
            "description": "Longitude of a point to search near (mode=search). Must be combined with `nearLatitude`. Example: `-122.4194` (SF Civic Center)."
          },
          "nearRadiusMeters": {
            "title": "Near radius (meters)",
            "minimum": 1,
            "maximum": 50000,
            "type": "integer",
            "description": "Radius in meters around the `nearLatitude`/`nearLongitude` point. Only applied when both coordinates are set.",
            "default": 500
          },
          "sortBy": {
            "title": "Sort by",
            "enum": [
              "inspectionDateDesc",
              "inspectionDateAsc",
              "violationCountDesc",
              "violationCountAsc",
              "dbaAsc",
              "neighborhoodAsc",
              "supervisorDistrictAsc"
            ],
            "type": "string",
            "description": "Sort order for results.",
            "default": "inspectionDateDesc"
          },
          "appToken": {
            "title": "Socrata app token (optional)",
            "type": "string",
            "description": "Optional free Socrata app token to raise API rate limits. Get one at https://data.sfgov.org/profile/app_tokens. Not required — the actor works without it."
          },
          "maxItems": {
            "title": "Max items",
            "minimum": 1,
            "maximum": 10000,
            "type": "integer",
            "description": "Hard cap on emitted records.",
            "default": 50
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}