# Cheap Socrata Open Data Scraper - Government Datasets API (`themineworks/socrata-open-data`) Actor

Cheapest Socrata open-data scraper: any government dataset portal. $1/1,000 results, 25 free, pay-per-result, no subscription. Works in Claude, ChatGPT & any MCP-compatible AI agent.

- **URL**: https://apify.com/themineworks/socrata-open-data.md
- **Developed by:** [The Mine Works](https://apify.com/themineworks) (community)
- **Categories:** Business, Developer tools, MCP servers
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

## Socrata Open Data — Any Government Portal (CDC, HHS, NY, NYC & 100s more)

Search and pull data from **any Socrata open-data portal** — the platform behind hundreds of US federal, state and city government data sites: **data.cdc.gov, datahub.hhs.gov, data.cms.gov, data.ny.gov, data.cityofnewyork.us, data.texas.gov** and many more. Two modes in one actor: **discover** datasets across every portal by keyword, then **pull** the rows you want with SoQL filters. Clean structured JSON, no API key, no anti-bot.

**Keywords:** Socrata API, SODA API, open data, government data, data.gov alternative, CDC data, NYC open data, public data API, SoQL.

---

### Why this actor

Socrata powers a huge share of US government open data, and it exposes two excellent public APIs — a cross-portal **Discovery API** and the per-dataset **SODA** query API with SoQL filtering. This actor wraps both so you can go from "I need X data" to clean rows in one run:

- **Discovery mode** — search by keyword across *every* Socrata portal and get back each matching dataset's domain, ID, name and description.
- **Data mode** — point at a domain + dataset ID and pull the rows, with full **SoQL** support: `$where` filters, `$select` field projection, `$order` sorting.
- **Hundreds of portals** — federal (CDC, HHS, CMS), state (NY, Texas, Washington), and city (NYC, LA, Seattle, Chicago).
- **No API key required** — keyless by default; add a free Socrata app token for higher rate limits.
- **No anti-bot** — these are the governments' own official data APIs.

---

### Two ways to use it

**1. Find a dataset (discovery):** leave `domain`/`datasetId` blank and pass a `searchQuery`.

```json
{ "searchQuery": "restaurant inspections", "maxResults": 25 }
````

→ returns datasets like `data.cityofnewyork.us / 43nn-pn8j — DOHMH NYC Restaurant Inspection Results`.

**2. Pull the data:** pass the `domain` + `datasetId` (from discovery or the dataset URL), plus optional SoQL.

```json
{
  "domain": "data.cdc.gov",
  "datasetId": "9bhg-hcku",
  "select": "state,sex,age_group,covid_19_deaths",
  "where": "state='United States'",
  "order": "covid_19_deaths DESC",
  "maxResults": 5000
}
```

***

### Input

| Field | Type | Description |
|---|---|---|
| `searchQuery` | string | Keyword to find datasets across all portals (discovery mode). |
| `domain` | string | Portal domain, e.g. `data.cdc.gov` (data mode). |
| `datasetId` | string | Dataset 4x4 ID, e.g. `9bhg-hcku` (data mode). |
| `where` | string | SoQL `$where` filter. |
| `select` | string | SoQL `$select` (comma-separated fields). |
| `order` | string | SoQL `$order` sort. |
| `appToken` | string | Optional free Socrata app token (higher rate limits). |
| `maxResults` | integer | Max records (rows or datasets) to return. |

***

### Output

**Data mode** returns each row as the dataset defines it, plus `_domain`, `_dataset_id`, `_scraped_at`. **Discovery mode** returns one record per matching dataset:

```json
{
  "_type": "dataset",
  "domain": "data.cityofnewyork.us",
  "dataset_id": "43nn-pn8j",
  "name": "DOHMH New York City Restaurant Inspection Results",
  "description": "...",
  "rows_count": 280000,
  "permalink": "https://data.cityofnewyork.us/d/43nn-pn8j",
  "scraped_at": "2026-06-11T13:00:00.000Z"
}
```

A final `{"_type": "summary"}` record reports the mode and record count.

***

### Pricing

**Your first 25 records are free — every Apify account, no card, no trial clock.** After that it is a flat **$0.001 per record**.

- First 25 records free per account (lifetime), then $0.001/record ($1 per 1,000)
- **Zero charge on empty runs**
- No monthly minimum, no rental

***

### FAQ

**Do I need an API key?** No. Socrata's APIs are keyless. A free app token only raises rate limits for very large pulls.

**Which portals work?** Any Socrata-powered portal — hundreds of US federal, state and city government sites.

**How do I find a dataset ID?** Use discovery mode (search by keyword), or copy the 4x4 ID from the dataset's URL.

**Can I filter server-side?** Yes — full SoQL: `$where`, `$select`, `$order`. Filtering happens on Socrata's side, so you only pull (and pay for) the rows you want.

# Actor input Schema

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

Find datasets across ALL Socrata portals by keyword (e.g. covid deaths, restaurant inspections, trade). Leave domain + datasetId blank to use this mode and get a catalog of matching datasets with their domain + id.

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

The Socrata portal domain to pull rows from, e.g. data.cdc.gov, data.ny.gov, data.cityofnewyork.us. Provide together with datasetId.

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

The dataset's 4x4 identifier, e.g. 9bhg-hcku. Find it via discovery mode or in the dataset's URL.

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

Optional SoQL filter, e.g. state='New York' AND covid\_19\_deaths > 100

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

Optional comma-separated fields to return, e.g. state,sex,age\_group,covid\_19\_deaths. Leave blank for all fields.

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

Optional sort, e.g. covid\_19\_deaths DESC

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

A free Socrata app token raises rate limits. Leave blank for keyless access (lower limits, fine for most runs).

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

Maximum number of records (rows or datasets) to return.

## Actor input object example

```json
{
  "searchQuery": "covid deaths",
  "appToken": "",
  "maxResults": 50
}
```

# 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 = {
    "searchQuery": "covid deaths",
    "maxResults": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("themineworks/socrata-open-data").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 = {
    "searchQuery": "covid deaths",
    "maxResults": 50,
}

# Run the Actor and wait for it to finish
run = client.actor("themineworks/socrata-open-data").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "searchQuery": "covid deaths",
  "maxResults": 50
}' |
apify call themineworks/socrata-open-data --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=themineworks/socrata-open-data",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Cheap Socrata Open Data Scraper - Government Datasets API",
        "description": "Cheapest Socrata open-data scraper: any government dataset portal. $1/1,000 results, 25 free, pay-per-result, no subscription. Works in Claude, ChatGPT & any MCP-compatible AI agent.",
        "version": "0.1",
        "x-build-id": "UBi4cjwfPIyM0tqeb"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/themineworks~socrata-open-data/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-themineworks-socrata-open-data",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/themineworks~socrata-open-data/runs": {
            "post": {
                "operationId": "runs-sync-themineworks-socrata-open-data",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/themineworks~socrata-open-data/run-sync": {
            "post": {
                "operationId": "run-sync-themineworks-socrata-open-data",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "searchQuery": {
                        "title": "Search datasets (discovery mode)",
                        "type": "string",
                        "description": "Find datasets across ALL Socrata portals by keyword (e.g. covid deaths, restaurant inspections, trade). Leave domain + datasetId blank to use this mode and get a catalog of matching datasets with their domain + id."
                    },
                    "domain": {
                        "title": "Portal domain (data mode)",
                        "type": "string",
                        "description": "The Socrata portal domain to pull rows from, e.g. data.cdc.gov, data.ny.gov, data.cityofnewyork.us. Provide together with datasetId."
                    },
                    "datasetId": {
                        "title": "Dataset ID (data mode)",
                        "type": "string",
                        "description": "The dataset's 4x4 identifier, e.g. 9bhg-hcku. Find it via discovery mode or in the dataset's URL."
                    },
                    "where": {
                        "title": "Filter (SoQL $where)",
                        "type": "string",
                        "description": "Optional SoQL filter, e.g. state='New York' AND covid_19_deaths > 100"
                    },
                    "select": {
                        "title": "Fields (SoQL $select)",
                        "type": "string",
                        "description": "Optional comma-separated fields to return, e.g. state,sex,age_group,covid_19_deaths. Leave blank for all fields."
                    },
                    "order": {
                        "title": "Sort (SoQL $order)",
                        "type": "string",
                        "description": "Optional sort, e.g. covid_19_deaths DESC"
                    },
                    "appToken": {
                        "title": "Socrata app token (optional)",
                        "type": "string",
                        "description": "A free Socrata app token raises rate limits. Leave blank for keyless access (lower limits, fine for most runs).",
                        "default": ""
                    },
                    "maxResults": {
                        "title": "Max records",
                        "minimum": 1,
                        "maximum": 100000,
                        "type": "integer",
                        "description": "Maximum number of records (rows or datasets) to return.",
                        "default": 1000
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
