# US Code Violations Feed: Building and Housing by City (`datacrate/us-code-violations-feed`) Actor

Open building and housing code violations from official city open-data portals (Chicago, San Francisco, Seattle, Austin) in one schema: category, status, address, dates. Property-level only, no owner data. Delta mode returns only new records.

- **URL**: https://apify.com/datacrate/us-code-violations-feed.md
- **Developed by:** [Data Crate](https://apify.com/datacrate) (community)
- **Categories:** Lead generation, Real estate
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.60 / 1,000 violation returneds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## US Code Violations Feed – building and housing violations by city, from official open data

Get open **building and housing code violations** for **Chicago, San Francisco, Seattle and Austin** in one clean schema: violation date, code, description, a derived **category** (structural, fire-safety, sanitation, zoning, electrical, plumbing, other), open/closed status, inspection status, property address and coordinates. Data comes straight from each city's official open-data portal (Socrata API). No scraping, no browser, no API key, no proxies.

It is built for roofers, restoration and repair contractors, insurers, property managers, real-estate investors doing area research, and analysts who need one consistent schema across cities.

**Property-level data only.** Rows describe a violation at an address. This actor does not return owner, respondent, complainant, tenant or inspector names, phone numbers or email addresses, and it does not look up owners or do skip tracing. It has no link to any owner-lookup service. If you need owner contact data, this is not that tool.

**First run:** press Start. The prefill (Chicago and San Francisco, open violations from the last 30 days, 100 records) costs about **$0.20 at $0.002 per record** and finishes in under a minute. **Empty input also works:** you get 100 open records from the last 30 days spread across all four cities.

### What you can do with it

- **Daily lead list:** schedule the actor with `onlyNewSinceLastRun: true` and pull only records you have not seen. Every row carries `isNew` and `firstSeenAt`.
- **Trade filters:** `categories: ["structural"]` for roof, wall, stair and porch work; `["plumbing","electrical"]` for trade contractors; `["sanitation"]` for cleanup and pest-control services.
- **Keyword search:** `keywords: ["roof", "mold", "stairs"]` matches description, code and address (any keyword).
- **Open vs closed:** `status: "open"` for unresolved cases, `"closed"` for resolved, `"any"` for both.
- **Market research:** compare violation volume by city and category over `daysBack` up to 365.

### Input

| Field | What it does |
|---|---|
| `cities` | `chicago`, `san-francisco`, `seattle`, `austin`. Empty = all four |
| `status` | `open` (default), `closed` or `any` |
| `daysBack` | Records dated in the last N days (1 to 365, default 30). The date is the violation, notice or case-opened date |
| `categories` | `structural`, `fire-safety`, `sanitation`, `zoning`, `electrical`, `plumbing`, `other`. Empty = all |
| `keywords` | Words to match in description, code or address (any match). Empty = no filter |
| `onlyNewSinceLastRun`, `stateKey` | Delta mode: skip records already returned by an earlier run with the same State name. The first run returns everything |
| `maxItems` | Cap on records (default 100). You pay per record. Results are newest first and spread evenly across the selected cities |

Example: `{ "cities": ["chicago", "san-francisco"], "status": "open", "daysBack": 30, "maxItems": 100 }`

Roofing leads example: `{ "categories": ["structural"], "keywords": ["roof"], "daysBack": 30, "onlyNewSinceLastRun": true, "maxItems": 500 }`

### Output

```json
{
  "city": "chicago",
  "cityName": "Chicago",
  "state": "IL",
  "violationId": "7569539",
  "recordKind": "violation",
  "violationDate": "2026-11-16",
  "code": "CN061014",
  "description": "Repair Exterior Wall",
  "ordinance": "Failed to maintain the exterior walls of a building or structure free from holes, breaks, loose or rotting boards ... (13-196-530(b), 13-196-641)",
  "category": "structural",
  "status": "Open",
  "statusGroup": "open",
  "statusDate": null,
  "inspectionStatus": "Failed",
  "address": "8928 S COMMERCIAL AVE",
  "zip": null,
  "latitude": 41.7328422114,
  "longitude": -87.551469154,
  "isNew": null,
  "firstSeenAt": "2026-11-18T19:59:04.906Z",
  "sourceDataset": "https://data.cityofchicago.org/resource/22u3-xenr.json",
  "sourceUrl": "https://data.cityofchicago.org/resource/22u3-xenr.json",
  "source": "City of Chicago, Building Violations (data.cityofchicago.org/resource/22u3-xenr). License: ... This data has been modified for use from its original source, www.cityofchicago.org ...",
  "license": "City of Chicago Data Terms of Use (the dataset has no license field; the portal points to the Terms of Use)",
  "attribution": "City of Chicago, Building Violations (data.cityofchicago.org/resource/22u3-xenr)"
}
```

What each city's record is:

| City | Dataset | `recordKind` | Notes |
|---|---|---|---|
| Chicago | Building Violations (`22u3-xenr`), Department of Buildings | `violation` | One row per violation. Includes the city's code and ordinance text. No ZIP column in the source |
| San Francisco | Notices of Violation issued by the Department of Building Inspection (`nbtm-fbw5`) | `notice-of-violation` | One row per NOV item. `code` is the section cited |
| Seattle | Code Complaints and Violations (`ez4a-iug7`), filtered to Notices of Violation and Citations only | `notice-of-violation` / `citation` | Plain complaints from the public are excluded. Free text is kept only when it is a short label (140 characters or less), because longer text can be a citizen's narrative |
| Austin | Austin Code Complaint Cases (`6wtj-zbtb`), Development Services | `complaint-case` | These are code-enforcement cases opened on a complaint, with the alleged violation type (property abatement, structure condition, land use, work without permit). Austin does not publish a violation code here |

Notes on fields:

- `category` is our normalization from the city's own wording (and bureau or section where the city has one). Cities use very different wording, so `other` is common; use `keywords` for exact searches.
- `status` is the city's own wording. `statusGroup` is our `open` / `closed` / `other` grouping. Chicago `Complied` = closed; San Francisco `active` = open; Austin `Active` and `Pending` = open; Seattle statuses such as `Completed`, `Closed` and `Compliance Achieved` = closed.
- Dates are the city's local calendar dates (`YYYY-MM-DD`). A violation's status can change after it is first seen; delta mode only tracks which record ids you have already received, not later status changes.
- `isNew` is `null` until a baseline exists for your State name, then `true` or `false`.

### Terms and licence evidence

Everything is read from the cities' official open-data portals through their documented SODA API (`/resource/<id>.json`). Licence fields were read from each dataset's own `/api/views/<id>.json` metadata and the portal terms on 2026-11-18:

| City | Dataset | Licence (from the dataset metadata and portal terms) |
|---|---|---|
| Chicago | `data.cityofchicago.org/resource/22u3-xenr` (Building Violations) | No licence field is set on this dataset. The portal's terms apply: [Chicago Data Terms of Use](https://www.chicago.gov/city/en/narr/foia/data_disclaimer.html) |
| San Francisco | `data.sf.gov/resource/nbtm-fbw5` (Notices of Violation) | "Open Data Commons Public Domain Dedication and License" (PDDL 1.0), terms link `opendatacommons.org/licenses/pddl/1.0/` |
| Seattle | `data.seattle.gov/resource/ez4a-iug7` (Code Complaints and Violations) | "Public Domain" |
| Austin | `data.austintexas.gov/resource/6wtj-zbtb` (Austin Code Complaint Cases) | "Public Domain U.S. Government" (`usa.gov/government-works`). The [City of Austin Open Data Terms of Use](https://data.austintexas.gov/stories/s/ranj-cccq) say data on the portal is "offered free and without restriction" and, unless noted in metadata, in the public domain |

**Chicago required disclaimer.** The Chicago Data Terms of Use ask anyone who provides an application using the data to include this notice. It applies to every Chicago row this actor returns and is repeated in each row's `source` field:

> This site provides applications using data that has been modified for use from its original source, www.cityofchicago.org, the official website of the City of Chicago. The City of Chicago makes no claims as to the content, accuracy, timeliness, or completeness of any of the data provided at this site. The data provided at this site is subject to change at any time. It is understood that the data provided at this site is being used at one's own risk.

The Chicago terms also say the data is provided "on an 'as is' basis" and that the City may require a user to stop using the data. The dataset's own description says the records are "historical in nature and should not be relied upon for real estate transactions", and that it "contains cases where a respondent has been found to be liable as well as cases where the respondent has been found to be not liable". Do not use this data as proof of an enforcement action against a person or property.

**Austin terms.** The Austin terms ask for credit to the City of Austin and the source department, and say the user agrees not to "re-identify the data or to contact individuals whose information is represented by the data". This actor returns no individuals; please do not combine it with other data to identify or contact people. Each Austin row repeats that notice in `source`.

**Robots and rate limits.** All four portals serve the standard Socrata `robots.txt`: `Crawl-delay: 1`, with only `/browse?...` style pages disallowed. `/resource/*.json` is not disallowed. The actor sends at most one request per second, identifies itself as `datacrate-actor/1.0`, and uses no app token. A typical run makes 1 to 4 requests per city.

**Personal data.** The actor selects only the columns it needs. It never reads owner, respondent, complainant, tenant, applicant or inspector fields (Chicago `violation_inspector_comments` and `inspector_id`, Austin `inspector` names and phone numbers, free-text complaint narratives are all left out). Remaining free text (San Francisco inspection notes, Chicago ordinance text, Seattle short labels) has phone numbers and email addresses removed before output. Free text written by city staff can still occasionally mention a business or person; treat it accordingly and follow the laws that apply to your outreach.

**Not included, on purpose.** New York City and Los Angeles are not in this version because we could not read open-data terms that confirm commercial reuse for their datasets. They can be added once those terms are confirmed. Not affiliated with or endorsed by any city or government.

### FAQ

**How fresh is the data?** Each portal updates on its own schedule, usually daily. When we tested on 2026-11-18, Chicago, San Francisco, Seattle and Austin all had records dated 1 to 2 days earlier.

**Why are some descriptions short?** Chicago, Seattle and Austin publish a violation label rather than a full narrative. San Francisco includes the inspector's item text.

**Can I get owner names or contact details?** No. This actor is property-level only and does no owner lookup or skip tracing.

**Can I get more than 100 records?** Yes, raise `maxItems`. Chicago alone has thousands of open violations per month.

**What if a city portal is down?** The other cities still return. The run log and the `SUMMARY` record in the key-value store show which cities failed. The run fails only if every selected city fails.

### Integrations

- **Schedule** the actor daily with `onlyNewSinceLastRun: true` for a fresh list.
- **Webhook** on run success to push new records into your CRM, Slack or Zapier/Make.
- **API and MCP:** call the actor from the Apify API, or use it as a tool in AI agents through the Apify MCP server.
- Export the dataset as JSON, CSV or Excel from the Console.

### Pricing

Pay per result: **$0.002 per record** ($2 per 1,000), no start fee. Higher Apify plans get lower per-record prices. Set `maxItems` to cap spend; the first run above costs about $0.20.

### Related actors

- **US Building Permits Feed** (`datacrate/us-building-permits-feed`): permits from the same city portals, for contractor leads.

### Changelog

- **1.0** First version: Chicago, San Francisco, Seattle, Austin; derived category; open/closed filter; delta mode.

# Actor input Schema

## `cities` (type: `array`):

Any of: chicago, san-francisco, seattle, austin. Empty = all four.

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

open = violation or case not yet resolved, closed = resolved, any = both.

## `daysBack` (type: `integer`):

Only records dated in the last N days (1 to 365). The date is the violation, notice or case-opened date.

## `categories` (type: `array`):

Keep only these derived categories: structural, fire-safety, sanitation, zoning, electrical, plumbing, other. Empty = all.

## `keywords` (type: `array`):

Keep only records whose description, code or address contains any of these words (case-insensitive), e.g. "roof", "mold", "stairs".

## `onlyNewSinceLastRun` (type: `boolean`):

Return only records not returned by a previous run with the same State name. The first run returns everything. Every row carries isNew and firstSeenAt.

## `stateKey` (type: `string`):

Name of the saved list of already-returned records. Use different names for different watchlists.

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

Stop after this many records (newest first, spread across the selected cities). You are charged per record returned.

## Actor input object example

```json
{
  "cities": [
    "chicago",
    "san-francisco"
  ],
  "status": "open",
  "daysBack": 30,
  "categories": [],
  "keywords": [],
  "onlyNewSinceLastRun": false,
  "stateKey": "default",
  "maxItems": 100
}
```

# Actor output Schema

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

One row per violation, notice or case (default dataset items).

# 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 = {
    "cities": [
        "chicago",
        "san-francisco"
    ],
    "status": "open",
    "daysBack": 30,
    "maxItems": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("datacrate/us-code-violations-feed").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 = {
    "cities": [
        "chicago",
        "san-francisco",
    ],
    "status": "open",
    "daysBack": 30,
    "maxItems": 100,
}

# Run the Actor and wait for it to finish
run = client.actor("datacrate/us-code-violations-feed").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 '{
  "cities": [
    "chicago",
    "san-francisco"
  ],
  "status": "open",
  "daysBack": 30,
  "maxItems": 100
}' |
apify call datacrate/us-code-violations-feed --silent --output-dataset

```

## MCP server setup

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

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/2KUUq2YHWQPbEagR4/builds/c7bNIOKeFbYyQyLP1/openapi.json
