# Seattle Commercial Permit Pipeline — Ready and Issued Alerts (`natstandridge/seattle-permit-pipeline`) Actor

Get commercial building permits from Seattle's official daily open data when they are first seen or move from Ready for Issuance to Issued. Filter by project cost, permit class, and work description; schedule a named monitor for change-only rows.

- **URL**: https://apify.com/natstandridge/seattle-permit-pipeline.md
- **Developed by:** [Nathaniel Standridge](https://apify.com/natstandridge) (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

$2.00 / 1,000 delivered seattle commercial permit observations

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

## Seattle Commercial Permit Pipeline

Find Seattle commercial building permits that have reached **Ready for Issuance** or **Issued**. Contractors, suppliers, and local business development teams can filter the city's published work descriptions and estimated project costs, then schedule a named monitor to receive newly observed permits and stage changes.

### First run

Paste this input for a bounded one-time sample:

```json
{
  "lookbackDays": 7,
  "permitClasses": ["Commercial"],
  "maxSourceRecords": 100,
  "maxResults": 25
}
```

Each dataset row is one delivered permit observation. On a one-time run, matching permits are `current` rows. To monitor changes, add a stable `monitorId` such as `commercial-doors` and schedule the same input daily. The first named run can deliver current matches (`baselineMode: "emit-current"`) or save a free baseline (`"baseline-only"`). Later runs emit `first_seen` for a newly observed permit and `stage_changed` when a previously observed permit changes between the two supported stages. Reuse a monitor name only for the same filters; schedule its runs without overlap.

### Coverage and timing

The only source is [Seattle's Building Permits open-data dataset](https://data.seattle.gov/Built-Environment/Building-Permits/76t5-zqzr/about_data), queried through its [Socrata API](https://dev.socrata.com/foundry/data.seattle.gov/76t5-zqzr). The query requires Seattle's `PermitClassMapped` to equal `Non-Residential` and the published `ReadyToIssueDate` to fall in the rolling UTC window. You can select the published `PermitClass` values Commercial, Industrial, and Institutional. Only current statuses `Ready for Issuance` and `Issued` produce rows. The optional cost filter uses the city's estimated project cost; a positive threshold excludes missing estimates. Keyword phrases are literal, case-insensitive OR matches in the published work description or permit type.

Seattle updates the dataset daily. **The readiness date is historical. Many permits are already Issued when first seen, so a row is not necessarily a pre-issuance lead.** This Actor reports observed source stages, not a guaranteed real-time transition or a claim that a permit is still actionable. It does not infer contractors, owners, contact information, completion, removal, or a stage that the source did not publish. A stage change can be missed if a permit leaves the rolling ready-date window before the next scheduled run.

The source query fetches at most `maxSourceRecords + 1` records (default cap 200, maximum 500). If more than the configured source cap exist, or eligible observations exceed `maxResults` (default 100, maximum 200), the Actor fails before delivery and does not advance the monitor. Narrow the lookback, class, cost, or keywords, or raise the bounded cap. It makes at most three source attempts, uses a fixed public Seattle endpoint, follows no redirects, sends no credential, and limits the source response to 4 MiB. A keyless public API call can receive HTTP 429 due to a shared rate limit; `OUTPUT.stopReason` reports `SOURCE_RATE_LIMITED` without exposing response content.

### Output and charges

The [example input](examples/input.json) and [illustrative output row](examples/output.json) show the contract. Every delivered dataset row has a stable `observationId`, stage and previous stage, source dates, project details, the official record link, and `observedAt`. `OUTPUT` contains the UTC query window, source and filter counts, delivered-row count, and monitor-commit status. The Dataset schema and Output schema are included in `.actor/`.

The intended Apify pay-per-event price is **$0.002 per `apify-default-dataset-item` event**, subject to the published Store price at release. There is no Actor-start event. A dataset row is the charged unit; an empty result, baseline-only setup, and the `OUTPUT` summary have no event charge. The Actor freezes a result plan, checks its visible dataset rows against the native charge count on recovery, and never retries an ambiguous billable write. If delivery or checkpointing is uncertain, the run stops for reconciliation instead of claiming a completed monitor. The release is configured so the Actor creator pays platform usage.

### Input limits

| Field | Default | Allowed |
| --- | ---: | --- |
| `monitorId` | empty | 1–40 letters, digits, `_` or `-`; empty means one-time snapshot |
| `lookbackDays` | 14 | 1–60 days |
| `permitClasses` | `["Commercial"]` | 1–3 of Commercial, Industrial, Institutional |
| `minProjectCostUsd` | 0 | 0–10,000,000; zero includes missing estimates |
| `keywords` | `[]` | Up to 8 literal phrases, 2–60 characters each |
| `maxSourceRecords` | 200 | 1–500 |
| `maxResults` | 100 | 1–200 paid rows |
| `baselineMode` | `emit-current` | `emit-current` or `baseline-only` for a named monitor |
| `requestTimeoutSeconds` | 20 | 5–30 |
| `maxRunSeconds` | 120 | 40–180 |

Named monitors store only permit number, ready date, last stage, and stage sequence in a private Apify key-value store derived from `monitorId`. They do not store the full public source response. To start a different monitoring scope, choose a new name. One named monitor must have only one active run at a time because Apify key-value stores do not provide an atomic compare-and-swap lock.

### Local development

```bash
uv sync --locked --group dev
uv run --locked python -B -m unittest discover -s tests -v
```

The pinned production dependencies are exported to `requirements.txt` with hashes for the Docker build. `tools/validate_cloud.py` checks exported run evidence against the frozen plan, dataset schema, summary, and native event count after cloud qualification.

# Actor input Schema

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

Leave empty for a one-time snapshot. Set a unique name and schedule the same input to get only new permits or stage changes on later runs. Do not overlap runs using one monitor name.

## `lookbackDays` (type: `integer`):

Only permits whose published ReadyToIssueDate falls within this rolling window are checked. The source is a daily snapshot and can lag.

## `permitClasses` (type: `array`):

Seattle's published PermitClass values. The query always excludes residential permits.

## `minProjectCostUsd` (type: `integer`):

0 includes permits with missing cost. A positive value excludes missing-cost permits. Applicant estimates are not verified contract values.

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

Literal, case-insensitive OR matches in the published work description or permit type. Leave empty for all selected classes.

## `maxSourceRecords` (type: `integer`):

Hard source-read cap. If the source has more, the run fails with no paid rows or monitor advance; narrow the window or raise this cap.

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

Hard delivery cap. If the filtered alert set exceeds it, the run fails with no charge or monitor advance.

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

Only used when monitorId is set. Baseline-only writes no paid rows on first setup, then later runs emit changes.

## `requestTimeoutSeconds` (type: `integer`):

Timeout for each attempt to read Seattle's public API.

## `maxRunSeconds` (type: `integer`):

Source collection reserves at least 30 seconds for checkpoints and dataset delivery.

## Actor input object example

```json
{
  "lookbackDays": 14,
  "permitClasses": [
    "Commercial"
  ],
  "minProjectCostUsd": 0,
  "maxSourceRecords": 200,
  "maxResults": 100,
  "baselineMode": "emit-current",
  "requestTimeoutSeconds": 20,
  "maxRunSeconds": 120
}
```

# Actor output Schema

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

No description

## `summary` (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 = {
    "permitClasses": [
        "Commercial"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("natstandridge/seattle-permit-pipeline").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 = { "permitClasses": ["Commercial"] }

# Run the Actor and wait for it to finish
run = client.actor("natstandridge/seattle-permit-pipeline").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 '{
  "permitClasses": [
    "Commercial"
  ]
}' |
apify call natstandridge/seattle-permit-pipeline --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,natstandridge/seattle-permit-pipeline"
        }
    }
}
```

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/lb2aXq565BS9zuk6c/builds/KwnFsU3i1MlVann02/openapi.json
