{
  "openapi": "3.0.1",
  "info": {
    "title": "Maricopa County Restaurant Inspections API – Phoenix (AZ)",
    "description": "Restaurant inspection grades (A–D) & violation history for Phoenix & Maricopa County, AZ. For food-safety research, lead lists and local apps. Search by ZIP or business name.\nFree sample (100 rows, real output): https://drive.google.com/uc?export=download&id=1AqtJBgB-sHU_QXVQgd55BkgPYDRsmLQj",
    "version": "0.3",
    "x-build-id": "NN85g0PxzvyBczE1a"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/groundplanes~maricopa-restaurant-inspections/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-groundplanes-maricopa-restaurant-inspections",
        "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/groundplanes~maricopa-restaurant-inspections/runs": {
      "post": {
        "operationId": "runs-sync-groundplanes-maricopa-restaurant-inspections",
        "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/groundplanes~maricopa-restaurant-inspections/run-sync": {
      "post": {
        "operationId": "run-sync-groundplanes-maricopa-restaurant-inspections",
        "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": {
          "zipCodes": {
            "title": "ZIP codes",
            "type": "array",
            "description": "5-digit Maricopa County ZIP codes to search, e.g. 85281. Each ZIP is one search. Invalid ZIPs are ignored with a warning. Provide ZIP codes or business names (or both).",
            "items": {
              "type": "string"
            }
          },
          "businessNames": {
            "title": "Business names",
            "type": "array",
            "description": "Business name searches (partial match), e.g. 'taco'. Combine with City to narrow. The county site requires a ZIP, business name or street with every city search.",
            "items": {
              "type": "string"
            }
          },
          "city": {
            "title": "City (optional, with business names)",
            "type": "string",
            "description": "Upper-case city, e.g. TEMPE, PHOENIX, SCOTTSDALE. Applied to business-name searches."
          },
          "permitTypeContains": {
            "title": "Permit type contains",
            "type": "string",
            "description": "Keep permits whose type contains this text, e.g. 'Eating & Drinking'. Leave empty for all."
          },
          "includeInspections": {
            "title": "Include inspection history",
            "type": "boolean",
            "description": "Fetch each permit's inspection list (one extra request per permit). Required for grades and the onlyGrades filter.",
            "default": true
          },
          "maxInspectionsPerPermit": {
            "title": "Max inspections per permit",
            "minimum": 1,
            "maximum": 100,
            "type": "integer",
            "description": "Max inspections per permit.",
            "default": 10
          },
          "onlyGrades": {
            "title": "Only latest grades",
            "type": "array",
            "description": "Keep permits whose latest graded inspection has one of these grades (case-insensitive, exact). Values used by the county: A, B, C, D, Cutting Edge A+, R, Not Participating. Ungraded Advisory visits are skipped. Needs 'Include inspection history'. Example: C, D. Permits marked Not Participating are only kept if you list 'Not Participating' too. Limit: grades are only known after each permit page is read (about 1.5 s per permit), and C/D grades are rare, so on a big ZIP the default time budget may find only a few matches; raise maxScanSeconds and the run timeout, or search smaller ZIPs.",
            "items": {
              "type": "string"
            }
          },
          "maxPermits": {
            "title": "Max permits",
            "minimum": 1,
            "maximum": 10000,
            "type": "integer",
            "description": "Max permits.",
            "default": 100
          },
          "requestDelaySecs": {
            "title": "Delay between requests (seconds)",
            "minimum": 0.5,
            "maximum": 10,
            "type": "number",
            "description": "Politeness delay. Keep at 1s or more to be gentle with the county server.",
            "default": 1
          },
          "maxScanSeconds": {
            "title": "Max scan time (seconds)",
            "minimum": 30,
            "maximum": 3000,
            "type": "integer",
            "description": "Time budget in seconds for the whole run (default 180). It is enforced inside every request and retry, and is automatically capped at the run's own timeout minus 30 s, so the run always ends with a clear status instead of being killed. When it runs out, you get the rows found so far with a PARTIAL: status. Each permit page takes about 1.5 s, so 180 s checks roughly 100 permits. For onlyGrades on a big ZIP, raise this and the run timeout together (e.g. 1200 s and 1300 s).",
            "default": 180
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}