ParseForge Scrapers

San Francisco Open Data Scraper

parseforge/sf-open-data-scraper

BusinessDeveloper toolsAutomation

Scrapes any dataset from data.sfgov.org by its 4x4 ID. Returns each row as a flat record with optional SoQL filtering, column selection, and full-text search.

Run this scraper See the API call
Total users
2
Monthly active
0
Total runs
115
Bookmarked
0
Rating
Not rated yet
Last modified
12 days ago

Overview

ParseForge

San Francisco Open Data Scraper

Scrape any dataset from San Francisco's open data portal, up to a million rows per run. Pull building permits, 311 cases, police incidents, business registrations, and hundreds more. Filter with SoQL, select columns, and export to CSV, JSON, Excel, or XML.

San Francisco's open data portal holds thousands of public datasets, but downloading them manually means clicking through a browser, hitting row limits, and repeating for every update. This Actor reads directly from the Socrata API behind data.sfgov.org, so you can pull the exact rows you need with a single run. No browser, no manual exports, no API key registration.

Who uses it What they scrape San Francisco Open Data for
Urban planners Tracking new building permits and development pipeline changes across neighborhoods.
Data journalists Pulling police incident reports or 311 cases for public safety investigations.
Real estate analysts Monitoring eviction notices and registered business locations for market trends.
Civic hackers Feeding live city data into dashboards and community tools.

What it does

This Actor collects any dataset hosted on data.sfgov.org by its 4x4 ID and returns each row as a flat record.

  • ๐Ÿ“‹ Any public dataset: choose from over 500 datasets including building permits, 311 cases, police incidents, parking citations, food trucks, and business registrations.
  • ๐Ÿ” SoQL filtering: pass a $where clause to filter rows server-side before they reach your dataset.
  • ๐Ÿ“Š Column selection: specify a $select list to return only the fields you need.
  • ๐Ÿ“ˆ Sort control: add an $order clause to sort results by any column, ascending or descending.
  • ๐Ÿ”Ž Full-text search: use the query parameter to search across all string columns in the dataset.

Results export to CSV, JSON, Excel, or XML, or straight from the API.

What you can do with San Francisco Open Data data

๐Ÿ—๏ธ Monitor new construction.

A real estate analyst pulls the building permits dataset weekly, filters by 'issued' status and neighborhood, and feeds the results into a market report.

๐Ÿ“ฐ Investigate public safety trends.

A data journalist scrapes police incident reports filtered by date range and category to map crime patterns for a story.

๐Ÿ“ž Track city service requests.

A neighborhood advocate collects 311 cases by district and complaint type to measure response times and identify recurring issues.

๐Ÿšš Find food truck locations.

A developer pulls the mobile food facility permit dataset to power a real-time map of active food trucks in the city.

Why choose this scraper

What you get
No API key Reads public Socrata endpoints directly, no registration needed
Server-side filters SoQL $where, $select, $order, and $query reduce data before transfer
Fixed schema Every row from a given dataset arrives with the same columns every run
Multi-format export Download as CSV, JSON, Excel, XML, or push to a database

How it compares

No other Store actor targets San Francisco Open Data the same way, so the honest comparison is with the alternatives teams actually weigh.

San Francisco Open Data Scraper Build it in-house By hand
Setup Run it now, zero config Days of engineering None, but hours per pull
When San Francisco Open Data changes Maintained for you You fix it You re-learn the page
Proxies, retries, anti-bot Built in Your problem Browser only
Output Fixed JSON schema, CSV/Excel export Whatever you build Copy-paste
Cost Pay per result Engineering time Analyst hours

Configure the run

Drive the Actor with a dataset ID from the dropdown, and optionally narrow results with SoQL where, select, order, and full-text query parameters so only matching rows land in your dataset. The Input tab lists every parameter.

A first run with the defaults:

{
  "datasetId": "3pee-9qhc",
  "maxItems": 10
}

A larger pull:

{
  "datasetId": "3pee-9qhc",
  "maxItems": 200
}

Pricing

Pay-per-result: $0.0343 per result collected. You pay only for the results written to your dataset.

Results collected Approximate cost
100 results $3.43
1,000 results $34.30
10,000 results $343.00

New Apify accounts start with $5 in free credit.

Free users

Free-plan runs return up to 10 results as a preview. Upgrade your Apify plan to collect up to 1,000,000 results per run.

Run it

  1. Create a free Apify account with $5 in credit.
  2. Open the San Francisco Open Data Scraper.
  3. Set your inputs and any filters, then click Start.
  4. Export the results as CSV, Excel, JSON, or XML from the Dataset tab.

Run it programmatically through the Apify API (run-sync-get-dataset-items) or the ApifyClient for JavaScript and Python.

Use with AI agents (MCP)

Give an AI agent live access to San Francisco Open Data through the Model Context Protocol. Add the Actor to Claude, Cursor, or any MCP client:

claude mcp add --transport http apify "https://mcp.apify.com?tools=parseforge/sf-open-data-scraper"

Then prompt it in plain language to run the scraper and read back the results.

Troubleshooting

Why am I getting no results?

Check your $where clause for syntax errors. SoQL is case-sensitive and uses single quotes for strings. Try removing the filter to confirm the dataset itself returns rows, then add conditions back one at a time.

Why does my run time out?

Large datasets with many columns can take time. Try reducing maxItems, using $select to request fewer columns, or adding a $where filter to narrow the result set.

Why are some columns missing from my output?

If you used the $select parameter, only those columns are returned. Remove $select to get all columns. Also note that some datasets have computed columns that only appear when requested by name.

Why do I get an error about an invalid dataset ID?

The 4x4 ID must match exactly. Copy it from the dataset URL on data.sfgov.org. The ID is the part after '/d/' in the URL, like 'i98e-djp9'.

Why is my $order clause not working?

Column names in $order are case-sensitive. Check the exact column name from the dataset's metadata. Use 'column_name ASC' or 'column_name DESC' syntax.

FAQ

Question Answer
Do I need an API key or token to use this? No. The Actor reads from the public Socrata API endpoints, so no registration or authentication is required.
How do I find the dataset ID I need? Browse data.sfgov.org, open the dataset you want, and copy the 4x4 ID from the URL. It looks like 'i98e-djp9' for building permits. The input dropdown also lists over 500 common datasets by name.
Can I filter rows before downloading? Yes. Use the $where field with a SoQL clause like "status='issued'" to filter server-side. You can also use $select to pick columns and $order to sort.
What is the maximum number of rows I can get? You can set maxItems up to 1,000,000 per run. The Socrata API itself may impose its own limits on very large datasets, but the Actor will fetch as many as allowed.
Which datasets are available? Over 500 datasets from data.sfgov.org, including building permits, 311 cases, police incidents, business registrations, eviction notices, parking citations, food trucks, and many more. The input dropdown lists them all.
Can I search within a dataset for specific text? Yes. The query parameter performs a full-text search across all string columns in the dataset, returning only rows that match.
What output formats are supported? You can export results as CSV, JSON, Excel, or XML from the dataset tab, or push them directly to a database or storage integration.
Does this work with datasets that have geographic columns? Yes. Geographic columns like points and polygons are returned in their native format. You can filter them with SoQL spatial functions in the $where clause.
How often is the data updated? The Actor pulls live data from the Socrata API on every run. The freshness depends on how often the City updates each dataset, which varies by department.
Can I scrape multiple datasets in one run? The Actor processes one dataset ID per run. To collect multiple datasets, run the Actor multiple times with different dataset IDs, or use an Apify workflow.

Related actors

Browse the full ParseForge collection for more scrapers.

๐Ÿ†˜ Need help? Email parseforge@protonmail.com with your run ID, your input, and what you expected.

โš ๏ธ Disclaimer. This Actor is unofficial and is not affiliated with, endorsed by, or sponsored by City and County of San Francisco. It collects only publicly available data. You are responsible for using the collected data in compliance with the source's terms of service and applicable data-protection laws, including GDPR, CCPA, and PIPL. Do not use it to collect personal data unlawfully.

Input

FieldTypeWhat it doesDefault
datasetId required string (659 options) Socrata 4x4 ID of any dataset hosted on data.sfgov.org. Find the ID in the dataset URL (e.g. 'i98e-djp9' for building permits, 'pyih-qa8i' for business locations, 'vw6y-z8j6' for 311 cases, '5cei-gny5' for parking citations, 'rqzj-sfat' for food trucks, 'wg3w-h783' for police incidents). 3pee-9qhc
maxItems integer How many datasets to collect per run. 10
where string Optional Socrata SoQL $where clause. Example: "status='issued' AND zipcode='94110'". See https://dev.socrata.com/docs/queries/where.html not set
select string Comma-separated list of columns to return. Example: 'permit_number,status,issued_date'. Default: all columns. not set
order string Sort order. Example: 'issued_date DESC' or 'filed_date ASC' not set
query string Free-text search across all string columns of the dataset not set

Pricing

from $25.72 per 1,000 results

Charged forWhat it isPrice each
result Single result in the default dataset. $0.02572 to $0.0343

Tiered: the lower figure is the price on a higher Apify plan. Billing and the free credit live on Apify.

API

One POST returns the dataset directly. Same shape for every scraper in the library, so swapping the slug is the only change.

POST ยท run and get results
curl -X POST "https://api.apify.com/v2/acts/parseforge~sf-open-data-scraper/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "helloWorld": 123
  }'

Examples

Input that runs as-is.

input.json
{
  "helloWorld": 123
}

Reviews

No reviews yet. Be the first.

Issues

We build and maintain this scraper, so a problem with it comes to us. Report it on the Apify listing and the thread stays attached to the scraper where the next person can find it: open an issue.

Broken and urgent, or you would rather not post in public? Write to parseforge@protonmail.com and it reaches the people who wrote it.

Related scrapers

Run San Francisco Open Data Scraper on Apify All scrapers