# NYC Building Violations & Risk Score (`nexus-ai-solutions/nyc-building-violations-risk-score`) Actor

Look up New York City buildings by address, BBL, or management company and return normalized open-violation counts, overdue Class C counts, recent DOB job filings, and a transparent risk score built only from public NYC Open Data.

- **URL**: https://apify.com/nexus-ai-solutions/nyc-building-violations-risk-score.md
- **Developed by:** [Nexus AI Solutions](https://apify.com/nexus-ai-solutions) (community)
- **Categories:** Real estate, Lead generation, Business
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/store.md#pay-per-usage

## 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

## NYC Building Violations & Risk Score

An [Apify](https://apify.com) Actor from [Nexus AI Solutions](https://getnexusaisolutions.com) that looks up New York City tax lots and returns a clean, normalized row of public housing and buildings records.

This Actor uses only public NYC Open Data (Socrata) APIs and NYC Planning Labs GeoSearch. It does not scrape private sites, and it does not invent counts. Every number is a count of rows returned by the City's datasets at the time of the run.

It is **not** an official NYC grade, **not** legal advice, and **not** a prediction of future harm or liability. One tax lot (BBL) can cover more than one building or address, so counts are lot-level, not unit-level.

### What it does

Give the Actor one or more of:

- Street **addresses** (resolved to a BBL; the house number must match)
- **BBLs** (10-digit borough-block-lot, hyphens optional)
- An **owner or management company** name (matched against the corporation name on active HPD multiple-dwelling registrations)
- A **borough** plus filters, or **index mode**, to list lots with the most open HPD Class C violations

For each lot it returns:

| Field | Meaning |
| --- | --- |
| `address`, `borough`, `bbl`, `bin` | Lot identity |
| `management_company` | Corporation name from HPD registration contacts (personal names are not requested or returned) |
| `open_hpd_total`, `open_class_a/b/c/i` | Open Housing Maintenance Code violations (`wvxf-dwi5`) |
| `overdue_class_c` | Open Class C rows whose certify-by or correct-by date is already past |
| `dob_active`, `ecb_active`, `ecb_in_default` | Active DOB violations (`3h2n-5cm9`) and ECB violations (`6bgk-3dad`) |
| `recent_dob_filings` | Job filings in the last 365 days from BIS (`ic3t-wcy2`) and DOB NOW (`w9ak-ipjd`) |
| `sr311_window` | 311 requests in the chosen lookback window (`erm2-nwe9`) |
| `risk_score`, `risk_tier` | Transparent heuristic described below |
| `fetched_at` | Timestamp in America/New_York |

### Example input

```json
{
  "addresses": ["950 Woodycrest Avenue, Bronx"],
  "bbls": ["2025050150"],
  "managementCompany": "Livingston Management",
  "borough": "Bronx",
  "minOpenClassC": 0,
  "maxBuildings": 10,
  "days311": 90,
  "includeJobFilings": true,
  "indexMode": false
}
```

You do not need every field. Addresses alone are enough for a single-lot lookup. Company name + `maxBuildings` is the typical portfolio scan. `indexMode` with an optional borough lists the lots with the most open Class C violations, then enriches each one.

### Example output (shape)

Field values depend on what the City returns on the day you run it. This is the shape, not a cached result:

```json
{
  "address": "950 WOODYCREST AVENUE, BRONX, NEW YORK, NY, USA",
  "borough": "Bronx",
  "bbl": "2025050xxx",
  "open_hpd_total": 0,
  "open_class_c": 0,
  "overdue_class_c": 0,
  "open_class_b": 0,
  "dob_active": 0,
  "ecb_active": 0,
  "ecb_in_default": 0,
  "recent_dob_filings": 0,
  "sr311_window": 0,
  "risk_score": 0,
  "risk_tier": "Low",
  "fetched_at": "2026-11-19T10:00:00-05:00",
  "risk_score_note": "Heuristic lot score from public counts only. ..."
}
```

Run it locally (see below) against live APIs to see current numbers. Do not treat any count in marketing copy as a permanent statistic.

### Risk score

The score is a weighted sum of public counts, rounded to an integer:

| Component | Weight |
| --- | ---: |
| Open HPD Class C | 10 |
| Overdue open Class C | 8 (added on top of the Class C weight) |
| Open HPD Class B | 3 |
| Open HPD Class A | 1 |
| Active DOB violation | 4 |
| Active ECB violation | 4 |
| Active ECB in default | 6 (added on top of the ECB weight) |
| 311 requests in the window, capped at 50 | 0.1 |

Tiers: `Low` (0–19), `Elevated` (20–49), `High` (50–99), `Severe` (100+). Component values are included on each row as `risk_score_components`.

### Data sources

Confirmed against `data.cityofnewyork.us`:

- Housing Maintenance Code Violations — `wvxf-dwi5`
- DOB Violations — `3h2n-5cm9`
- DOB ECB Violations — `6bgk-3dad`
- 311 Service Requests from 2020 to Present — `erm2-nwe9`
- Housing Maintenance Code Violations, NYCHA properties — `im9z-53hg` (no open/closed status; counted only when not marked issued in error)
- DOB Job Application Filings — `ic3t-wcy2`
- DOB NOW: Build – Job Application Filings — `w9ak-ipjd`
- HPD Registration Contacts — `feu5-w2e2` (corporation name only)
- HPD Multiple Dwelling Registrations — `tesw-yqqr`
- Address → BBL: [NYC Planning Labs GeoSearch](https://geosearch.planninglabs.nyc)

`9hiw-49pz` (DOB Licenses Filtered for Active) is a **person-level** license file. It has no BBL and is not included in these lot-level rows.

An optional Socrata app token may be supplied as the `SOCRATA_APP_TOKEN` environment variable for higher rate limits. It is not required for light use.

### Use cases

- **Property managers** — portfolio scan by management company, or a one-building brief for a new takeover.
- **Lenders and insurers** — lot-level open-hazard and overdue counts before a close or renewal.
- **Contractors** — buildings with overdue Class C work in a borough, as a public lead list.
- **Investors and researchers** — a normalized feed of HPD, DOB, ECB, 311, and recent filings without hand-joining the City's files.

### Suggested pay-per-result pricing

Set this in the Apify Console when you publish; this file is only a suggestion.

Each output row is one tax lot and typically requires several City API calls (geocode or registration lookup, HPD, DOB, ECB, 311, and optional filings). A starting point that matches that work:

- **Pay-per-result:** $0.03 to $0.05 per building row, plus Apify compute.
- **Rental (optional):** a modest monthly rental if you later offer a higher-volume plan, still billed per result for overage.

Do not advertise earnings, accuracy rates, or “typical” portfolio sizes. Price is set by the publisher and can be changed later. Publishing requires an Apify account (signup is separate from this repository).

### Run locally (no Apify account)

```bash
cd apify-nyc-building-risk
python3 -m pip install -r requirements.txt   # apify is optional for this path
python3 src/run_local.py \
  --address "950 Woodycrest Avenue, Bronx" \
  --address "2980 West 28th Street, Brooklyn" \
  --max-buildings 2 \
  --out examples/last-run.json
```

Or test a company name:

```bash
python3 src/run_local.py --management "Livingston Management" --borough Bronx --max-buildings 2
```

### Run on Apify

1. Create an Apify account and, in the Console, create a new Actor from this repository (or `apify push` once the Apify CLI is logged in).
2. Paste the example input, or point the Actor at your own addresses.
3. Set pay-per-result pricing in the store listing. The README text above can be used as the store description.

### Limitations

- Lot-level, not apartment-level.
- DOB and ECB have no reliable BBL column in older extracts; the Actor joins on borough, block, and lot with several zero-paddings.
- GeoSearch results are rejected when the house number does not match the input address.
- NYCHA inspection rows in `im9z-53hg` are recorded violations, not confirmed-open items.
- Index mode ranks lots by open Class C count only, then enriches the top rows. It is not a complete census of every NYC building.

Built for Nexus AI Solutions. Source data belongs to the City of New York.

# Actor input Schema

## `addresses` (type: `array`):

Street addresses to resolve via NYC Planning Labs GeoSearch. House number must match. You can include the borough in the string or set the borough field.

## `bbls` (type: `array`):

10-digit borough-block-lot identifiers (hyphens optional).

## `managementCompany` (type: `string`):

Looks up active HPD multiple-dwelling registrations whose contact corporation name contains this text (case-insensitive). Personal contact names are not returned.

## `borough` (type: `string`):

Optional borough filter for management-company and index lookups, and a hint for address geocoding.

## `minOpenClassC` (type: `integer`):

When set, skip buildings below this open Class C count. Also used with borough-only (index) mode.

## `maxBuildings` (type: `integer`):

Hard cap on output rows. Each building makes several NYC Open Data calls.

## `days311` (type: `integer`):

Window for 311 service requests (dataset erm2-nwe9, 2020 to present).

## `includeJobFilings` (type: `boolean`):

Add 365-day counts and a short list of recent filings from DOB Job Application Filings (ic3t-wcy2) and DOB NOW: Build (w9ak-ipjd). Company names only; personal applicant/owner names are not requested.

## `indexMode` (type: `boolean`):

If no addresses, BBLs, or company name are given, list the tax lots in the chosen borough (or citywide) with the most open HPD Class C violations, then enrich each up to maxBuildings.

## Actor input object example

```json
{
  "addresses": [
    "950 Woodycrest Avenue, Bronx"
  ],
  "borough": "",
  "minOpenClassC": 0,
  "maxBuildings": 25,
  "days311": 90,
  "includeJobFilings": true,
  "indexMode": false
}
```

# Actor output Schema

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

JSON items from the default dataset: one object per scored tax lot, including open HPD/DOB/ECB counts, filings, and a heuristic risk score.

# 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("nexus-ai-solutions/nyc-building-violations-risk-score").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("nexus-ai-solutions/nyc-building-violations-risk-score").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 nexus-ai-solutions/nyc-building-violations-risk-score --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,nexus-ai-solutions/nyc-building-violations-risk-score"
        }
    }
}
```

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/xSonMYMGw1Oh0tEaJ/builds/ibjmc0x9iNm9gZUXo/openapi.json
