# Toronto DineSafe Restaurant Inspections - Official Open Data (`apiflows/toronto-dinesafe-inspections`) Actor

Standardized Toronto DineSafe food-premises inspection records from the City of Toronto's official open data (OGL - Toronto): one item per inspection with full infraction detail and severity, filterable by date, status, severity, and name.

- **URL**: https://apify.com/apiflows/toronto-dinesafe-inspections.md
- **Developed by:** [APIFLOWS DEV](https://apify.com/apiflows) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 inspection records

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/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

## Toronto DineSafe Restaurant Inspections — Official Open Data

Extract standardized food-premises inspection records for **Toronto, Canada** from the City of Toronto's official open data, in one clean, fixed JSON schema.

DineSafe is Toronto Public Health's food safety inspection and disclosure system. This Actor queries the City of Toronto's official open-data datastore directly, groups every infraction row into **one item per inspection**, normalizes severity levels, and delivers dataset items that pipelines, analytics tools, and AI agents can consume without building their own integration.

### What you get

- **Official public records only** — data comes straight from the City of Toronto Open Data datastore (refreshed daily by the City); no synthetic or fabricated rows.
- **One item per inspection** — infractions are nested in a single `infractions` array with category, detail, published severity, and a normalized `severity_level` (Minor / Significant / Crucial), instead of one scattered row per infraction.
- **Useful filters** — lookback window, inspection status (Pass / Conditional Pass / Closed), minimum infraction severity, and establishment-name keyword.
- **Business data only** — output includes establishment names, addresses, inspection results, and outcomes. The source dataset's phone column is **deliberately excluded** from the output.
- **Pay per result** — you are charged per inspection record delivered ($0.005/record), plus a minimal Actor start fee. Set a maximum total charge on the run to cap spend; the Actor stops gracefully when the cap is reached.

### Data source

| Jurisdiction | Publisher | Program | Portal |
| :--- | :--- | :--- | :--- |
| **Toronto, ON** | Toronto Public Health | DineSafe | `open.toronto.ca/dataset/dinesafe` |

### Input parameters

| Parameter | Type | Description |
| :--- | :--- | :--- |
| `daysBack` | Integer | Inspections performed within the last N days (default `90`, max `3650`). |
| `statusFilter` | String | `all`, `pass`, `conditional_pass`, or `closed`. |
| `keyword` | String | Optional case-insensitive keyword matched against the establishment name (e.g. `"SUSHI"`). |
| `minSeverity` | String | `all`, `minor`, `significant`, or `crucial` — only inspections with at least one infraction at this severity or higher. |
| `maxItems` | Integer | Maximum inspection records to extract (default `100`). |

### Output example (normalized JSON)

```json
{
  "establishment_id": "001Vo000013QjdPIAS",
  "establishment_name": "EXAMPLE RESTAURANT",
  "address": "1871 O'Connor Dr",
  "postal_code": "M4A 1X1",
  "inspection_date": "2026-04-21",
  "status": "Pass",
  "latitude": 43.72198563,
  "longitude": -79.30349182,
  "infraction_count": 2,
  "infractions": [
    {
      "category": "05. MAINTENANCE / SANITATION OF NON-FOOD CONTACT SURFACES / EQUIPMENT",
      "detail": "FAIL TO ENSURE EQUIPMENT SURFACE SANITIZED AS NECESSARY - SEC. 22",
      "severity": "M - Minor",
      "severity_level": "Minor"
    }
  ],
  "observation": "One or more minor infractions were observed under the Food Premises Regulation during an inspection.",
  "outcome_date": "",
  "outcome_description": "",
  "amount_fined": null,
  "source_endpoint": "https://open.toronto.ca/dataset/dinesafe/",
  "scraped_at": "2026-11-19T00:00:00+00:00"
}
```

### Attribution

Contains information licensed under the **Open Government Licence – Toronto**. Data: **City of Toronto — Toronto Public Health (DineSafe)**, via Toronto Open Data (https://open.toronto.ca/dataset/dinesafe/).

### Data notes

- Records are retrieved live from the official datastore at run time; each item carries its `source_endpoint` and retrieval timestamp (`scraped_at`) for provenance.
- The City of Toronto provides the data "as is" and makes no warranty as to accuracy, timeliness, or completeness. Verify critical records against the source portal.
- Inspection coverage, fields, and update cadence are controlled by the City and may change without notice.

# Actor input Schema

## `daysBack` (type: `integer`):

Fetch inspections performed within the last N days.

## `statusFilter` (type: `string`):

Filter by the inspection outcome assigned by Toronto Public Health.

## `keyword` (type: `string`):

Optional keyword matched against the establishment name (case-insensitive), e.g. 'SUSHI' or 'PIZZA'.

## `minSeverity` (type: `string`):

Only return inspections that include at least one infraction at this severity or higher. Inspections with no infractions are included only when 'all' is selected.

## `maxItems` (type: `integer`):

Maximum number of inspection records to extract.

## Actor input object example

```json
{
  "daysBack": 90,
  "statusFilter": "all",
  "keyword": "SUSHI",
  "minSeverity": "all",
  "maxItems": 100
}
```

# Actor output Schema

## `inspections` (type: `string`):

Normalized DineSafe inspection records in the default dataset.

# 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 = {
    "daysBack": 90,
    "statusFilter": "all",
    "minSeverity": "all",
    "maxItems": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("apiflows/toronto-dinesafe-inspections").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 = {
    "daysBack": 90,
    "statusFilter": "all",
    "minSeverity": "all",
    "maxItems": 100,
}

# Run the Actor and wait for it to finish
run = client.actor("apiflows/toronto-dinesafe-inspections").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 '{
  "daysBack": 90,
  "statusFilter": "all",
  "minSeverity": "all",
  "maxItems": 100
}' |
apify call apiflows/toronto-dinesafe-inspections --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,apiflows/toronto-dinesafe-inspections"
        }
    }
}
```

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/g1o76Pbx9yH75K2KV/builds/MHIqk0YkoT4ljshrg/openapi.json
