# NYC HPD Housing Complaints - Heat, Plumbing & Sanitation (`j0401/nyc-hpd-complaints`) Actor

New York City housing complaints from HPD (public open data, 16.4M records): building and apartment, the reported condition by category and code, the emergency tier, received and closed dates and the outcome. Screen a building by HPD id, or filter by borough, category, type, status, ZIP or date.

- **URL**: https://apify.com/j0401/nyc-hpd-complaints.md
- **Developed by:** [Wenhao Yang](https://apify.com/j0401) (community)
- **Categories:** Business, Real estate, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.03 / 1,000 nyc hpd complaint records

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

## NYC HPD Housing Complaints - Heat, Plumbing & Sanitation

Every housing complaint and problem recorded by New York City's Department of Housing
Preservation and Development, from the City's open data. **16.4 million
complaint-problem records across ~9.0 million complaints** - what a tenant
reported, in which building and apartment, how urgent, and how it was resolved.

### Low cost

**From $0.00005 per record, down to $0.00003 at Gold.** Pay only for the
records you actually receive - the whole register stays queryable, you are
never billed for the scan behind it.

### What you get

One row per complaint problem:

- **Where** - the borough, house number, street, ZIP, apartment, block and lot,
  plus the BBL, BIN and community board
- **What** - the condition by category and code, from HEAT/HOT WATER and
  PLUMBING to PAINT/PLASTER and UNSANITARY CONDITION
- **How urgent** - the emergency tier: EMERGENCY, NON EMERGENCY, IMMEDIATE
  EMERGENCY, HAZARDOUS or (a handful of rows) REFERRAL
- **When** - the received date and the complaint/problem status dates (duration
  is the difference between them)
- **Where it stands** - the Open/Close status and the department's own outcome
  narrative
- **Who reported it** - whether the tenant stayed anonymous, and whether it is a
  duplicate of another complaint

The building id joins the HPD violations table, and the BBL joins the City's
property records.

### Filter it

- **Category** - `majorCategory="HEAT/HOT WATER"` for the most-reported condition.
- **Urgency** - `type="IMMEDIATE EMERGENCY"` for the most severe tier.
- **Status** - `problemStatus="OPEN"` for complaints not yet resolved.
- **Place** - `borough="BROOKLYN"`, `zip="11206"`, `street="BROADWAY"`.
- **One building** - `buildingId="374378"` for that building's complaints (up to
  2,000 per run; large buildings exceed this - add `dateFrom`/`dateTo` to page
  through the rest).
- **Period** - `dateFrom="2026-01-01"`, or `recentDays=30` for the last month.

### Example inputs

**Open heat complaints** - the most-reported category, still unresolved.

```json
{ "majorCategory": "HEAT/HOT WATER", "problemStatus": "OPEN", "maxResults": 50 }
```

**One building's record** - `buildingId` is the HPD key.

```json
{ "buildingId": "374378", "maxResults": 100 }
```

**Recent Brooklyn emergencies** - a borough, a tier and a window.

```json
{ "borough": "BROOKLYN", "type": "EMERGENCY", "recentDays": 90, "maxResults": 50 }
```

**How the complaints break down** - `mode=aggregate` counts per category.

```json
{ "mode": "aggregate", "groupBy": "majorCategory" }
```

### Or roll it up

Set `mode=aggregate` and get a count by **majorCategory**, **minorCategory**,
**borough**, **type**, **unitType**, **spaceType**, **nta** or either status.
Every group comes back - this mode is not cut off by `maxResults`.

### Then use it

- **Habitability / legal diligence** - a building's heat, plumbing and
  sanitation complaint history by `buildingId`.
- **Underwriting** - complaint density and unresolved load as a property risk
  signal.
- **Portfolio monitoring** - pull a landlord's buildings and track new complaints.

### Example output

**One heat complaint, as captured on 2026-10-07** - a building-wide no-heat
report (the status fields track the department's workflow and change over time):

```json
{
 "platform": "nyc-hpd-complaints",
 "source": "nyc-hpd-housing-complaints",
 "mode": "rows",
 "groupKey": "",
 "groupCount": "",
 "groupBy": "",
 "receivedDate": "2026-10-07T00:01:41.000",
 "problemId": "29242015",
 "complaintId": "15010743",
 "buildingId": "33490",
 "borough": "MANHATTAN",
 "houseNumber": "415",
 "streetName": "WEST 47 STREET",
 "zip": "10036",
 "block": "1057",
 "lot": "25",
 "apartment": "BLDG",
 "communityBoard": "4",
 "unitType": "BUILDING-WIDE",
 "spaceType": "BUILDING-WIDE",
 "type": "EMERGENCY",
 "majorCategory": "HEAT/HOT WATER",
 "minorCategory": "ENTIRE BUILDING",
 "problemCode": "NO HEAT AND NO HOT WATER",
 "complaintStatus": "OPEN",
 "complaintStatusDate": "2026-10-07T00:04:29.000",
 "problemStatus": "OPEN",
 "problemStatusDate": "2026-10-07T00:04:22.000",
 "statusDescription": "More than one complaint was received for this building-wide condition. ... (excerpt)",
 "duplicateFlag": "Y",
 "anonymousFlag": "Y",
 "uniqueKey": "",
 "latitude": "40.761915000000002",
 "longitude": "-73.991022000000001",
 "councilDistrict": "3",
 "censusTract": "127",
 "bin": "1079057",
 "bbl": "1010570025",
 "nta": "Hell's Kitchen",
 "sourceUpdatedAt": "2026-10-07"
}
```

**`mode=aggregate`, `groupBy=majorCategory`** - one count row per category:

```
HEAT/HOT WATER                              2,936,779
HEATING                                     2,509,671
PLUMBING                                    2,084,550
PAINT/PLASTER                               1,890,316
GENERAL                                     1,829,141
UNSANITARY CONDITION                        1,358,712
ELECTRIC                                      849,871
...
```

### Notes on the data, from the source

- **Counts in this section are a 2026-10-30 snapshot.** The register refreshes
  daily, so the live figures will differ slightly.
- **Heat and water dominate.** HEAT/HOT WATER alone is 2.94M problem records
  (17.9%), and it is the category the City treats as a same-day emergency in the
  cold months. Filter on `majorCategory` to find it.
- **The urgency tiers, in order.** IMMEDIATE EMERGENCY (567,690) and HAZARDOUS
  (280,397) are the two tiers to screen on; the rest are EMERGENCY (10,520,710),
  NON EMERGENCY (5,056,475) and a handful of REFERRAL rows. `type` is matched
  exactly.
- **Open vs closed.** `problemStatus` is `OPEN` (42,475) or `CLOSE` (16,382,801)
  at the problem level, with `complaintStatus` at the complaint level. The two
  rarely differ, and both track the department's workflow.
- **Anonymous and duplicate flags.** 2,121,993 problem records came in anonymously
  (`anonymousFlag="Y"`); 2,638,447 are marked as duplicates of another complaint
  (`duplicateFlag="Y"`). These are output flags only - the actor does not filter
  on them, and `anonymousFlag` is blank when the source did not record it.
- **The listing is keyed by `buildingId` and BBL.** A building's complaints are
  one `buildingId` lookup - up to 2,000 per run; the busiest buildings have
  more, so page with `dateFrom`/`dateTo`. The same key pulls its issued
  violations from the companion NYC HPD violations dataset.
- **`uniqueKey` is not always present** (filled on ~14.3M of 16.4M rows).
  `problemId` is unique per row; `complaintId` groups several problems under one
  complaint (~1.83 rows per complaint on average).
- **The register refreshes daily**; `sourceUpdatedAt` carries the dataset's own
  refresh date.
- **One run returns up to 2,000 records.** Narrow the filters to reach a
  specific slice; for a building with more complaints, split the period with
  `dateFrom` / `dateTo`.

### Use it from an AI agent (MCP)

Connect any MCP client to `https://mcp.apify.com/?tools=j0401/nyc-hpd-complaints` to load this dataset as a single tool beside the tools you already have - same records, same per-record pricing.

# Actor input Schema

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

The borough the building is in. Blank = any.

## `majorCategory` (type: `string`):

The condition category, e.g. HEAT/HOT WATER, PLUMBING, PAINT/PLASTER, UNSANITARY CONDITION. Blank = any.

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

The complaint's severity tier. Blank = any.

## `problemStatus` (type: `string`):

OPEN = not yet resolved; CLOSE = resolved. Blank = any.

## `complaintStatus` (type: `string`):

OPEN = the complaint is still open; CLOSE = closed. Blank = any.

## `unitType` (type: `string`):

Where the condition was reported: one apartment, a building-wide problem, or a public area. Blank = any.

## `zip` (type: `string`):

Substring match on the ZIP code, e.g. '11206', '104'. Blank = any.

## `street` (type: `string`):

Substring match on the street name, e.g. 'BROADWAY', 'GRAND'. Blank = any.

## `buildingId` (type: `string`):

Every complaint on one building by its HPD building id, e.g. '374378'. This is the key that joins the HPD violations table. Blank = any.

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

Earliest received date, YYYY-MM-DD. Blank = any.

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

Latest received date, YYYY-MM-DD. Blank = any.

## `recentDays` (type: `integer`):

Only complaints received within the last N days. Cannot be combined with 'Received on or after' (an overlap is rejected). 0 = off.

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

rows = complaint records matching your filters (default). aggregate = one count row per group (see groupBy).

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

Which dimension to aggregate over (mode=aggregate). Blank = majorCategory. Every group is returned - aggregate mode is not cut off by maxResults.

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

Cap the number of records pushed in rows mode (0 = default 50; up to 2,000 per run). Each record is metered individually, so there is no per-run charge cap. Aggregate mode returns every group.

## Actor input object example

```json
{
  "borough": "",
  "majorCategory": "",
  "type": "",
  "problemStatus": "",
  "complaintStatus": "",
  "unitType": "",
  "zip": "",
  "street": "",
  "buildingId": "",
  "dateFrom": "",
  "dateTo": "",
  "recentDays": 0,
  "mode": "rows",
  "groupBy": "",
  "maxResults": 50
}
```

# Actor output Schema

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

New York City HPD housing complaint records - 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/nyc-hpd-complaints").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/nyc-hpd-complaints").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/nyc-hpd-complaints --silent --output-dataset

```

## MCP server setup

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

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/4jiBEM87gGbehG8RK/builds/WNAGELN1Oopurh3eb/openapi.json
