# Chicago Building Violations (`j0401/chicago-violations`) Actor

Chicago building code violations (public open data, 2.03M records, daily): the violation code, description and ordinance, the inspector's comments, the inspection that produced it, and the property address with lat/lon. Filter by status/category/bureau/code/date or pull the daily change stream.

- **URL**: https://apify.com/j0401/chicago-violations.md
- **Developed by:** [Wenhao Yang](https://apify.com/j0401) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.10 / 1,000 chicago violation 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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Chicago Building Violations

Chicago publishes every building-code violation it writes - over two million of them - as open data. This actor turns that register into a **charged-per-record lookup, filter and aggregate tool**: pull the violations at an address, sweep a bureau's caseload, isolate the open cases, or follow the daily change stream to see what the buildings department touched today.

**Built for:** property and title diligence, real-estate and construction underwriting, code-compliance screening, and anyone who needs the **code-enforcement record behind a Chicago address** - not a keyword match against a street name.

### What it covers

**2,027,808 violations** - every code violation on file, spanning the department's own bureaus:

| Bureau | Violations |
|---|---|
| Conservation | 1,333,299 |
| Special Task Force | 148,295 |
| Elevator | 135,695 |
| Demolition | 119,476 |
| Electrical | 42,820 |
| Boiler | 40,416 |
| Plumbing | 39,617 |
| New Construction | 39,121 |
| Ventilation | 36,631 |
| Refrigeration | 32,032 |
| Special Inspection Program / Signs / Iron / Water / Construction Equipment | ~60,400 |

and why each inspection happened - **COMPLAINT (1,430,270)**, PERIODIC (492,812), PERMIT (102,133), REGISTRATION (2,593).

Each violation carries real depth, not just a code:

- the **violation code** (100% populated - `CN190019`, `EV1110`, `CN061014`, ), its **plain-language description** (2,013,116 rows), and the **municipal ordinance** citation it falls under (1,968,752)
- the **inspector's own comments** on the finding (1,837,142 rows)
- the **inspection** that produced it: number, category, status, and the **bureau** that ran it
- the **property**: full street address (**100%, 174,821 distinct addresses**), street number/direction/name/type, property group, SSA, and **lat/lon** (2,025,788)

### The fine print that matters

Status is exactly three source values - **OPEN (1,159,140, still outstanding)**, **COMPLIED (861,525, resolved)** and **NO ENTRY (7,143, inspector couldn't gain access)** - matched as exact values. The **daily change stream** is real: `violation_last_modified_date` is a per-row timestamp, so **mode=delta** returns what the department actually touched since a date (1,210 rows in the last 7 days).

Two source quirks are handled honestly. The `inspection_waived` column is **'N' on all 2.03M rows** - a dead field, not surfaced. And the `violation_location` column (a short free-text note like "rear porch") is filled on **only ~49%** of rows - surfaced as-is and never pitched as a location field; the real geocoding is latitude/longitude, present on 99.9%.

One boundary stated plainly: Chicago's **building-permit register stores street parts separately and has no address column**, so the violationpermit relationship is a **fuzzy address / lat-lon match, not an id join**. This actor gives you the violation record complete; joining it to a permit is address work, not a key lookup.

### Typical questions

- "Every **open** violation at **200 E Garfield Blvd**."
- "**Elevator** bureau violations filed this year."
- "**Complaint-driven** inspections that **FAILED** in Chicago."
- "Violations under code **EV1110**."
- "What did the buildings department **change since yesterday**?" (`mode=delta`)
- "Aggregate the register by **bureau**, **category** or **status**."

### Inputs

| Input | What it does |
|---|---|
| `mode` | `rows` (default) / `delta` (change stream) / `aggregate` |
| `status` / `category` / `inspectionStatus` | open vs resolved; why inspected; inspection outcome |
| `bureau` | which department unit |
| `violationCode` | exact code |
| `address` / `streetName` | where |
| `dateFrom` / `dateTo` / `changedSince` | violation-date range, and the change window |
| `groupBy` | aggregate over status / category / bureau / inspectionStatus / code |
| `maxResults` | cap records (default 200) |

**Default run = the 200 most recent violations** - fast for the daily auto-test. For a targeted query add a filter; for a broad view use `aggregate`.

### Low cost

**From $0.0001 per record** - billed only for the rows you use, at the platform floor. Cost scales with what you pull, not with the size of the register, and because each record is metered individually there's no per-run charge cap to hit on a big pull.

The traps in this register are the silent ones. The status column carries a value - **`NO ENTRY`** - that means the inspector *couldn't look*, which a filter written for open/closed quietly files under neither; the **change timestamp and the violation date are different columns**, so "what the department touched since yesterday" and "what was filed since yesterday" are different questions (1,210 rows were modified in the last seven days, while 614 new ones were filed - the two axes move at different rates), and a single date filter conflates them; and the **location note is present on less than half the file**, so treating it as the location drops half the register. Normalizing the three-valued status, the separate change column and the half-empty note into a schema where an `address` / `status=OPEN` / `bureau` query returns exactly the violations you mean - and `mode=delta` returns the true daily delta - is the actual product. Every pull is integrity-checked against the register's known shape, so a degraded source fails loudly instead of returning bad rows.

### Source

- [City of Chicago: Building Violations](https://data.cityofchicago.org/Buildings/Building-Violations/22u3-xenr) - the city's full violation register, refreshed daily. Public open data. Records are the city's own published fields; a violation is an alleged code violation, not a court finding.

# Actor input Schema

## `mode` (type: `string`):

rows = violations matching your filters (default). delta = the daily change stream: rows the buildings department modified since `changedSince` (any other filters still apply). aggregate = one count row per group (see groupBy).

## `status` (type: `string`):

Violation status. OPEN = still outstanding (~1.16M); COMPLIED = resolved; NO ENTRY = inspector could not gain access. Blank = any.

## `category` (type: `string`):

Why the inspection happened: COMPLAINT (1.43M), PERIODIC (493k), PERMIT (102k), REGISTRATION (2.6k). Blank = any.

## `bureau` (type: `string`):

Bureau substring: CONSERVATION (1.33M), SPECIAL TASK FORCE, ELEVATOR, DEMOLITION, ELECTRICAL, BOILER, PLUMBING, NEW CONSTRUCTION, VENTILATION, REFRIGERATION. Blank = any.

## `violationCode` (type: `string`):

Exact violation code, e.g. 'EV1110', 'CN190019'. Blank = any.

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

Outcome of the inspection that produced the violation. Blank = any.

## `address` (type: `string`):

Street address substring, e.g. 'MICHIGAN' or 'GARFIELD'. Matches the full street address.

## `streetName` (type: `string`):

Street name only.

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

Only violations dated on/after this date (YYYY-MM-DD).

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

Only violations dated before this date (YYYY-MM-DD).

## `changedSince` (type: `string`):

Only rows the department modified on/after this date (YYYY-MM-DD). Use with mode=delta for the change stream; blank in delta mode = last 24h.

## `groupBy` (type: `string`):

Which dimension to aggregate over. status -> open vs resolved; category -> why inspected; bureau -> which unit.

## `maxResults` (type: `integer`):

Cap the number of records pushed (0 = up to ~10k per run; each record is metered individually, so there is no per-run charge cap). Aggregate mode returns every group; maxResults applies to rows only.

## Actor input object example

```json
{
  "mode": "rows",
  "status": "",
  "category": "",
  "bureau": "",
  "violationCode": "",
  "inspectionStatus": "",
  "address": "",
  "streetName": "",
  "dateFrom": "",
  "dateTo": "",
  "changedSince": "",
  "groupBy": "status",
  "maxResults": 50
}
```

# Actor output Schema

## `recordsUrl` (type: `string`):

Chicago building violation records or aggregates - as JSON

## `datasetUrl` (type: `string`):

No description

## `runUrl` (type: `string`):

No description

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("j0401/chicago-violations").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("j0401/chicago-violations").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 '{}' |
apify call j0401/chicago-violations --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,j0401/chicago-violations"
        }
    }
}
```

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/csI5xyrXfgAV3pzqI/builds/FEkma4mdlRjvEnDgg/openapi.json
