# Toronto DineSafe Restaurant Inspections (`loudtzu/toronto-dinesafe-inspections`) Actor

Toronto Public Health DineSafe food inspections: restaurant name, address, date, pass/conditional/closed, infractions, severity, fines. Official open data.

- **URL**: https://apify.com/loudtzu/toronto-dinesafe-inspections.md
- **Developed by:** [LOUDTZU TZULOUD](https://apify.com/loudtzu) (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

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

### What it does

Pulls Toronto Public Health's **DineSafe** food-premises inspection results from the City of Toronto open data portal. You get one row per inspection finding: the restaurant or food business, its address, the inspection date, the result (Pass, Conditional Pass or Closed), each infraction with its severity, and any court outcome and fine. The source has about 124,000 rows and is refreshed daily. The Actor reads the official API; it does not scrape web pages.

Source: [DineSafe on open.toronto.ca](https://open.toronto.ca/dataset/dinesafe/).

### Who it's for

Food-safety and restaurant-tech apps, delivery and review platforms, pest-control and sanitation sales teams, insurers, journalists and anyone who wants Toronto restaurant inspection history in a spreadsheet.

### Input

| Field | What it does |
|---|---|
| `establishmentName` | Word search on the business name, e.g. `Tim Hortons`, `sushi` |
| `keyword` | Text that must appear in the name, address, observation, infraction or outcome, e.g. `pest` |
| `inspectionStatus` | `pass`, `conditional pass` or `closed` |
| `severity` | `minor`, `significant` or `crucial` |
| `infractionsOnly` | Skip rows where no infraction was found |
| `postalPrefix` | First 3 characters of the postal code, e.g. `M5V` |
| `dateFrom` / `dateTo` | Inspection date range, YYYY-MM-DD |
| `maxItems` | Default 100, maximum 50,000 |

Results come newest first. Example: `{"inspectionStatus": "closed", "dateFrom": "2026-01-01"}` lists every closure this year.

### Output

`recordId`, `establishmentId`, `legacyEstablishmentId`, `establishmentName`, `nameWithheld`, `address`, `postalCode`, `inspectionDate`, `inspectionStatus`, `observation`, `infraction`, `deficiencyCategory`, `severity`, `outcome`, `outcomeDate`, `amountFinedCad`, `latitude`, `longitude`, `source`, `licence`.

An inspection with several infractions appears as several rows that share the establishment and date. An inspection with no infractions has one row with `infraction` empty.

### Privacy

- The establishment **telephone number is dropped**: it is never requested from the source or exported.
- **Personal names in business names are masked.** Some establishments are sole operators whose own name is the business name: hot-dog carts and food trucks ("C. Smith - Toronto Plate No. 01234 (Hot Dog Cart)") and person-named shops ("First Last Catering"). In those rows the name is replaced with `[name withheld]` and `nameWithheld` is `true`; the rest of the name (plate number, "Hot Dog Cart", "Fruit Market") is kept.
  - **Strict default.** Any two adjacent words that could be a given name followed by a surname are masked. A word counts as a possible given name when it is on a given-name list **or is unknown** (not an English dictionary word, business word, dish, cuisine or place word); it counts as a possible surname when it is on the surname list, is an O'/D' surname ("O'Brien", "D'Souza") or is unknown. So a name is masked even when neither word is on any list.
  - **Forms covered** (each tested with synthetic names in UPPER, Title and lower case):
    - "First Last", with any trailing trade word, possessive or number, and "First First Last" (two given names);
    - "First G. Last" and "First G Last" (middle initial), "First K. B. Last" (spaced middle initials; the whole span is masked, never half); "First & First Last";
    - "First.Last" (dot-joined; a web ending such as ".com", ".ca" or ".to" is not read as a surname);
    - "First and Last" / "First & Last" at the start of the name when the given name is on the given-name list;
    - **Vietnamese order with Le or Do as the surname**: "Le Van First", "Le Van First Catering", "Do Van First", "Van First Le" (Le and Do count as surnames, not particles, before a Vietnamese middle name such as Van, Thi, Minh, Ngoc, Duc, Huu, Thanh, Quoc, Xuan, Hoang, Dinh, Cong, or a given name);
    - apostrophe given names ("D'Arcy Last", "De'Shawn Last"); any word before "Singh" or "Kaur" that is not a business, place or trade word ("Lucky Singh");
    - **"Last, First"** (registry style), "Last; First", "Last, K", "Last/First Catering" and "Last - First - Cart" (at the start of the name), "Last, First-First", "Last,First Catering", and several names joined by "/" ("Last, First/Last, First"); a name after "/" or "&" that follows a withheld name ("First Last / Last Catering") is withheld too;
    - **hyphenated given names** ("Jean-Paul Last"): a hyphenated word counts as a given name when either part is a given name or unknown; hyphenated surnames ("Last-Last", "Ben-Last", "Al-Last");
    - **surname particles** between the given name and the surname are skipped and the whole span is masked: da, de, de la, del, della, di, do, dos, das, du, des, el, al, bin, ben, ibn, bint, abu, van, von, van der, ter, ten, Mc, Mac ("First da Last", "First de la Last", "First bin Last", "First Mc Last"); "Mc Last" and "Mac's" are masked on their own;
    - **initials**: "J Last", "J. Last", "J.P. Last", "J. P. Last", "K. B. Last", "Last J.", "Last, F."; "Last's by First";
    - **case and accents**: matching is case-insensitive and runs on accent-folded text ("MÜLLER, JÜRGEN", "Łukasz", "Nguyễn Văn", "Çağla Öztürk" are matched as "MULLER, JURGEN" and so on; the original spelling is what is replaced).
  - **Not covered (known gaps).**
    - Surname-only forms with no given name or initial: "Mr & Mrs Last", "The Lasts", "Last's Bakery".
    - A full name after a saint prefix ("St. First Last Catering"), and a full name directly before a place-of-worship word that ends the name ("First Last Church", "First Last Temple") or a school-board school pattern ("First Last P.S."): these are kept on purpose (see below).
    - A lone given name ("First Centre", "Chez First", "Chef First's") and a lone surname.
    - "First and Last" / "First & Last" when the given name is not on the given-name list (two unknown words joined by "&" are usually a business), and when it is not at the start of the name.
    - "Last/First" with spaces around the slash, or when nothing follows the given name; "Last - First" without a second " - ".
    - "Last/First Catering" and "Last - First - Cart" when the surname is also an ordinary dictionary word or the given name is only on the U.S. given-name list (for example "Smith/John Catering"): these are kept.
    - Lower-case initials inside a name that also has capitals ("Last, k"); a bare "A" or "O" without a period ("A Last Bakery", read as an article; "A. Last" is masked).
    - Names in non-Latin scripts (Chinese, Korean, Arabic and other characters are not read as names).
    - A name whose words are both ordinary English dictionary words and not on a name list.
  - **Word lists, honestly.** Given names: a U.S. list plus a world list (Chinese, Vietnamese, Korean, Japanese, South-East Asian, South Asian, West and East African and others) built from Wikidata and a public-domain names dataset (CC0; see `src/first_names_world_SOURCE.txt`). Surnames: the **top 5,000 U.S. Census 2010 surnames** only (`src/surnames_SOURCE.txt`), so most non-U.S. surnames are not on it; they are caught by the unknown-word rule instead. Words that are known not to be names (cuisines, dishes, business and place words) are in `src/non_name_words.txt` (`src/non_name_words_SOURCE.txt`). A test checks that no word there is on the shipped given-name or surname lists, nor a Wikidata given name or family name borne by 3 or more people (about 227,000 family names and 47,000 given names, CC0; `tests/wikidata_names_SOURCE.txt`). Words such as "Casa", "Dolce", "Nero" or "Verde" are therefore treated as possible names. Articles and particles ("la", "el", "los", "de", "il"...) and abbreviations ("ave", "co", "inc") are never a name on their own. A separate, smaller list of 141 cuisine, place and trade words in `src/names.py` (`_NOT_SURNAME`, e.g. "Thai", "Toronto", "Shawarma") never counts as the surname of a pair; 37 of these words are also Wikidata family names, so "<Given> Thai" or "<Given> Toronto" is kept. This is a known gap, accepted to avoid masking names like "Bangkok Thai".
  - **Titles.** Only a saint prefix ("St.", "Ste", "Saint", "Blessed", "Pope", "Notre", "Frère", "Sœur") keeps the name after it. Every other title is masked with the name: "Dr.", "Father", "Rev.", "Brother", "Sister", "Mother", "Lord", "Lady", "King", "Prince", "General", "Senator", "Chief", "Captain", "Mrs.".
  - **What keeps a pair.** Only: a school-board school pattern directly after it ("Public School", "P.S.", "Collegiate", "C.I.", "Catholic Secondary School"...); a place-of-worship word ("Church", "Temple", "Synagogue", "Mosque", "Chapel"...) **only when that word ends the name** (or is followed by " - ", "(", "#" and similar), so "First Last Church" is kept but "First Last Church Catering" and "First Last Temple Bakery" are masked; a worship word is never taken as the surname itself ("St. Clements of Ohrid Church", "Hindu Temple" are kept); a saint prefix; a possessive first name alone ("Mary's"); a lone first name before "Centre" at the end of the name or before a fixed trade phrase ("Day Care", "Tea House", "Fine Foods", "Fish & Chips"); and exact phrases on an allowlist (brands, public figures and the public schools and City-run facilities named for them, places, romanised words), each group with a stated reason and no wildcards. An allowlist phrase followed by a further surname ("Captain First Last") is masked. Venue words that are also surnames ("House", "Place", "Hall", "Manor", "Lodge", "Chapel") do not keep a name. Child-care, nursery, Montessori, academy, "Jr."/"Sr." and similar words do not keep a name. Community and non-profit centres named for private individuals are not on the allowlist and are masked.
  - **Over-masking is deliberate.** Because unknown words and surnames that are also ordinary words ("King", "Park", "Casa", "Verde") count as possible names, many business names that only look like a person's name are masked too (for example "Costa Verde" and many romanised restaurant names). Over-masking a business is accepted; leaving a person's name is not.
  - **Chains and landmarks kept by exact phrase.** One allowlist group holds well-known chains with many branches (national, international or Toronto-area) and Toronto landmarks that the strict rule would mask; every entry is a business or place name, not a person: Kung Fu Tea, Casa Loma, Palais Royale, Hai Di Lao, Radisson Blu, Oakberry, Nando's, Firkin, Pharmasave, Tutti Frutti, Esso, Scotiabank, Yogen Früz, Hokkaido Ramen Santouka, Shi Miaodao, Yin Ji Chang Fen, Machi Machi, Xing Fu Tang, Gong Cha, Fuwa Fuwa, Church's Texas Chicken, Tim Hortons, Kibo, Delmanor, Daldongnae, Yee Hong, Apotex, Lindt & Sprüngli, Rabba, Art Gallery of Ontario. "Yee Hong" is kept only as the centre ("Yee Hong Centre"), and "Xing Fu Tang Fairview" and "Delmanor Prince Edward" are kept as branch names. Several of these words are also surnames, so an entry does **not** protect a given name directly in front of it: "First Kibo", "First Esso Catering" or "First Rabba Catering" is masked, and so is a full name before or after an entry ("First Last - Tim Hortons"). For the single-word entries that are also surnames (Rabba, Firkin, Kibo, Esso, Delmanor, Apotex) this covers any possible given name, listed or unknown, except a Toronto street, neighbourhood or place word, which names the branch ("Harbord Esso"). For the other entries it covers given names on the given-name lists only: an unknown word before them ("First Kung Fu Tea", "First Oakberry") is kept.
  - A full scan of the 14,898 distinct source names on Oct 29, 2026 masked 1,098 names (8,152 of about 124,466 rows, 6.5%). Like any rule-based filter it can still miss an unusual name (see the gaps above).
- Addresses are the inspected premises (or cart location) as published by the City. Inspector names are not in the source.
- A name search (`establishmentName`) for a withheld person's name returns no rows for that business; searches such as `hot dog` still return masked rows.

### Alternatives (checked Oct 29, 2026)

No Apify Store Actor is built for DineSafe. Two generic CKAN tools can export the same City of Toronto table row by row:

| Actor | Price | Notes |
|---|---|---|
| doggo/ckan-opendata-exporter | $0.01 per GB of run memory (default 4 GB = $0.04) + $0.001 per row (FREE plan), $0.0009 (BRONZE), $0.0008 (SILVER), $0.0007 (GOLD and above) | Generic exporter for any CKAN portal |
| straightforward_hydra/ckan-open-data-scraper | $0.002 per record + $0.00005 per GB of run memory (default 4 GB = $0.0002) | Generic CKAN scraper |
| **This Actor** | **$0.003 per row, no start fee** | DineSafe only |

**Ours costs more per row.** What the extra cost buys:

- DineSafe-specific filters: result (pass/conditional/closed), severity, infractions only, postal prefix, date range, name word search and keyword. Results come newest first.
- Clean, typed fields: dates as YYYY-MM-DD, fines and coordinates as numbers, postal code split out of the address, "None" placeholders removed.
- Privacy: the phone column is never requested, and personal names of cart, truck and sole-operator businesses are masked. A generic export returns the source columns as published.
- The licence attribution is on every row.

If you only need the raw table and will clean it yourself, a generic CKAN exporter is cheaper.

### Licence

- **Open Government Licence – Toronto** ([text](https://open.toronto.ca/open-data-licence/)). It grants a worldwide, royalty-free licence to use the information "including for commercial purposes", with attribution. Every row carries the attribution: "Contains information licensed under the Open Government Licence – Toronto."
- The portal's `robots.txt` allows `/api/`. The Actor reads the public CKAN API, 1,000 rows per request, with a short pause between pages.
- Independent; not endorsed by the City of Toronto or Toronto Public Health.

### Pricing

**$0.003 per result, no start fee** (one result = one inspection row). 1,000 rows cost about $3.

### Limits

- The run-level **Max items** option (Apify run options / API `maxItems`) is honoured: the run stops at the lower of that limit and the input `maxItems`, so you are never charged for more rows than either allows.
- An `establishmentName` that is only spaces is rejected: the run fails at once with a clear status message, before any row is read or charged ($0). Leave it empty for no name filter.
- The name search matches whole words (plurals and apostrophes are handled), not parts of words.
- `keyword`, `postalPrefix` and `dateTo` are applied while reading newest first, so on old date ranges a run reads more pages before it finds matches.
- The live dataset starts in November 2023 (checked Oct 29, 2026); older history is only in the City's separate historical ZIP, which this Actor does not read.

# Actor input Schema

## `establishmentName` (type: `string`):

Word search on the establishment name, e.g. Tim Hortons, sushi (case-insensitive; plurals and apostrophes match).

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

Text that must appear in the name, address, observation, infraction or outcome, e.g. pest, handwashing, Queen St. Applied while reading newest first, so combine it with a date range for speed.

## `inspectionStatus` (type: `string`):

Only this inspection result.

## `severity` (type: `string`):

Only infractions of this severity.

## `infractionsOnly` (type: `boolean`):

Skip inspection rows with no infraction.

## `postalPrefix` (type: `string`):

First 3 characters of the postal code, e.g. M5V.

## `dateFrom` (type: `string`):

YYYY-MM-DD.

## `dateTo` (type: `string`):

YYYY-MM-DD.

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

Stop after this many records (1-50,000). Each record is a billable result.

## Actor input object example

```json
{
  "infractionsOnly": false,
  "maxItems": 50
}
```

# Actor output Schema

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

All inspections returned by the run.

# 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 = {
    "maxItems": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("loudtzu/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 = { "maxItems": 50 }

# Run the Actor and wait for it to finish
run = client.actor("loudtzu/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 '{
  "maxItems": 50
}' |
apify call loudtzu/toronto-dinesafe-inspections --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,loudtzu/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/PFdOdPDRErpQbALXf/builds/tLuAR12p8s9BvP8Pu/openapi.json
