# Cambridge Building Permits Properties and Details Scraper (`realestateapi/cambridge-building-permits-properties-and-details-scraper`) Actor

Cambridge Building Permits Properties and Details Scraper — Reads public Cambridge Massachusetts building-permit records from Socrata. Returns permit rows only; OUTPUT reports standardized SUCCEEDED/FAILED status.

- **URL**: https://apify.com/realestateapi/cambridge-building-permits-properties-and-details-scraper.md
- **Developed by:** [Real Estate API](https://apify.com/realestateapi) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.99 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## Cambridge Building Permits Properties and Details Scraper

Query public building-permit records from the City of Cambridge, Massachusetts Inspectional Services Department. The Actor uses the official Socrata dataset `qu2z-8suj` (`Building Permits: Addition/Alteration`) and returns permit IDs, addresses, work descriptions, permit status/type, issue dates, contractors, valuations, property/building fields, public location flags, and source URLs.

### Public source

```text
https://data.cambridgema.gov/resource/qu2z-8suj.json
```

The source is queried with a bounded `$limit`, optional `$offset`, the public Socrata `$q` full-text filter for `street`, exact `$where` filters for `permitType` and `status`, and a stable newest-issue-date ordering. No login, API key, protected endpoint, or remote Apify operation is used.

### Input

- `street` — optional full-text address/street filter.
- `permitType` — optional exact `permit_type` filter.
- `status` — optional exact status filter such as `Active`.
- `maxItems` — maximum records to store, from 1 to 500 (default `25`).
- `offset` — source row offset, from 0 to 100,000 (default `0`).
- `timeoutSecs` — public request timeout, from 5 to 120 seconds (default `30`).
- `requestDelayMs` — polite delay before the request (default `0`).

### Output

Each successful record has `recordType=permit`, `found=true`, and `dataAvailable=true`. Costs are normalized to numbers when the source publishes numeric values; missing fields are omitted. Records include source-backed nested `buildingDetails`, `residentialDetails`, `parkingDetails`, `constructionDetails`, `reviewFlags`, and parsed `locationDetails` when those values are present. `changeFlags` includes permit-specific project and site-impact indicators. Applicant, architect, and licensed-name fields are intentionally omitted.

The dataset contains permit records only. A valid empty response reports `SUCCEEDED` / `COMPLETED` with zero rows. A request or processing failure with no saved permits reports `FAILED` / `FAILED`. If permit rows were saved before a later dataset, summary-store, or shutdown failure, the run remains `SUCCEEDED` / `PARTIAL`. Failed requests, invalid rows, and placeholder/diagnostic data never become dataset records. `OUTPUT` reports last-run counts and aggregate failure counts.

The City portal identifies the dataset as licensed under the Open Data Commons Public Domain Dedication and License (PDDL). The dataset contains only completed applications and is updated daily. Fields remain source values; absent permit details are omitted rather than inferred.

### Local development

```bash
npm install
npm test
apify validate-schema
apify run
```

Local datasets and the `OUTPUT` summary are written only under this Actor's `storage/` directory. The lifecycle entrypoint uses `Actor.exit({ exit: false })` for clean Node 24 local shutdown.

# Actor input Schema

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

Optional public full-text filter applied to the Socrata dataset.

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

Optional exact permit-type filter, for example Building: Alteration and Addition.

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

Optional exact status filter, for example Active.

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

Maximum public permit records to store.

## `offset` (type: `integer`):

Number of source rows to skip before storing records.

## `timeoutSecs` (type: `integer`):

Timeout for the public Socrata request.

## `requestDelayMs` (type: `integer`):

Optional polite delay before the public Socrata request.

## Actor input object example

```json
{
  "street": "",
  "permitType": "",
  "status": "",
  "maxItems": 25,
  "offset": 0,
  "timeoutSecs": 30,
  "requestDelayMs": 0
}
```

# Actor output Schema

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

No description

## `runSummary` (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("realestateapi/cambridge-building-permits-properties-and-details-scraper").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("realestateapi/cambridge-building-permits-properties-and-details-scraper").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 realestateapi/cambridge-building-permits-properties-and-details-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,realestateapi/cambridge-building-permits-properties-and-details-scraper"
        }
    }
}
```

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/gb4P0efps1CGwoZFl/builds/ccYetK5gmdkj3vl8W/openapi.json
