City of Toronto · Notes from the code
How MapleStats works with Toronto's open data
A number from a city dataset is only useful if you know what it measures. This post follows one question through open.toronto.ca: find the dataset, read what the City says its columns mean, then get the figures, with the citation and licence attached.
Finding a dataset
The City's portal runs CKAN, the open-source catalogue many governments use, and its API answers anyone. MapleStats reads it with 13 general CKAN tools, the same ones it uses for the federal portal and the other city and provincial catalogues, and adds 9 tools written for the Toronto datasets people ask about most.
The question this post follows: how well are Toronto's rental apartment buildings kept? The City's RentSafeTO program scores them. A search of the catalogue finds the dataset:
call_tool{
"name": "ckan_search_datasets",
"arguments": {"portal": "toronto", "query": "apartment building evaluation", "rows": 2}
}{
"packages": [
{
"name": "apartment-building-evaluation",
"title": "Apartment Building Evaluation",
"notes_excerpt": "This dataset contains building evaluation data for rental buildings that are registered in the City's RentSafeTO: Apartment Building Standards program.",
"update_frequency": "Daily",
"owner_unit": "Municipal Licensing & Standards",
"datastore_resources": 2,
"landing_page_url": "https://open.toronto.ca/dataset/apartment-building-evaluation/"
// + 11 more fields
}
// 1 more
],
"total_count": 4,
"provenance": {
"url": "https://ckan0.cf.opendata.inter.prod-toronto.ca/api/3/action/package_search?q=apartment+building+evaluation&rows=2&start=0"
// + 13 more fields
}
}What a column means
A column called CURRENT BUILDING EVAL SCORE invites a guess. The City does not leave it to one: its DataStore keeps a note on each column, and the dataset's record says how the data were collected and how often they change. ckan_get_dataset_documents returns both, here for the 70 columns of the current evaluations, kept to the ones that match "score":
call_tool{
"name": "ckan_get_dataset_documents",
"arguments": {"portal": "toronto", "dataset_id": "apartment-building-evaluation", "query": "score"}
}{
"title": "Apartment Building Evaluation",
"about": {
"refresh_rate": "Daily",
"owner_division": "Municipal Licensing & Standards"
},
"data_dictionary": [
{
"resource_names": [
"Apartment Building Evaluations 2023 - current"
],
"fields": [
{
"name": "CURRENT BUILDING EVAL SCORE",
"description": "An assessment of a building's compliance with property standards which is calculated by adding the reactive score (applicable Orders or Notices of Violations) to the proactive score (latest building evaluation score)"
// + 2 more fields
},
{
"name": "PROACTIVE BUILDING SCORE",
"description": "The score of the most recent, proactive evaluation of the common areas of a building reflecting the weighted score of all, applicable, evaluation categories."
// + 2 more fields
},
{
"name": "CURRENT REACTIVE SCORE",
"description": "Total score of all applicable Orders and Notices of Violation issued for a building"
// + 2 more fields
}
],
"fields_total": 70
}
// 1 more
],
"documents": [
{
"title": "Information page",
"url": "https://www.toronto.ca/community-people/housing-shelter/rental-housing-standards/apartment-building-standards/",
"kind": "information page"
},
{
"title": "RentSafeTO",
"url": "https://www.toronto.ca/community-people/housing-shelter/rental-housing-tenant-information/rental-housing-standards/apartment-building-standards/rentsafeto-for-tenants/",
"kind": "linked in the description"
}
// 1 more
],
"notes": [
"The documents are listed, not opened: some publishers' terms or robots.txt rule out automated copies (the City of Toronto's, for one), so read them in a browser and cite them by their URL."
],
// + 4 more fields
"provenance": {
"url": "https://ckan0.cf.opendata.inter.prod-toronto.ca/api/3/action/package_show?id=apartment-building-evaluation"
// + 13 more fields
}
}Two things change how the score should be read. It adds two parts: the latest proactive evaluation, and the orders and notices of violation issued since. And the dataset's description says the officers inspect common areas, mechanical and security systems, parking and exterior grounds. A building's score says nothing about the inside of any one unit. An agent that reads this before answering will say so.
The 3 pages the dataset points to are listed with their address but not opened. The City's website terms bar copying its pages without permission, so the agent gives you the link to read and cite. The idea for this tool comes from the CKAN MCP Server, an honourable mention at the 2025 Toronto Open Data Awards; MapleStats' version reads only what the portal's API serves.
Apartment scores by ward
With the meaning settled, toronto_summarize_apartment_scores reads the evaluations and groups the buildings by ward. On 19 November 2026, Scarborough-Rouge Park had the lowest mean score (85.9) of the 25 wards, and Etobicoke Centre the highest (94.3).
| Ward | Buildings | Units | Mean | Median | Lowest |
|---|---|---|---|---|---|
| 01 Etobicoke North | 82 | 9,602 | 92.4 | 93.0 | 77 |
| 02 Etobicoke Centre | 134 | 13,064 | 94.3 | 96.0 | 72 |
| 03 Etobicoke-Lakeshore | 250 | 13,968 | 92.7 | 94.0 | 69 |
| 04 Parkdale-High Park | 207 | 17,492 | 90.8 | 92.0 | 51 |
| 05 York South-Weston | 238 | 18,354 | 87.9 | 89.0 | 62 |
| 06 York Centre | 235 | 15,939 | 92.1 | 94.0 | 69 |
| 07 Humber River-Black Creek | 103 | 15,116 | 90.7 | 92.0 | 70 |
| 08 Eglinton-Lawrence | 242 | 14,424 | 92.4 | 94.0 | 70 |
| 09 Davenport | 95 | 6,859 | 87.8 | 89.0 | 52 |
| 10 Spadina-Fort York | 62 | 10,610 | 90.4 | 93.0 | 45 |
| 11 University-Rosedale | 149 | 13,744 | 88.8 | 91.0 | 53 |
| 12 Toronto-St. Paul's | 340 | 27,478 | 91.0 | 93.0 | 59 |
| 13 Toronto Centre | 214 | 29,436 | 90.1 | 92.0 | 73 |
| 14 Toronto-Danforth | 151 | 9,985 | 89.5 | 92.0 | 67 |
| 15 Don Valley West | 171 | 16,696 | 93.1 | 94.0 | 76 |
| 16 Don Valley East | 159 | 16,412 | 91.4 | 93.0 | 69 |
| 17 Don Valley North | 74 | 11,901 | 91.8 | 92.0 | 76 |
| 18 Willowdale | 47 | 7,222 | 90.8 | 93.0 | 71 |
| 19 Beaches-East York | 202 | 13,110 | 91.4 | 93.0 | 49 |
| 20 Scarborough Southwest | 163 | 13,186 | 89.8 | 91.0 | 62 |
| 21 Scarborough Centre | 136 | 11,835 | 88.8 | 90.0 | 69 |
| 22 Scarborough-Agincourt | 42 | 7,592 | 92.7 | 94.0 | 80 |
| 23 Scarborough North | 9 | 1,649 | 94.1 | 94.0 | 90 |
| 24 Scarborough-Guildwood | 78 | 12,515 | 89.0 | 90.0 | 69 |
| 25 Scarborough-Rouge Park | 28 | 2,103 | 85.9 | 86.0 | 77 |
The means and medians are of buildings, not of units: a 300-unit tower counts as much as a 12-unit walk-up. The result says so, so an agent can say so too.
A neighbourhood beside the city
The City's Neighbourhood Profiles give each of its 140 neighbourhoods a column of census figures, with the city as a whole beside them. toronto_get_neighbourhood_profile returns one neighbourhood and the city on the same row, here for housing in Regent Park:
call_tool{
"name": "toronto_get_neighbourhood_profile",
"arguments": {"neighbourhood": "Regent Park", "topic": "core housing need"}
}{
"census_year": 2016,
"neighbourhood": "Regent Park",
"rows": [
{
"characteristic": "Rate of core housing need",
"value": null,
"city_value": "23.3"
},
{
"characteristic": "Number of households in core housing need",
"value": "1,340",
"city_value": "240,780"
},
{
"characteristic": "Rate of unaffordable housing",
"value": "39.4",
"city_value": "36.6"
},
{
"characteristic": "Rate of inadequate housing",
"value": "9.6",
"city_value": "7.1"
},
{
"characteristic": "Rate of unsuitable housing",
"value": "16",
"city_value": "12.1"
}
// 16 more rows
],
"provenance": {
"url": "https://ckan0.cf.opendata.inter.prod-toronto.ca/api/3/action/datastore_search?resource_id=7f8eee5e-85fb-415c-aef3-c3bd4998445f&fields=_id%2CCategory%2CTopic%2CCharacteristic%2CData+Source%2CCity+of+Toronto%2CRegent+Park&sort=_id&limit=1000"
// + 13 more fields
}
}In 2016, 39.4% of Regent Park's households spent 30% or more of their income on shelter, against 36.6% for the city. The City published no rate of core housing need for the neighbourhood (the city's was 23.3%), and the response leaves it empty rather than fill it in. These are the 2016 profiles: the 2021 ones come only as a spreadsheet file, which the server does not download (see the portal's rules).
Short-term rentals
Of 8,598 registrations in force with the City's short-term rental program, 2,622 were in Spadina-Fort York. toronto_summarize_short_term_rentals counts them by ward, property type or postal code. The City's table also lists each operator's registration number and street address; the tool returns counts only. A registration is not a booking or a night stayed, and the result says that as well.
The portal's rules
The API, not the files. The portal's robots.txt allows its API and disallows automated downloads of its resource files. MapleStats reads the catalogue and the DataStore tables through the API and downloads none of the files. Some datasets exist only as files, so they are out of reach for now: 311 service requests (yearly ZIP files), the TTC's GTFS schedules, the 2021 Neighbourhood Profiles (a spreadsheet) and DineSafe inspections older than the DataStore table. Asked to read one of these files, the CKAN file tools say why they will not.
The City's pages. The documents a dataset links to are listed, not copied, as above.
The licence. The data are under the Open Government Licence - Toronto, which allows use, copying and publishing, commercially too, with an acknowledgement. Every result from the 9 Toronto tools carries the dataset's citation and the sentence the licence asks for: "Contains information licensed under the Open Government Licence - Toronto."
A named, paced client. Requests carry MapleStats' own User-Agent and go through one rate limit per portal, shared by every tool that reads it.
Where to go next
- The 9 City of Toronto toolsApartment evaluations and scores by ward, neighbourhood profiles, DineSafe inspections and short-term rental counts.
- The 13 CKAN toolsAny dataset on open.toronto.ca, with
portal="toronto". - Connect MapleStats to your agentOne address, no account or API key.