# CA San Francisco Building Permits (`j0401/ca-sf-permits`) Actor

San Francisco building permits (public open data, 1.3M records) - the city's full permit file with engineering depth (cost, use, units, ADU, occupancy, status, dates, neighborhood). Filter by type/status/ADU/address or pull the daily change stream.

- **URL**: https://apify.com/j0401/ca-sf-permits.md
- **Developed by:** [Wenhao Yang](https://apify.com/j0401) (community)
- **Categories:**
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.10 / 1,000 ca san francisco permit records

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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## CA San Francisco Building Permits - the City's Full Permit File

The City & County of San Francisco publishes its **entire building-permit file** - every permit issued in the city, going back to the earliest electronic records - as open data. This actor turns that register into a **charged-per-record lookup, filter and change-stream tool**.

**Built for:** construction & development leads (who just pulled what permit, what's being built where), ADU / housing-market research (SF's ADU boom), property & real-estate diligence, permitting-activity analytics by neighborhood / district, and anyone who wants to watch the permit office's **daily change stream** without polling the whole city.

### What it covers

**1,295,048 permits** - the complete file, active and historical. SF keeps every permit on record, so the register spans:

| Type | What it is | Count |
|---|---|---|
| OTC alterations permit | over-the-counter alterations | 973,920 |
| Additions / alterations / repairs | the standard alteration bucket | 271,440 |
| Sign - erect / wall or painted sign | signage | ~25,000 |
| New construction (incl. wood frame) | brand-new buildings | ~15,600 |
| Demolitions | teardowns | 7,312 |
| Grade / quarry / fill / excavate | site work | 835 |

Each permit carries its **engineering depth** - not just a number and a status:

- **estimated & revised cost**, **existing vs proposed use**, **units** and **occupancy**, **existing vs proposed construction type**, existing/proposed **stories**
- **ADU / reroof / soft-story retrofit / fire-only / site-permit** flags - SF's ~3,269 true ADU permits are first-class citizens here
- the full **status-date chain**: creation / filed / issued / completed / approved / last-activity
- **address** (street number + name + suffix + unit), block & lot, **supervisor district**, **analysis neighborhood**, ZIP, and **latitude/longitude**
- the source's **work-description** free text

### Status

Permits end in many ways, and SF stores them as compact lowercase values. Key values: **complete** (743,162) / **issued** (247,662) / **expired** (232,344) / cancelled / filed / withdrawn / approved / revoked / denied. The live, in-progress slice is roughly `issued` + `filed` + `plancheck`; everything else is history.

### Typical questions

- "What permits did SF **issue last month**?" (date range on the issued date)
- "Show the **ADU permits** - where are SF's accessory dwellings going in?"
- "Recent **new-construction** permits in the Mission."
- "Every permit on **this address** - current and historical."
- "How much **new housing** is being entitled by district?"
- "**What changed at the permit office today?**" - the daily `delta` mode.
- "Aggregate the whole register by **status** or **neighborhood**."

### Daily change stream (`delta` mode)

SF's register carries a `data_loaded_at` marker that advances **every night** when the city refreshes the feed. `delta` mode returns exactly the rows that refresh touched since a date you pick - so "what's new since Tuesday" is a small, precise pull, not a scan of 1.3M rows. This is the change stream other city-permit tools don't expose.

### Inputs

| Input | What it does |
|---|---|
| `mode` | `rows` (default) / `delta` (change stream) / `aggregate` |
| `permitType` | permit type: new construction, additions alterations or repairs, OTC alterations, demolitions, sign, grade |
| `status` | complete / issued / expired / cancelled / filed / withdrawn / approved / ... Blank = any |
| `aduOnly` | ADU permits only |
| `address` / `streetName` | street filter |
| `neighborhood` / `supervisorDistrict` / `zipcode` | where the work is |
| `issuedFrom/To` / `createdFrom/To` | date-range filters |
| `changedSince` | for `delta` mode: rows touched on/after this date |
| `groupBy` | aggregate over status / permitTypeDescription / neighborhood / supervisorDistrict / zipcode / proposedUse |
| `maxResults` | cap records (default 200) |

**Default run = the 200 most recently touched permits** - fast for the daily auto-test. For a targeted query add a filter; for a broad view use `aggregate` (a handful of summary rows, not a 1.3M-row dump).

### Low cost

**From $0.0001 per record** - billed only for the rows you use, at the platform floor. Cost scales with what you pull, not with the size of the register - and because each record is metered individually there's no per-run charge cap to hit on a big pull.

SF's permit file is a "just download the CSV" dataset that hides real traps: **estimated cost is stored as a text column** (so it can't be range-filtered the way you'd expect, and the naive sort returns garbage), **status is a 23-value lowercase enum** that mixes lifecycle stages (a *complete* permit, an *issued* one, and an *expired* one are three different things and the file doesn't separate them for you), **the interesting flags are one-character markers** (ADU is 'Y'/'N'; reroof, fire-only and site permits are 'Y'/blank), and the type you'd search by is split across a numeric code and a human name. Normalizing that into a register where a `permitType` / `status` / `date` / `delta` query returns exactly the permits you mean is the actual product. Every pull is integrity-checked against the feed's known shape, so a degraded source fails loudly instead of returning bad rows.

### Source

- [SF Open Data: Building Permits](https://data.sfgov.org/Housing-and-Buildings/Building-Permits/i98e-djp9) - the City & County of San Francisco's published register. Reflects the city's record as of each daily refresh; not an endorsement of any project or contractor.

# Actor input Schema

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

rows = permits matching your filters (default). delta = the daily change stream: permits the SF permit office touched since `changedSince`. aggregate = one count row per group (see groupBy).

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

Permit type (fuzzy, matches the type name): new construction, additions alterations or repairs, OTC alterations, demolitions, sign, grade. Blank = any.

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

Permit status. Use a source value: complete, issued, expired, cancelled, filed, withdrawn, approved, revoked, denied, ... Blank = any. Most permits end 'complete'; live work is 'issued' / 'filed' / 'plancheck'.

## `aduOnly` (type: `boolean`):

When on, returns only accessory-dwelling-unit (ADU) permits.

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

Street number or street name, e.g. 'Market' or '1200'. Matches the permit's street line.

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

Street name only (matches the street field exactly-ish).

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

Analysis neighborhood substring, e.g. 'Mission', 'Sunset', 'Marina'.

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

SF supervisor district number (1-11).

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

Permit ZIP code.

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

Only permits issued on/after this date (YYYY-MM-DD).

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

Only permits issued before this date (YYYY-MM-DD).

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

Only permits created on/after this date.

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

Only permits created before this date.

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

Only rows the daily refresh touched on/after this date (YYYY-MM-DD). Use with mode=delta for the change stream; blank in delta mode = last 24h.

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

Which dimension to aggregate over. status -> the live vs done mix; permitTypeDescription -> what kind of work; neighborhood -> where.

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

Cap the number of records pushed (0 = up to ~10k per run; each record is metered individually, so there is no per-run charge cap). An aggregate has at most a few hundred groups.

## Actor input object example

```json
{
  "mode": "rows",
  "permitType": "",
  "status": "",
  "aduOnly": false,
  "address": "",
  "streetName": "",
  "neighborhood": "",
  "supervisorDistrict": "",
  "zipcode": "",
  "issuedFrom": "",
  "issuedTo": "",
  "createdFrom": "",
  "createdTo": "",
  "changedSince": "",
  "groupBy": "status",
  "maxResults": 200
}
```

# Actor output Schema

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

San Francisco building permit records or aggregates - 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/ca-sf-permits").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/ca-sf-permits").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/ca-sf-permits --silent --output-dataset

```

## MCP server setup

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

```

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/qqksZzMBfGWeBdiRx/builds/h6epVg6dcaAUaryVh/openapi.json
