Open source

An open-source civic project. Not affiliated with the Government of Canada or the City of Toronto.

Watermain Codebook

Nshipyard Canada · Project 03

Toronto's watermains, decoded.

Watermains are the large pipes under the street that carry drinking water across the city. Toronto publishes the location, diameter, material, and install year of every segment it manages: 49,414 segments, 6,131.6 km. Material arrives as unexplained codes like CI and DICL, and nothing flags which pipes date from the era of lead service connections. This is the codebook: 18 material codes documented in plain English with counts and quality notes, plus a lead-era classification built on the City's own mid-1950s cutoff.

49,414

watermain segments documented, 6,131.6 km of pipe across the distribution and transmission networks

18

material codes decoded: cast iron, ductile iron, PVC, steel, concrete and the rest, each with counts and notes

16,949

segments installed before 1955, the City's lead-service era cutoff, covering 2,014.9 km

25

wards ranked by lead-era pipe, showing where the oldest network concentrates

Explorer

Search the codebook.

Search by code or meaning above, or filter by code type, to browse the 61 documented codes.

Showcase

Where the lead-era network concentrates.

The raw file lists install years; it cannot tell you which wards carry the oldest pipes. Joining 46,923 distribution segments to ward boundaries by segment midpoint reveals the pattern: Toronto-St. Paul's has 84.2% of its distribution network dating from before 1955, the highest share in the city. Etobicoke-Lakeshore carries the most lead-era pipe by length at 206.0 km. The lead-era cohort is 91.6% cast iron.

Lead-era pipe by ward

Distribution network installed before 1955, the City of Toronto's lead-service era cutoff. Length in km, and share of each ward's network.

The network's age, by decade

Segments by construction decade. Two build waves stand out: the post-war expansion of the 1950s with 8,339 segments, and the 2000s-2010s replacement wave with 9,772 segments combined. Pipes from the 1870s are still in the file: 752 segments predate 1880.

pre-1955 1955+

What the lead-era pipes are made of

15,528 of the 16,949 lead-era segments are cast iron. The classification is era-based, not a lead measurement: no segment in the dataset carries an explicit lead material code.

What this does not say: these are watermains, the street pipes, not service connections. Toronto's lead risk is about service pipes, the small lines from the main to the house. This flag marks where lead-era services are more likely nearby; it never states that a pipe contains lead.

Methodology

How the codebook was built, and where it is weak.

  1. 01

    Source: the City of Toronto open data “Watermains” package, retrieved 2026-10-08. Distribution: 46,923 segments, 5,586.4 km. Transmission: 2,491 segments, 545.2 km. The City updates it daily.

  2. 02

    Material codes are decoded from standard water-industry usage; the source publishes no codebook, which is why this project exists. Diameter units are inferred as millimetres from standard pipe sizes. Watermain Type codes (0, 1, 2) are inferred from file context.

  3. 03

    Lead rule: construction year before 1955 counts as lead-era, from the City of Toronto's statement that lead water service pipes affect homes built before the mid-1950s. That gives 16,949 segments and 2,014.9 km. No segment carries an explicit lead material code.

  4. 04

    Measured versus inferred: the dataset measures pipe location, material code, diameter, and install year. Lead content is never measured; the era flag is inferred. Health conclusions are out of scope.

  5. 05

    731 segments (1.5%) have no construction year and cannot be era-classified. 830 segments have no material recorded (UNK).

  6. 06

    Wards are assigned by segment midpoint against the City's 25-ward model. Segments falling outside every ward polygon are excluded from the ward tables.

  7. 07

    Corrosion control: the City has added phosphate at its treatment plants since 2014, which lowers lead leaching. Era describes the pipe inventory in the ground, not current water quality.

For developers

Query it from code, or from an agent.

Three consumption paths, same canonical data. REST for applications, OpenAPI for integration, MCP tools over streamable HTTP for AI agents.

Endpoints

GET

/api/v1/watermain/codes?q=ductile&type=material

Search the codebook by code or meaning, optionally filtered by code type

{
  "q": "ductile",
  "type": "material",
  "rows": [
    { "code_type": "material", "code": "DIP",
      "meaning": "Ductile Iron Pipe",
      "count": 4440, "pct": 8.99,
      "notes": "Ductile (nodular) cast iron; …" }
  ]
}
Try it →

GET

/api/v1/watermain/lead?ward=19

Lead-era classification for one ward: rank, lead-era km, share of network

{
  "ward": "19", "name": "Beaches-East York",
  "rank": 2, "lead_era_km": 164.7,
  "lead_era_pct": 79.8, "median_year": 1948,
  "rule": "Construction year before 1955 …"
}
Try it →

GET

/api/v1/watermain/summary

Network totals, material mix, lead classes, decade distribution, ward ranking

{ "meta": { "segments": 49414, "total_km": 6131.6, … },
  "materials": [ { "code": "CI", "count": 25359 }, … ],
  "lead": { "classes": { "lead_era": { "segments": 16949 } } },
  "wards": [ … ] }
Try it →

Connect your agent

Put this data to work inside your AI tools.

Pick your harness, copy the prompt, send it to your agent. Your agent runs the setup itself.

Copy and send this to Claude Code

Set up the Toronto Watermain Codebook MCP server so I can query it from here.
1. Run: claude mcp add --transport http toronto-watermain https://this-site.example/mcp
2. Run `claude mcp list` to confirm it connected.
3. Look up material code CI and tell me its lead-era share, and show me the result.

Data

Take the files.

The codebook and the per-segment classification, MIT licensed, as CSV.

watermain_codebook.csv

61 codes: 18 materials, 3 function codes, diameters, with meanings, counts, and notes

Download
lead_classification.csv

49,414 segments with lead-era classification, ward, and the rule applied

Download