# FBI Crime Data Scraper — Statistics & NIBRS Counts (`muhammadafzal/fbi-crime-data-scraper`) Actor

Query FBI Crime Data Explorer summary statistics and NIBRS offense-count aggregates by year, offense, state, nation, or agency. $0.002 per stored record.

- **URL**: https://apify.com/muhammadafzal/fbi-crime-data-scraper.md
- **Developed by:** [Muhammad Afzal](https://apify.com/muhammadafzal) (community)
- **Categories:** Automation, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 fbi crime observations

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#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

## FBI Crime Data Scraper — Statistics & NIBRS Counts

Query the FBI Crime Data Explorer for structured annual crime statistics and aggregated NIBRS offense counts. This actor is designed for researchers, journalists, analysts, public-sector teams, and AI agents that need a compact, repeatable FBI crime-data surface.

### What it returns

Each dataset item represents one normalized FBI observation, usually one year × offense × geography combination. Fields include:

| Field | Meaning |
| --- | --- |
| `recordType` | `summary` or `nibrs-offense-count` |
| `dataYear` | Calendar year supplied by the FBI API |
| `locationLevel` | National, state, or agency |
| `stateCode` / `ori` | State abbreviation or FBI agency ORI when present |
| `offense` | Query slug such as `violent-crime` or `robbery` |
| `count` / `actual` / `cleared` | Normalized count fields when the endpoint supplies them |
| `rate` / `population` | Rate and population fields when supplied |
| `raw` | Compact source row for endpoint-specific fields |
| `sourceUrl` | Exact FBI API request URL |
| `warnings` | Coverage and interpretation notes |

### Supported modes

#### Summary crime statistics

Use `dataMode: "summary"` for FBI SRS-style summaries by `national`, `state`, or `agency`. State mode uses a two-letter `stateCode`; agency mode uses an FBI ORI. Common offense slugs include:

`violent-crime`, `property-crime`, `homicide`, `rape`, `robbery`, `aggravated-assault`, `burglary`, `larceny`, `motor-vehicle-theft`, and `arson`.

#### NIBRS offense counts

Use `dataMode: "nibrs"` with `locationLevel: "state"` for state-level offense-count aggregates. NIBRS data is more detailed than SRS, but this public API surface returns aggregated counts—not raw incident/case records. Use the FBI Crime Data Explorer bulk-download files for raw NIBRS segment data.

### Example input

```json
{
  "dataMode": "summary",
  "locationLevel": "state",
  "stateCode": "CA",
  "offenses": ["violent-crime", "property-crime", "homicide"],
  "fromYear": 2020,
  "toYear": 2024,
  "maxResults": 100,
  "apiKey": "DEMO_KEY"
}
```

For a NIBRS offense-count query:

```json
{
  "dataMode": "nibrs",
  "locationLevel": "state",
  "stateCode": "TX",
  "offenses": ["robbery", "aggravated-assault"],
  "fromYear": 2022,
  "toYear": 2024
}
```

Use a registered `api.data.gov` key for larger or repeated runs. `DEMO_KEY` is intended for small tests and is subject to a low shared limit.

### Pricing

| Event | Price |
| --- | ---: |
| Actor start | $0.00005 |
| Stored crime observation | $0.002 |

The actor prints the maximum result-charge cap at startup. A result event is charged only after its validated dataset write succeeds. Invalid, empty, or blocked requests do not generate result charges.

### Data and coverage notes

The FBI Crime Data Explorer is a reporting system. Counts reflect data submitted by participating law-enforcement agencies and may vary by year, endpoint, and reporting coverage. NIBRS counts are not equivalent to total crime victimization and should not be presented as a complete census of crime. The actor preserves endpoint-specific raw fields and warnings to support downstream review.

The current implementation uses the FBI's first-party public API endpoints at `cde.ucr.cjis.gov`. API endpoint behavior and data availability can change as the FBI updates the Crime Data Explorer. The actor fails honestly when every requested endpoint is unavailable rather than emitting fabricated rows.

### When not to use this actor

Do not use it for live emergency information, individual criminal-history checks, personally identifying information, case-level incident files, geospatial hot-spot analysis, or legal conclusions. Do not infer that zero returned NIBRS rows means zero crime; it may mean no participating data for that query.

### Source

Official source: [FBI Crime Data Explorer](https://cde.ucr.cjis.gov/LATEST/). The FBI Crime Data Explorer describes its purpose as providing public access to criminal and noncriminal law-enforcement data and publishes UCR summary and NIBRS resources.

### Related workflow

For raw incident research, download the relevant annual NIBRS files from the FBI Crime Data Explorer and process the pipe-delimited segments with the FBI technical specification. For quick state or national trend tables, use this actor with a narrow year range and a registered API key.

# Actor input Schema

## `dataMode` (type: `string`):

Use summary for SRS-style crime statistics by nation, state, or agency; use nibrs for state-level offense-count aggregates. Example: 'summary'. This is not a raw incident-download selector.

## `locationLevel` (type: `string`):

Use national for U.S. totals, state for a two-letter stateCode such as CA, or agency for an FBI ORI such as CA0194200. NIBRS mode currently supports state only.

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

Use this for state summaries or to filter NIBRS results to one state. Enter a two-letter USPS/FBI abbreviation such as CA, TX, or NY. Defaults to CA for a working prefill; ignored for national and agency summary queries.

## `ori` (type: `string`):

Use this only when locationLevel is agency. Enter the agency's FBI Originating Agency Identifier, for example CA0194200. This is not a city name, county name, or postal code.

## `offenses` (type: `array`):

Use this to select FBI offense endpoint slugs. Examples: violent-crime, property-crime, homicide, rape, robbery, aggravated-assault, burglary, larceny, motor-vehicle-theft, or arson. Up to 10 unique slugs are queried; unknown slugs are reported in OUTPUT warnings.

## `fromYear` (type: `integer`):

Use this as the inclusive first year, from 1960 through the current year. Example: 2020. The FBI may have different historical coverage by endpoint.

## `toYear` (type: `integer`):

Use this as the inclusive last year. Example: 2024. Keep it at or after fromYear and no later than the current year when the actor runs.

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

Use this to cap stored dataset rows and result-event charges. Defaults to 100 and allows 1-1,000. Each row is one normalized FBI year/offense/location observation, not one raw criminal case.

## `apiKey` (type: `string`):

Use a registered api.data.gov/FBI key for higher request limits. DEMO\_KEY is the default for small tests; enter your own key as a secret when running larger queries. This is not an Apify token.

## `requestDelayMs` (type: `integer`):

Use this to pace requests to the public FBI API. Enter 100-5,000 milliseconds; 250 is the default. This is not a total timeout or a proxy setting.

## Actor input object example

```json
{
  "dataMode": "summary",
  "locationLevel": "state",
  "stateCode": "CA",
  "ori": "",
  "offenses": [
    "violent-crime",
    "property-crime"
  ],
  "fromYear": 2020,
  "toYear": 2024,
  "maxResults": 100,
  "requestDelayMs": 250
}
```

# Actor output Schema

## `results` (type: `string`):

One normalized FBI observation per dataset item.

## `summary` (type: `string`):

Request counts, records, charges, and warnings.

# 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 = {
    "dataMode": "summary",
    "locationLevel": "state",
    "stateCode": "CA",
    "ori": "",
    "offenses": [
        "violent-crime",
        "property-crime"
    ],
    "fromYear": 2020,
    "toYear": 2024,
    "maxResults": 100,
    "requestDelayMs": 250
};

// Run the Actor and wait for it to finish
const run = await client.actor("muhammadafzal/fbi-crime-data-scraper").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 = {
    "dataMode": "summary",
    "locationLevel": "state",
    "stateCode": "CA",
    "ori": "",
    "offenses": [
        "violent-crime",
        "property-crime",
    ],
    "fromYear": 2020,
    "toYear": 2024,
    "maxResults": 100,
    "requestDelayMs": 250,
}

# Run the Actor and wait for it to finish
run = client.actor("muhammadafzal/fbi-crime-data-scraper").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 '{
  "dataMode": "summary",
  "locationLevel": "state",
  "stateCode": "CA",
  "ori": "",
  "offenses": [
    "violent-crime",
    "property-crime"
  ],
  "fromYear": 2020,
  "toYear": 2024,
  "maxResults": 100,
  "requestDelayMs": 250
}' |
apify call muhammadafzal/fbi-crime-data-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/dqQ215E9vZfIasij2/builds/oBsFfJFm3ShigfwdZ/openapi.json
