# Food Safety Inspection Scanner — Restaurant Health Inspections (`mibedk/food-inspection-scanner`) Actor

Extract restaurant food-safety and health-inspection records from public government open-data portals. Ships with NYC DOHMH (updated daily); works with any Socrata open-data city by configuration. Normalized JSON, filters for borough, cuisine, grade, critical violations, and recency.

- **URL**: https://apify.com/mibedk/food-inspection-scanner.md
- **Developed by:** [Mikkel Bech-Hansen](https://apify.com/mibedk) (community)
- **Categories:** Business, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.36 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js/docs.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python/docs.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Food Safety Inspection Scanner — Restaurant Health Inspections (NYC + Socrata Cities)

Extract restaurant food-safety and health-inspection records from public government open-data portals as clean, normalized JSON — ready for spreadsheets, dashboards, databases, and automation pipelines.

Ships preconfigured for the **NYC Department of Health (DOHMH) Restaurant Inspection Results** dataset, which is updated **daily** and contains every inspection and violation cited at New York City food-service establishments. The backend is generic Socrata — point it at **any Socrata open-data portal** (Chicago, Los Angeles, Boston, Austin, and 200+ other cities) by changing two input fields.

### What it does

- Queries the city's official open-data API (no scraping, no CAPTCHAs, no broken HTML parsers — the data comes straight from the government source)
- Filters by **borough**, **cuisine**, **ZIP code**, **inspection grade** (A/B/C), **critical violations only**, and **recency** (last N days)
- Normalizes every row into a stable record schema with deterministic IDs (safe for incremental syncs and deduplication)
- Handles throttling and transient errors with retry + exponential backoff
- Runs in seconds — a single API request per run, minimal compute cost

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `days_back` | integer | `30` | Only include inspections from the last N days |
| `max_items` | integer | `100` | Maximum records to return (cap: 5,000) |
| `boro` | select | `Any` | NYC borough filter |
| `cuisine` | string | — | Cuisine keyword, e.g. `Pizza`, `Chinese`, `Bakery` |
| `zipcode` | string | — | Exact ZIP code filter |
| `grade` | select | `Any` | Letter grade filter (A / B / C) |
| `critical_only` | boolean | `false` | Only critical violations |
| `socrata_domain` | string | `data.cityofnewyork.us` | Any Socrata open-data portal |
| `dataset_id` | string | `43nn-pn8j` | Socrata dataset ID |

### Output

One JSON record per inspection violation, e.g.:

```json
{
  "id": "NTAxODA0NTJ8MjAyNi0wNy",
  "source": "socrata:data.cityofnewyork.us/43nn-pn8j",
  "restaurant_id": "50180452",
  "restaurant_name": "ALL LIN COMING INC",
  "boro": "Staten Island",
  "address": "1022 ROSSVILLE AVENUE",
  "zipcode": "10309",
  "phone": "3472799411",
  "cuisine_description": "Chinese",
  "inspection_date": "2026-07-18",
  "inspection_type": "Cycle Inspection / Initial Inspection",
  "action": "Violations were cited in the following area(s).",
  "violation_code": "04L",
  "violation_description": "Evidence of mice or live mice present in facility...",
  "critical_flag": "Critical",
  "score": 17,
  "grade": "B",
  "grade_date": "2026-07-18",
  "record_date": "2026-07-21",
  "latitude": 40.552129043699,
  "longitude": -74.212092661776,
  "url": "https://data.cityofnewyork.us/resource/43nn-pn8j.json?camis=50180452"
}
````

Export as JSON, CSV, or Excel from the Apify dataset, or consume via API.

### Real-world examples

#### Example 1 — Weekly Manhattan pizza inspection roundup

A food-delivery platform wants to display health grades next to restaurant listings.

```json
{
  "boro": "Manhattan",
  "cuisine": "Pizza",
  "days_back": 7,
  "max_items": 500
}
```

#### Example 2 — Critical violations only, last 14 days

A compliance auditor needs to flag restaurants with serious hygiene issues for follow-up.

```json
{
  "critical_only": true,
  "days_back": 14,
  "max_items": 1000
}
```

#### Example 3 — Chicago food inspections

A market-research firm tracks inspection trends across multiple cities.

```json
{
  "socrata_domain": "data.cityofchicago.org",
  "dataset_id": "4ijn-s7e5",
  "days_back": 30,
  "max_items": 2000
}
```

### Use cases

- **Delivery platforms** — enrich restaurant listings with official health grades and violation histories
- **Restaurant chains & franchise auditors** — monitor your own locations for new violations and grade changes (schedule daily runs + webhooks)
- **Insurance underwriting** — food-safety risk signals for hospitality clients
- **Commercial real estate** — due-diligence on food-service tenants
- **Journalism & research** — track enforcement patterns by borough, cuisine, or ZIP code
- **Competitive intelligence** — monitor compliance trends across a market

### Other cities

Any city on a Socrata open-data portal works. Examples:

| City | `socrata_domain` | Example dataset |
|---|---|---|
| NYC (default) | `data.cityofnewyork.us` | `43nn-pn8j` (restaurant inspections) |
| Chicago | `data.cityofchicago.org` | `4ijn-s7e5` (food inspections) |
| Austin | `data.austintexas.gov` | `ecmv-9xxi` (food establishment inspections) |

Note: filter fields (`boro`, `grade`, `cuisine`, `zipcode`) are NYC-specific column names; for other datasets use `days_back` / `max_items` and check the dataset's column names. Date, limit, and ordering filters work everywhere.

### Scheduling & integrations

Run on a schedule (daily/weekly) directly in Apify, or trigger via API, Zapier, Make, or webhooks. Use deterministic record IDs for incremental syncs into your own database.

### Cost & reliability

- **Flat pricing:** $0.00036 per result + $0.001 run start fee — 1,000 records costs $0.36
- **Deterministic:** no headless browser, no LLM, no paid third-party APIs
- **Cheap:** one HTTP request per run, typically <10 seconds of compute
- **Data license:** public government open data, free to reuse
- **Source stability:** Socrata (Tyler Technologies) powers 200+ government portals; schemas are stable and changes are announced

# Actor input Schema

## `socrata_domain` (type: `string`):

Open-data portal domain (default: data.cityofnewyork.us for NYC). Change to any Socrata city portal, e.g. data.cityofchicago.org.

## `dataset_id` (type: `string`):

Socrata dataset identifier (default: 43nn-pn8j = NYC DOHMH Restaurant Inspection Results).

## `boro` (type: `string`):

Filter by NYC borough (Any = no filter). Ignored for non-NYC datasets.

## `cuisine` (type: `string`):

Case-insensitive keyword matched against the cuisine description, e.g. 'Pizza', 'Chinese', 'Bakery'. Empty = no filter.

## `zipcode` (type: `string`):

Filter by exact ZIP code. Empty = no filter.

## `grade` (type: `string`):

Filter by letter grade (Any = no filter). Only inspections that received a grade match.

## `critical_only` (type: `boolean`):

If true, return only violation rows flagged as Critical.

## `days_back` (type: `integer`):

Only include inspections from the last N days (default: 30).

## `max_items` (type: `integer`):

Maximum number of records to return (default: 100, hard cap: 5000).

## Actor input object example

```json
{
  "socrata_domain": "data.cityofnewyork.us",
  "dataset_id": "43nn-pn8j",
  "boro": "Any",
  "grade": "Any",
  "critical_only": false,
  "days_back": 30,
  "max_items": 100
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "socrata_domain": "data.cityofnewyork.us",
    "dataset_id": "43nn-pn8j"
};

// Run the Actor and wait for it to finish
const run = await client.actor("mibedk/food-inspection-scanner").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "socrata_domain": "data.cityofnewyork.us",
    "dataset_id": "43nn-pn8j",
}

# Run the Actor and wait for it to finish
run = client.actor("mibedk/food-inspection-scanner").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "socrata_domain": "data.cityofnewyork.us",
  "dataset_id": "43nn-pn8j"
}' |
apify call mibedk/food-inspection-scanner --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=mibedk/food-inspection-scanner",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Food Safety Inspection Scanner — Restaurant Health Inspections",
        "description": "Extract restaurant food-safety and health-inspection records from public government open-data portals. Ships with NYC DOHMH (updated daily); works with any Socrata open-data city by configuration. Normalized JSON, filters for borough, cuisine, grade, critical violations, and recency.",
        "version": "0.3",
        "x-build-id": "dq5nqrSQgea3RmEm8"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/mibedk~food-inspection-scanner/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-mibedk-food-inspection-scanner",
                "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/mibedk~food-inspection-scanner/runs": {
            "post": {
                "operationId": "runs-sync-mibedk-food-inspection-scanner",
                "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/mibedk~food-inspection-scanner/run-sync": {
            "post": {
                "operationId": "run-sync-mibedk-food-inspection-scanner",
                "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": {
                    "socrata_domain": {
                        "title": "Socrata domain",
                        "type": "string",
                        "description": "Open-data portal domain (default: data.cityofnewyork.us for NYC). Change to any Socrata city portal, e.g. data.cityofchicago.org.",
                        "default": "data.cityofnewyork.us"
                    },
                    "dataset_id": {
                        "title": "Socrata dataset ID",
                        "type": "string",
                        "description": "Socrata dataset identifier (default: 43nn-pn8j = NYC DOHMH Restaurant Inspection Results).",
                        "default": "43nn-pn8j"
                    },
                    "boro": {
                        "title": "Borough",
                        "enum": [
                            "Any",
                            "Manhattan",
                            "Brooklyn",
                            "Queens",
                            "Bronx",
                            "Staten Island"
                        ],
                        "type": "string",
                        "description": "Filter by NYC borough (Any = no filter). Ignored for non-NYC datasets.",
                        "default": "Any"
                    },
                    "cuisine": {
                        "title": "Cuisine keyword",
                        "type": "string",
                        "description": "Case-insensitive keyword matched against the cuisine description, e.g. 'Pizza', 'Chinese', 'Bakery'. Empty = no filter."
                    },
                    "zipcode": {
                        "title": "ZIP code",
                        "type": "string",
                        "description": "Filter by exact ZIP code. Empty = no filter."
                    },
                    "grade": {
                        "title": "Inspection grade",
                        "enum": [
                            "Any",
                            "A",
                            "B",
                            "C"
                        ],
                        "type": "string",
                        "description": "Filter by letter grade (Any = no filter). Only inspections that received a grade match.",
                        "default": "Any"
                    },
                    "critical_only": {
                        "title": "Critical violations only",
                        "type": "boolean",
                        "description": "If true, return only violation rows flagged as Critical.",
                        "default": false
                    },
                    "days_back": {
                        "title": "Days back",
                        "minimum": 1,
                        "maximum": 3650,
                        "type": "integer",
                        "description": "Only include inspections from the last N days (default: 30).",
                        "default": 30
                    },
                    "max_items": {
                        "title": "Maximum items",
                        "minimum": 1,
                        "maximum": 5000,
                        "type": "integer",
                        "description": "Maximum number of records to return (default: 100, hard cap: 5000).",
                        "default": 100
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
