# Test a building permit API against city records

> Compare a provider’s permit IDs, issue dates, inspection completion and roof scope with dated NYC and Seattle records.

Source: https://docs.invariant-ai.com/test-building-permit-api

To compare building permit APIs, start with records you can verify at the issuing office. Give providers the same buildings and date ranges, then match their results on the source permit number. Use [the building identity workflow](https://docs.invariant-ai.com/verify-building-by-address) to link the permit to the intended structure. Invariant Earth supplies cited building, parcel and zoning context for that join.

## Run the reference trial

The [Python script](https://docs.invariant-ai.com/examples/building-permit-trial.py) reads two dated samples from [Invariant’s permit comparison](https://invariant-ai.com/blog/building-permit-data-apis). It uses Python 3.11 or newer and runs locally without a provider key. The downloads keep the original city queries and retrieval dates.

The [versioned trial download](https://github.com/in-variant/invariant-website/releases/tag/building-permit-api-trial-v1.0.0) bundles the script, both city samples, the expiration observations, and a provider CSV template. It includes a sample comparison and checksums so teams can rerun the same trial.

```bash
curl -fLsS --max-time 30 -o building-permit-trial.py \
  'https://docs.invariant-ai.com/examples/building-permit-trial.py'
curl -fLsS --max-time 30 -o nyc.json \
  'https://invariant-ai.com/blog/building-permit-data-apis.json'
curl -fLsS --max-time 30 -o seattle.json \
  'https://invariant-ai.com/blog/seattle-commercial-roof-permit-inspections.json'
python3 building-permit-trial.py nyc.json seattle.json > issuer-reference.json
```

The report lists nine distinct permit IDs across the samples. Keep work type rows when reviewing scope. Count distinct permit numbers when comparing coverage. A source filing number can group several permits.

| Trial | What to check |
| --- | --- |
| Brooklyn Army Terminal fit-out | Six rows represent four work permits and three filings. Two permit numbers repeat on both plumbing and sprinkler rows. |
| Brooklyn rooftop mechanical work | Inspect two equipment replacement permits and the related filings. One filing has a December 27, 2022 sign-off. The saved export has no sign-off date for the other. |
| Seattle roof work | Alki’s reroof is in the Building category and shows completed inspections. Meadowbrook’s reroof has an issue date and a blank completion date in the sample. The Lemieux Library record describes rooftop telecom work and has a completion date for that scope. |

Use [NYC’s DOB NOW Approved Permits](https://data.cityofnewyork.us/d/rbx6-tga4) and [Job Application Filings](https://data.cityofnewyork.us/d/w9ak-ipjd) for the Brooklyn records. [Seattle’s field definitions](https://data.seattle.gov/Built-Environment/Building-Permits/76t5-zqzr/about_data) explain the milestone used for its Completed Date.

## Compare a provider export with the same issuer snapshot

Map the provider’s output to the CSV header below. Use `NYC` or `SEATTLE` for the issuing jurisdiction, the issuer’s full permit number, and `YYYY-MM-DD` for dates. Include only permits the provider actually returned. Leave unavailable facts blank and use `true` or `false` for roof replacement scope when the evidence supports it.

```csv
jurisdiction,permit_id,building_id,filing_id,issued_on,expires_on,filing_signed_off_on,inspections_completed_on,roof_replacement_scope
```

```bash
python3 building-permit-trial.py nyc.json seattle.json \
  --provider provider.csv > permit-comparison.json
```

The report distinguishes missing permits, missing fields, conflicting values across duplicate rows, and differences from the issuer snapshot. A provider value paired with a blank issuer field needs another source. IDs outside the selected sample are counted separately. Field differences tell you what to investigate for these cases. To evaluate market coverage, repeat the trial on a defined set of offices, date ranges and work types.

## Keep dated copies when permit records change

The Brooklyn permit `B01440157-S1-PL` shows why the retrieval date matters. Its two work type rows in the November 23, 2026 export showed an expiration date of December 4, 2026. Rerunning the city query on November 25 returned October 15, 2027. Both exports retained the October 15, 2026 issue date. This establishes a change between the two saved observations. Check the city’s permit history for the timing and reason for the change. [Query the work permit in NYC Open Data](https://data.cityofnewyork.us/resource/rbx6-tga4.json?work_permit=B01440157-S1-PL).
