# US Building Permits & Code Violations Leads (8 Metros) (`vesper_studio/us-permits-code-violations-leads`) Actor

Stream fresh US building permits & code violations from official Socrata & ArcGIS Open Data (Chicago, Austin, Seattle, SF, NYC, LA, DC, Atlanta). Auto-qualified by trade (Roofing, Solar, HVAC, Electrical, Remodel), LLC vs. individual owner, and leadPriorityScore. Zero proxies, 512 MB.

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

## Pricing

$10.00 / 1,000 qualified property permit or code violation leads

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?

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 Building Permits & Code Violations Leads (`us-permits-code-violations-leads`)

Stream **fresh, hyper-local US building permits and open municipal code violations** directly from official **Socrata SODA** & **ArcGIS REST** Open Data portals — auto-qualified by trade (`ROOFING`, `SOLAR`, `HVAC`, `PLUMBING`, `ELECTRICAL`, `REMODEL`, `DEMOLITION`, `NEW_CONSTRUCTION`, `DISTRESSED_VIOLATION`), owner entity type (`LLC` / `TRUST` / `CORPORATION` vs. `INDIVIDUAL`), and **`lead_priority_score` (0–100)**.

Built for **real estate wholesalers, cash buyers, roofing contractors, solar installers, HVAC companies, and general contractors** who want first-mover municipal property signals without paying $50–$1,250/month for PropStream/BatchData subscriptions or risking fragile HTML scraping.

***

### Why Municipal Permits & Code Violations?

| Signal Type | Who Buys These Leads | Why It Converts |
| :--- | :--- | :--- |
| **Open Code Violations (`code_violations`)** | **Real Estate Wholesalers, Cash Buyers, Fix-and-Flip Investors, Property Preservation** | Unresolved structural, roof leak, lead paint, vacant/unsafe, and nuisance citations create immediate seller motivation — often weeks before MLS or foreclosure filings. |
| **Roofing / Solar / HVAC / Plumbing Permits (`permits`)** | **Roofing, Solar, HVAC, Plumbing & Home Services Teams, Storm Restoration** | Identifies homeowners actively investing in property upgrades, neighboring homes in storm/permit clusters, active licensed contractors, and cross-sell opportunities (e.g., new roof -> solar, HVAC/electrical panel upgrade -> solar battery). |
| **Demolition & New Construction / High-Ticket Remodels** | **Building Material Suppliers, Subcontractors, Commercial Lenders & Insurance** | Captures `$50K–$1M+` permitted projects with contractor names, owner entities (`LLC` vs. `INDIVIDUAL`), and parcel/ZIP coordinates. |

***

### Supported Official Open Data Portals (Zero Proxy, 512 MB RAM)

| Metro | State | Platform | Building Permits Dataset | Code Violations Dataset |
| :--- | :--- | :--- | :--- | :--- |
| **Chicago, IL** (`chicago`) | IL | Socrata (`data.cityofchicago.org`) | `ydr8-5enu` (includes Owner, Contractor, Cost) | `22u3-xenr` (Building Violations, `OPEN` filter) |
| **Austin, TX** (`austin`) | TX | Socrata (`data.austintexas.gov`) | `3syk-w9eu` (includes Contractor Company, Phone, Trade) | — |
| **Seattle, WA** (`seattle`) | WA | Socrata (`data.seattle.gov`) | `76t5-zqzr` (includes Estimated Cost, Units, Link) | `ez4a-iug7` (Code Complaints & Violations) |
| **San Francisco, CA** (`san_francisco`) | CA | Socrata (`data.sfgov.org`) | `i98e-djp9` (DBI Permits, Estimated & Revised Cost) | `nbtm-fbw5` (DBI Notices of Violation) |
| **New York City, NY** (`nyc`) | NY | Socrata (`data.cityofnewyork.us`) | `rbx6-tga4` (DOB NOW Permits, Owner Name/LLC, Cost) | `wvxf-dwi5` (HPD Housing Maintenance Violations) |
| **Los Angeles, CA** (`los_angeles`) | CA | Socrata (`data.lacity.org`) | `pi9x-tg5x` (LADBS Permits, Solar/EV flags, Valuation) | `u82d-eh7z` (Open Code Enforcement Cases) |
| **Washington, DC** (`washington_dc`) | DC | ArcGIS REST (`maps2.dcgis.dc.gov`) | `FEEDS/DCRA/FeatureServer/18` (includes `OWNER_NAME`) | — |
| **Atlanta Metro / DeKalb, GA** (`dekalb_atlanta`) | GA | ArcGIS REST (`dcgis.dekalbcountyga.gov`) | — | `Hansen/CodeEnforcementCasesInspections/FeatureServer/0` |

> **Streaming Architecture**: Uses `httpx` HTTP/2 + `ijson` streaming JSON parsing with **server-side SoQL / ArcGIS SQL pushdown** (`issuedSinceDays`, `tradeCategories`, `minEstimatedCost`, `openViolationsOnly`) so multi-million-row city portals are filtered on the server and processed well within **512 MB RAM**.

***

### Daily CRM / n8n Automation (Delta Mode + Pay-Per-Event)

1. **Schedule a daily morning run** (e.g., 6:00 AM local) with `"onlyNew": true`.
2. Seen keys (`city:record_type:record_id`) are persisted in the named Apify Key-Value Store (`us-permits-code-violations-leads-state`), including safe checkpointing on `ABORTING`.
3. Only **brand-new** permits and code violations are pushed to the dataset and charged via Pay-Per-Event (`property-signal` in batches of 25, respecting `maxTotalChargeUsd`).
4. Pipe the Apify Dataset webhook directly into **n8n, Make, GoHighLevel, Podio, HubSpot, or BatchLeads** for skip-tracing and outreach.

***

### Example Input

```json
{
    "cities": ["chicago", "austin", "seattle", "nyc", "washington_dc"],
    "recordTypes": ["permits", "code_violations"],
    "issuedSinceDays": 14,
    "tradeCategories": ["roofing", "solar", "hvac"],
    "minEstimatedCost": 5000,
    "openViolationsOnly": true,
    "onlyNew": true,
    "maxItems": 200
}
```

### Example Output (`PropertySignal`)

```json
{
    "signal_id": "chicago:permits:B200519842",
    "city": "chicago",
    "city_name": "Chicago, IL",
    "state": "IL",
    "source_platform": "socrata",
    "dataset_id": "ydr8-5enu",
    "record_type": "permits",
    "record_id": "B200519842",
    "permit_number": "B200519842",
    "issue_date": "2026-11-12",
    "status": "ACTIVE",
    "is_open_violation": null,
    "work_type": "PERMIT – EXPRESS PERMIT PROGRAM",
    "work_description": "SCOPE: ROOF REPLACEMENT. AREA: 2400 SQ. FT. ROOF COVERING: ASPHALT SHINGLES",
    "estimated_cost": 42791.0,
    "address": "1268 W 73RD ST",
    "zip": "60636",
    "latitude": 41.7614,
    "longitude": -87.6562,
    "contractor_name": "MIDWEST ROOFING PROS INC",
    "contractor_phone": null,
    "owner_name": "PORTER OLIVIA M",
    "owner_entity_type": "INDIVIDUAL",
    "is_corporate_owner": false,
    "primary_trade": "ROOFING",
    "matched_trades": ["roofing"],
    "lead_priority_score": 90,
    "target_buyer_segments": ["ROOFING_CONTRACTOR", "STORM_RESTORATION", "HOME_SERVICES"],
    "score_reasons": [
        "ultra_fresh_0_3d",
        "high_intent_trade:ROOFING",
        "project_value_20k_plus",
        "has_owner_name",
        "complete_address_zip"
    ],
    "source_url": "https://data.cityofchicago.org/Buildings/Building-Permits/ydr8-5enu",
    "fetched_at": "2026-11-14T00:25:00+00:00"
}
```

***

### Local Development & Tests

```bash
python -m pytest -q
```

Optional environment variable:

- `SOCRATA_APP_TOKEN`: Optional Socrata API token for higher rate limits on large multi-city pulls.

# Actor input Schema

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

Select which US municipal open data portals to query. Leave empty to query all 8 supported metros across Socrata SODA & ArcGIS REST.

## `recordTypes` (type: `array`):

Select building permits (home services, subcontractors, material suppliers) and/or municipal code violations (cash buyers, real estate wholesalers, distress investors).

## `issuedSinceDays` (type: `integer`):

Server-side SoQL / ArcGIS date pushdown window: fetch permits issued or violations opened within the last N days.

## `tradeCategories` (type: `array`):

Optional filter pushed down to SoQL/ArcGIS and verified locally. Leave empty to return all trades and distressed code violations.

## `minEstimatedCost` (type: `number`):

Minimum estimated construction valuation for building permits (pushed down via SoQL where available). Set 0 to include all permits regardless of reported valuation.

## `openViolationsOnly` (type: `boolean`):

When enabled, excludes closed/completed/dismissed code violations so cash buyers and wholesalers only receive active distressed properties.

## `onlyNew` (type: `boolean`):

Persist seen (city + record_type + record_id) keys in a named Apify Key-Value Store and skip already-delivered signals on subsequent scheduled runs (ideal for daily n8n / Make / CRM sync).

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

Upper limit on qualified PropertySignal records pushed to the dataset (ranked by lead_priority_score).

## Actor input object example

```json
{
  "cities": [
    "chicago",
    "austin",
    "seattle",
    "nyc",
    "washington_dc"
  ],
  "recordTypes": [
    "permits",
    "code_violations"
  ],
  "issuedSinceDays": 14,
  "tradeCategories": [],
  "minEstimatedCost": 0,
  "openViolationsOnly": true,
  "onlyNew": false,
  "maxItems": 100
}
```

# Actor output Schema

## `signals` (type: `string`):

Unified PropertySignal leads from official US municipal building permit and code violation portals, classified by trade (ROOFING, SOLAR, HVAC, PLUMBING, DEMOLITION, NEW_CONSTRUCTION, REMODEL, DISTRESSED_VIOLATION), owner entity type (LLC/TRUST/INC vs INDIVIDUAL), and lead_priority_score (0-100). Append ?format=csv or ?format=xlsx for CRM/skip-tracing import.

## `summary` (type: `string`):

Aggregated counts by city, record type, trade classification, owner entity type, delta skips, and billing guardrails.

# 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",
        "austin",
        "seattle",
        "nyc",
        "washington_dc"
    ],
    "recordTypes": [
        "permits",
        "code_violations"
    ],
    "issuedSinceDays": 14,
    "minEstimatedCost": 0,
    "openViolationsOnly": true,
    "onlyNew": false,
    "maxItems": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("vesper_studio/us-permits-code-violations-leads").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",
        "austin",
        "seattle",
        "nyc",
        "washington_dc",
    ],
    "recordTypes": [
        "permits",
        "code_violations",
    ],
    "issuedSinceDays": 14,
    "minEstimatedCost": 0,
    "openViolationsOnly": True,
    "onlyNew": False,
    "maxItems": 100,
}

# Run the Actor and wait for it to finish
run = client.actor("vesper_studio/us-permits-code-violations-leads").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",
    "austin",
    "seattle",
    "nyc",
    "washington_dc"
  ],
  "recordTypes": [
    "permits",
    "code_violations"
  ],
  "issuedSinceDays": 14,
  "minEstimatedCost": 0,
  "openViolationsOnly": true,
  "onlyNew": false,
  "maxItems": 100
}' |
apify call vesper_studio/us-permits-code-violations-leads --silent --output-dataset

```

## MCP server setup

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

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/jHXRundabh2pZA20r/builds/XqwyB0SakEoigStzQ/openapi.json
