# Census Business Patterns - Employment & Payroll (`pink_comic/census-business-patterns-industry-employment`) Actor

Query Census County Business Patterns for establishment counts, employment, and payroll by NAICS code and geography. Built for market research, site selection, and economic analysis. Pay per result.

- **URL**: https://apify.com/pink\_comic/census-business-patterns-industry-employment.md
- **Developed by:** [Ava Torres](https://apify.com/pink_comic) (community)
- **Categories:** Lead generation, Education, AI
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 results

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/platform/actors/running/actors-in-store#pay-per-event

## 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

## Census Business Patterns - Industry & Employment Data by Location

Extract U.S. Census **County Business Patterns (CBP)** data: employee counts, establishment counts, and annual payroll — segmented by NAICS industry code and geographic level (national, state, county, or ZIP code).

Data is sourced directly from the [U.S. Census Bureau CBP API](https://www.census.gov/data/developers/data-sets/cbp-nonemp-zbp/cbp-api.html). No API key required.

---

### What This Actor Does

- Queries the Census 2021 CBP dataset via the official REST API
- Filters by any NAICS 2017 industry code (2-digit sector down to 6-digit subsector)
- Returns results at national, state, county, or ZIP code geographic level
- Outputs structured records ready for analysis, market research, or lead generation

---

### Use Cases

- **Market sizing** — How many restaurants (NAICS 72) are in each U.S. state?
- **Business density analysis** — Which ZIP codes have the highest concentration of healthcare establishments?
- **Competitive research** — How large is the labor market for a given industry in a target county?
- **Economic intelligence** — Compare payroll and employment trends across geographies
- **Lead generation** — Identify high-density industry clusters for outreach campaigns

---

### Input

| Field | Type | Description |
|-------|------|-------------|
| `naicsCode` | string | NAICS 2017 code (e.g. `"72"` for Accommodation & Food Services). Leave blank for all industries. |
| `geography` | select | `national`, `state`, `county`, or `zipcode` |
| `stateCode` | string | Two-digit FIPS state code to narrow county/ZIP results (e.g. `"06"` for California). Optional. |
| `maxResults` | integer | Maximum number of records to return (default: 500) |

#### Common NAICS Codes

| Code | Industry |
|------|----------|
| `11` | Agriculture, Forestry, Fishing |
| `21` | Mining, Quarrying, Oil & Gas |
| `23` | Construction |
| `31-33` | Manufacturing |
| `44-45` | Retail Trade |
| `52` | Finance and Insurance |
| `53` | Real Estate |
| `54` | Professional, Scientific & Technical Services |
| `62` | Health Care & Social Assistance |
| `72` | Accommodation & Food Services |

#### Common State FIPS Codes

| Code | State |
|------|-------|
| `06` | California |
| `48` | Texas |
| `36` | New York |
| `12` | Florida |
| `17` | Illinois |

---

### Output

Each record contains:

| Field | Description |
|-------|-------------|
| `naicsCode` | NAICS 2017 industry code |
| `naicsLabel` | Industry name |
| `employees` | Total employees (mid-March pay period) |
| `establishments` | Number of business establishments |
| `annualPayroll` | Annual payroll in thousands of dollars |
| `firstQuarterPayroll` | First-quarter payroll in thousands of dollars |
| `stateFips` | State FIPS code (state/county queries) |
| `countyFips` | County FIPS code (county queries) |
| `zipCode` | ZIP code (zipcode queries) |

---

### Example Output

```json
[
  {
    "naicsCode": "72",
    "naicsLabel": "Accommodation and food services",
    "employees": "1812928",
    "establishments": "91942",
    "annualPayroll": "37029834",
    "firstQuarterPayroll": "8543210",
    "stateFips": "06",
    "countyFips": "",
    "zipCode": ""
  }
]
````

***

### Data Source

**U.S. Census Bureau — County Business Patterns (2021)**

- Coverage: All U.S. states and territories
- Frequency: Annual (2021 is the most recent CBP release available via this API)
- Official documentation: https://www.census.gov/data/developers/data-sets/cbp-nonemp-zbp/cbp-api.html

***

### Notes

- Suppressed cells (where data is withheld for confidentiality) appear as `"0"` or `"N"` in the Census response — this is normal Census disclosure avoidance behavior, not an actor error.
- ZIP code queries can return large result sets. Use `stateCode` to limit scope, or set `maxResults` accordingly.
- NAICS codes must match the 2017 revision. Prior-year codes may differ at the subsector level.

# Actor input Schema

## `naicsCode` (type: `string`):

NAICS 2017 industry code to filter results (e.g. "72" for Accommodation & Food Services, "44" for Retail Trade, "62" for Health Care). Leave blank for all industries.

## `geography` (type: `string`):

The geographic granularity of results.

## `stateCode` (type: `string`):

Two-digit FIPS state code to narrow county or ZIP code results (e.g. "06" for California, "48" for Texas). Leave blank to query all states.

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

Maximum number of records to return.

## Actor input object example

```json
{
  "naicsCode": "72",
  "geography": "state",
  "stateCode": "",
  "maxResults": 500
}
```

# 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 = {
    "naicsCode": "72",
    "geography": "state",
    "stateCode": "",
    "maxResults": 500
};

// Run the Actor and wait for it to finish
const run = await client.actor("pink_comic/census-business-patterns-industry-employment").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 = {
    "naicsCode": "72",
    "geography": "state",
    "stateCode": "",
    "maxResults": 500,
}

# Run the Actor and wait for it to finish
run = client.actor("pink_comic/census-business-patterns-industry-employment").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 '{
  "naicsCode": "72",
  "geography": "state",
  "stateCode": "",
  "maxResults": 500
}' |
apify call pink_comic/census-business-patterns-industry-employment --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=pink_comic/census-business-patterns-industry-employment",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Census Business Patterns - Employment & Payroll",
        "description": "Query Census County Business Patterns for establishment counts, employment, and payroll by NAICS code and geography. Built for market research, site selection, and economic analysis. Pay per result.",
        "version": "0.1",
        "x-build-id": "gxPif0j6EI2n9YMn9"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/pink_comic~census-business-patterns-industry-employment/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-pink_comic-census-business-patterns-industry-employment",
                "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/pink_comic~census-business-patterns-industry-employment/runs": {
            "post": {
                "operationId": "runs-sync-pink_comic-census-business-patterns-industry-employment",
                "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/pink_comic~census-business-patterns-industry-employment/run-sync": {
            "post": {
                "operationId": "run-sync-pink_comic-census-business-patterns-industry-employment",
                "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": {
                    "naicsCode": {
                        "title": "NAICS Industry Code",
                        "type": "string",
                        "description": "NAICS 2017 industry code to filter results (e.g. \"72\" for Accommodation & Food Services, \"44\" for Retail Trade, \"62\" for Health Care). Leave blank for all industries.",
                        "default": "72"
                    },
                    "geography": {
                        "title": "Geographic Level",
                        "enum": [
                            "national",
                            "state",
                            "county",
                            "zipcode"
                        ],
                        "type": "string",
                        "description": "The geographic granularity of results.",
                        "default": "state"
                    },
                    "stateCode": {
                        "title": "State FIPS Code",
                        "type": "string",
                        "description": "Two-digit FIPS state code to narrow county or ZIP code results (e.g. \"06\" for California, \"48\" for Texas). Leave blank to query all states.",
                        "default": ""
                    },
                    "maxResults": {
                        "title": "Max Results",
                        "minimum": 1,
                        "maximum": 100000,
                        "type": "integer",
                        "description": "Maximum number of records to return.",
                        "default": 500
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
