# NYC Restaurant Health Inspection Monitor (DOHMH Grades JSON) (`steadfetch/nyc-restaurant-inspections-extractor`) Actor

Monitor official NYC Open Data restaurant inspections (DOHMH): one row per inspection and violation with score, grade, action, violation codes and descriptions, borough, cuisine, address and coordinates. Filter by date, borough, cuisine or grade. Establishment data only, no personal contact fields.

- **URL**: https://apify.com/steadfetch/nyc-restaurant-inspections-extractor.md
- **Developed by:** [Steadfetch](https://apify.com/steadfetch) (community)
- **Categories:** Other
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.20 / 1,000 inspection row delivereds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

This Actor returns official New York City restaurant inspection results published by the NYC Department of Health and Mental Hygiene (DOHMH) on the [NYC Open Data Socrata API](https://data.cityofnewyork.us/resource/43nn-pn8j.json): one structured JSON row per inspection or violation, with the score, grade, action, violation code and description, and the establishment borough, address and coordinates. It is meant for compliance, food-safety and location analytics work that needs the inspection grain the City actually publishes. No browser, no login and no API key are required.

Tested daily. Last verified: 2026-10-30

### What it does

The Actor queries the DOHMH New York City Restaurant Inspection Results dataset (Socrata resource `43nn-pn8j`) and writes one dataset item per inspection or violation row.

- Date window: `since` and `until` filter on `inspection_date`; when `since` is omitted the run covers the last 30 days.
- Filters: `borough`, `cuisine` and `grade` (A, B or C) narrow the query and are applied against the source. When `grade` is set, rows without a grade are not returned.
- Normalization: scores and coordinates become numbers, dates become `YYYY-MM-DD`, and missing or placeholder values become `null` (for example the `1900-01-01` placeholder and `0/0` coordinates).
- Deduplication: the key is `camis` + `inspection_date` + `violation_code`, applied inside a run and across monitor runs.
- Mode: `full` returns every matching row; `monitor` stores delivered keys in the Actor key-value store and emits only rows never delivered before for the same borough, cuisine and grade scope.
- Validation: every item is checked against `.actor/dataset_schema.json` before it reaches the dataset; with `strictSchema` true (the default) an invalid item fails the run.
- Privacy: establishment data only. The source `phone` column is never selected and no phone, email, officer or other personal contact field is published.

### How to use

1. Open the Actor in the Apify Console or the CLI and set the filters you need (`since`, `borough`, `cuisine`, `grade`, `maxResults`, `mode`).
2. Run it with the default example input to pull a small, recent slice of inspections.
3. To watch for new rows over time, set `mode` to `monitor` and schedule the run; already delivered keys are skipped.
4. Read results from the dataset, the `overview` view, or through the API.

Run the shipped example input from the CLI:

```bash
apify call steadfetch/nyc-restaurant-inspections-extractor --input='{"since":"2026-09-01","maxResults":10}'
```

### Input

#### Input fields

| Field | Type | Required | Default/Prefill | Description | Example |
| --- | --- | --- | --- | --- | --- |
| `since` | string | No | none (last 30 days) | Optional ISO date (YYYY-MM-DD). Only rows with `inspection_date` on or after this date are returned. | `2026-09-01` |
| `until` | string | No | none | Optional ISO date (YYYY-MM-DD). Only rows with `inspection_date` on or before this date are returned. | `2026-10-20` |
| `borough` | string | No | none | Optional NYC borough, case-insensitive: Manhattan, Brooklyn, Queens, Bronx or Staten Island. | `Manhattan` |
| `cuisine` | string | No | none | Optional cuisine description as published by DOHMH, case-insensitive (for example American, Pizza, Chinese). | `Pizza` |
| `grade` | string | No | none | Optional inspection grade, one of `A`, `B`, `C`. Rows without a grade are not returned when set. | `A` |
| `maxResults` | integer | No | 100 | Maximum number of inspection rows to save (minimum 1, maximum 5000). | `10` |
| `mode` | string | No | `full` | `full` returns every matching row; `monitor` returns only rows never emitted before in the same borough, cuisine and grade scope. | `monitor` |
| `strictSchema` | boolean | No | `true` | Fail the run when an item does not match the output schema. | `true` |

#### Example input

```json
{
  "since": "2026-09-01",
  "maxResults": 10
}
```

A wider, filtered monitor run using other documented fields:

```json
{
  "since": "2026-09-01",
  "borough": "Manhattan",
  "cuisine": "Pizza",
  "grade": "A",
  "maxResults": 50,
  "mode": "monitor"
}
```

### Output

#### Example output

```json
{
  "url": "https://data.cityofnewyork.us/resource/43nn-pn8j.json?camis=50193639",
  "title": "GENESIS HOUSE RESTAURANT",
  "scrapedAt": "2026-10-20T08:00:00.000Z",
  "camis": "50193639",
  "business_name": "GENESIS HOUSE RESTAURANT",
  "borough": "Manhattan",
  "building": "123",
  "street": "W 45 ST",
  "zipcode": "10036",
  "cuisine_description": "American",
  "inspection_date": "2026-09-15",
  "action": "Violations were cited in the following area(s).",
  "violation_code": "10F",
  "violation_description": "Non-food contact surface improperly constructed",
  "critical_flag": "Not Critical",
  "score": 12,
  "grade": "A",
  "grade_date": "2026-09-20",
  "latitude": 40.759,
  "longitude": -73.989,
  "source_url": "https://data.cityofnewyork.us/resource/43nn-pn8j.json?camis=50193639"
}
```

#### Output fields

| Field | Type | Description |
| --- | --- | --- |
| `url` | string | Public NYC Open Data API URL for this establishment (camis filter). |
| `title` | string or null | Business name, mirrored for the common Steadfetch envelope. |
| `scrapedAt` | string | ISO 8601 UTC timestamp of the run. |
| `camis` | string | Unique establishment identifier used by DOHMH. |
| `business_name` | string | Establishment business name as published by DOHMH. |
| `borough` | string or null | NYC borough. |
| `building` | string or null | Building / street number. |
| `street` | string or null | Street name. |
| `zipcode` | string or null | ZIP code. |
| `cuisine_description` | string or null | DOHMH cuisine label. |
| `inspection_date` | string | Inspection date (YYYY-MM-DD). The placeholder 1900-01-01 is never emitted. |
| `action` | string or null | Inspection action text. |
| `violation_code` | string or null | Violation code. |
| `violation_description` | string or null | Violation description. |
| `critical_flag` | string or null | Violation criticality flag. |
| `score` | number or null | Inspection score as published. Higher is worse. |
| `grade` | string or null | Letter grade as published. |
| `grade_date` | string or null | Date the grade was assigned (YYYY-MM-DD). Placeholder 1900-01-01 dates are emitted as null. |
| `latitude` | number or null | WGS84 latitude. Null when the source reports no valid coordinate. |
| `longitude` | number or null | WGS84 longitude. Null when the source reports no valid coordinate. |
| `source_url` | string | Public NYC Open Data API URL for this establishment. |

### Pricing

This Actor uses Apify pay-per-event pricing with the two synthetic platform events from `.actor/pay_per_event.json`:

- `apify-actor-start`: 0.00005 USD per run. This is the Apify-recommended default and it includes the first 5 seconds of compute per run.
- `apify-default-dataset-item`: 0.003 USD per row, that is **3.00 USD per 1,000 results**. Measured cost: a 1,000-row run takes about 4.0 seconds at the 256 MB minimum memory on one free Socrata request (about 0.00006 USD of compute per 1,000 rows), well under the 0.10 USD target and leaving a gross margin above 99%.

There is no custom per-item event, so a saved row is never double-billed. Items that fail schema validation and runs that return nothing are not billed as dataset items.

**Works on the Apify free plan** - about 1,666 inspection rows for the $5 monthly credit ((5.00 USD - 0.0002 USD run-start at the default 4 GB memory) / 0.003 USD per row).

### Other Steadfetch Actors

- [UK Food Hygiene Ratings](https://apify.com/steadfetch/uk-food-hygiene-monitor) - comparable hygiene scores when you track food-safety compliance across markets.
- [FDA Recall Monitor](https://apify.com/steadfetch/fda-recall-monitor) - food and drug recalls that overlap with inspected establishments' supply chains.
- [CPSC Recall Monitor](https://apify.com/steadfetch/cpsc-recall-monitor) - consumer product safety recalls to pair with venue-level compliance alerts.
- [Federal Register Monitor](https://apify.com/steadfetch/federal-register-monitor) - US regulatory filings that set the rules behind this inspection data.

### FAQ

**Do I need an API key or login?**
No. The NYC Open Data Socrata endpoint is public and keyless. An optional `SOCRATA_APP_TOKEN` Actor secret can raise Socrata rate limits; it is never part of the input and is never logged.

**Does it use a browser?**
No. The source is a JSON API, so plain HTTP is used instead of rendering the web front end.

**Does it return personal data?**
No. Only establishment fields are returned. The source `phone` column is not selected and no contact field (phone, email, officer) is published.

**When am I charged?**
Once per run start (`apify-actor-start`) and once per inspection row saved to the dataset (`apify-default-dataset-item`). Errors, retries, duplicates and the `1900-01-01` placeholder are not billed as results.

**How does monitor mode avoid charging twice?**
It stores the dedup keys it delivered in the Actor key-value store. On the next run with the same borough, cuisine and grade scope it skips those keys before pushing, so they are not billed again. Use `mode` `full` to re-pull the whole window each run.

**What are the limits?**
`maxResults` defaults to 100 and can be set up to 5000. When `grade` is set, only graded rows are returned.

### Support

Report bugs through the Issues tab on this Actor's Apify Store page or through the steadfetch actors repository issues. Please include the run ID and the input you used so the run can be reproduced.

### Maintenance

Target: tested daily. The Actor is registered for the Steadfetch daily catalog QA (enablement pending as of 2026-10-22); tests run in CI on every push. When the scheduled runs are enabled they check that the NYC Open Data API is reachable and that the output still matches the published schema. Failures are reported as issues in the Steadfetch Actors repository.

# Actor input Schema

## `since` (type: `string`):

Optional ISO date (YYYY-MM-DD). Only rows with inspection_date on or after this date are returned. Default: the last 30 days.

## `until` (type: `string`):

Optional ISO date (YYYY-MM-DD). Only rows with inspection_date on or before this date are returned.

## `borough` (type: `string`):

Optional NYC borough, case-insensitive: Manhattan, Brooklyn, Queens, Bronx or Staten Island.

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

Optional cuisine description as published by DOHMH, case-insensitive (for example American, Pizza, Chinese).

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

Optional inspection grade. Rows without a grade are not returned when this filter is set.

## `maxResults` (type: `integer`):

Maximum number of inspection rows to save to the dataset.

## `mode` (type: `string`):

full: return every matching row (deduplicated inside the run). monitor: return only rows that were never emitted by a previous monitor run with the same borough, cuisine and grade scope. The monitor state is stored in the Actor key-value store.

## `strictSchema` (type: `boolean`):

Fail the run when an item does not match the OUTPUT schema. Keep enabled: Steadfetch never publishes Actors without output-schema validation.

## Actor input object example

```json
{
  "since": "2026-09-01",
  "until": "2026-10-20",
  "borough": "Manhattan",
  "cuisine": "Pizza",
  "grade": "A",
  "maxResults": 50,
  "mode": "full",
  "strictSchema": true
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset items validated against the item schema in dataset_schema.json (fields).

# 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 = {
    "since": "2026-10-01",
    "until": "2026-10-05",
    "maxResults": 10,
    "mode": "full",
    "strictSchema": true
};

// Run the Actor and wait for it to finish
const run = await client.actor("steadfetch/nyc-restaurant-inspections-extractor").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 = {
    "since": "2026-10-01",
    "until": "2026-10-05",
    "maxResults": 10,
    "mode": "full",
    "strictSchema": True,
}

# Run the Actor and wait for it to finish
run = client.actor("steadfetch/nyc-restaurant-inspections-extractor").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "since": "2026-10-01",
  "until": "2026-10-05",
  "maxResults": 10,
  "mode": "full",
  "strictSchema": true
}' |
apify call steadfetch/nyc-restaurant-inspections-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,steadfetch/nyc-restaurant-inspections-extractor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/wRkiUTYJ8p6K3yUzv/builds/jhzBk6ahp3RkoSYnf/openapi.json
