# USDOT FRA Rail Crossing Accidents & Equipment Incidents (`groundplanes/fra-rail-crossing-accident-scraper`) Actor

Scrape official USDOT Federal Railroad Administration (FRA) highway-rail grade crossing accidents (Form 57), train equipment accidents (Form 54), and crossing inventory data (Form 71). Keyless from data.transportation.gov.

- **URL**: https://apify.com/groundplanes/fra-rail-crossing-accident-scraper.md
- **Developed by:** [Groundplane Labs](https://apify.com/groundplanes) (community)
- **Categories:** Business
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.10 / 1,000 incidents

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

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

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## USDOT FRA Rail Crossing Accidents & Equipment Incidents Scraper

Extract official Federal Railroad Administration (FRA) safety data from data.transportation.gov, covering Highway-Rail Grade Crossing Accidents (Form 57), Train Equipment Accidents (Form 54), and Crossing Inventory details (Form 71). Keyless, official SODA JSON API integration.

> This actor is an independent product and is not affiliated with, endorsed by, or sponsored by the Federal Railroad Administration (FRA) or the US Department of Transportation (USDOT).

### What it does

- **Form 57 (Grade Crossing Incidents):** Detailed collision reports involving motor vehicles, pedestrians, and trains at highway-rail crossings across all US states.
- **Form 54 (Train Equipment Accidents):** Rail equipment derailments, collisions, and mechanical accidents reported by interstate rail carriers.
- **Form 71 (Crossing Inventory Enrichment):** Joins warning device equipment summaries and quiet zone status from the crossing inventory to grade crossing incident records. The Form 71 Socrata dataset does not publish a predicted accident value, so `predictedAccidentRisk` always ships null (see Output).
- **Deduplication:** Optional collapsing of multiple railroad filings for the same incident on Form 54 using `uniqueIncidentsOnly`.
- **Count Reconciliation:** Verifies delivered incident rows against source SoQL `count(*)` totals; marks runs `PARTIAL:` with honest counts if any records are withheld or truncated.

### Who it's for

- **Rail Safety & Litigation Analysts:** Track crossing collision histories, warning device signaling failures, and carrier accident narratives for tort claims and expert testimony.
- **Supply Chain & Logistics Teams:** Monitor Class I (UP, BNSF, CSX, NS) equipment accidents, derailments, and hazardous material release events along freight corridors.
- **Municipal Planners & Transportation Engineers:** Evaluate crossing collision histories, quiet zones, and active warning device installations for grade separation funding.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `datasetFormType` | string (select) | `"FORM_57_GRADE_CROSSING_INCIDENTS"` | `"FORM_57_GRADE_CROSSING_INCIDENTS"`, `"FORM_54_TRAIN_EQUIPMENT_ACCIDENTS"`, or `"FORM_71_CROSSING_INVENTORY"`. |
| `states` | array | `["TX", "IL", "CA", "GA", "OH", "IN"]` | 2-letter US state postal codes. Empty array queries all states. |
| `railroadCodes` | array | `["UP", "BNSF", "CSX", "NS"]` | Railroad reporting marks. Empty array queries all reporting carriers. |
| `incidentDateFrom` | string | `Jan 1 of current year` | ISO date `YYYY-MM-DD`. Relative default computed at run time. |
| `onlyWithInjuriesOrFatalities` | boolean | `false` | When true, filters for incidents where total killed or injured >= 1. |
| `onlyPublicCrossings` | boolean | `false` | When true, limits to public grade crossings only. |
| `uniqueIncidentsOnly` | boolean | `false` | For Form 54, deduplicates multi-railroad joint reports by date, state, county, and time. |
| `socrataAppToken` | string (secret) | `""` | Optional Socrata App Token for higher request limits on data.transportation.gov. |
| `maxItems` | integer | `1000` | Maximum incident reports to deliver, newest first. |

#### Example input

```json
{
  "datasetFormType": "FORM_57_GRADE_CROSSING_INCIDENTS",
  "states": ["TX", "IL", "CA", "GA", "OH", "IN"],
  "railroadCodes": ["UP", "BNSF", "CSX", "NS"],
  "onlyWithInjuriesOrFatalities": false,
  "onlyPublicCrossings": false,
  "maxItems": 1000
}
```

### Output

One row per incident report.

| Field | Type | Description |
|---|---|---|
| `incidentNumber` | string | FRA report or incident tracking number. |
| `crossingId` | string or null | National DOT grade crossing ID number. |
| `reportingRailroadCode` | string or null | Reporting carrier mark (e.g. UP, BNSF, CSX). |
| `reportingRailroadName` | string or null | Full corporate name of reporting railroad. |
| `incidentDate` | string | Incident date (YYYY-MM-DD). |
| `incidentTime` | string or null | Time of incident. |
| `stateName` | string or null | State name. |
| `countyName` | string or null | County name. |
| `cityName` | string or null | City or nearest timetable station. |
| `highwayName` | string or null | Road or highway name. |
| `publicPrivateCode` | string or null | `Y` for public, `N` for private. Form 54 segment note: always null on Form 54 rows; the Form 54 dataset (85tf-25kj) publishes no public/private crossing field. |
| `highwayUserType` | string or null | Vehicle type or pedestrian designation. |
| `warningDeviceType` | string or null | Primary warning device at the crossing from the FRA crossing warning field (e.g. Gates, Crossbucks, Standard FLS). Form 54 caveat: in the Form 54 segment this field carries the dataset's signalization values ("Signaled" / "Not Signaled"), the only warning-device field Form 54 publishes. |
| `warningDeviceSignaledFailure` | boolean or null | True when the FRA signaled warning code reports no warning (alleged or confirmed), false when a warning was reported, null when the source reports no signaled warning outcome. Form 54 segment note: always null on Form 54 rows; the Form 54 dataset (85tf-25kj) publishes no signaled-warning code field. |
| `trainSpeedMph` | integer or null | Train speed in miles per hour. |
| `totalKilled` | integer or null | Total fatalities (Form 57 / Form 54 total fields as filed). |
| `totalInjured` | integer or null | Total injuries (Form 57 / Form 54 total fields as filed). |
| `hazmatReleasedCars` | integer or null | Number of cars releasing hazardous materials. Published only on Form 54; always null on Form 57 and Form 71 rows (Form 57 publishes a hazmat involvement code, not a car count). |
| `narrativeDescription` | string or null | Official narrative description filed with FRA. |
| `warningDeviceEquipment` | string or null | Summary of the warning device counts on the crossing's Form 71 inventory record; null when the inventory record reports no device counts or the crossing has no inventory record. |
| `quietZoneStatus` | string or null | `Yes` when a quiet zone ID is on the crossing's Form 71 inventory record, `No` when a record exists without one, null when the crossing has no inventory record. |
| `predictedAccidentRisk` | number or null | Always null: the Form 71 Socrata dataset does not publish a predicted accident value. Kept in the schema for compatibility. |

#### Sample row (real, live FRA data)

```json
{
  "incidentNumber": "CH0826202",
  "crossingId": "069890G",
  "reportingRailroadCode": "BNSF",
  "reportingRailroadName": "BNSF Railway Company",
  "incidentDate": "2026-08-31",
  "incidentTime": "04:42 PM",
  "stateName": "ILLINOIS",
  "countyName": "CARROLL",
  "cityName": "CHADWICK",
  "highwayName": "PRIVATE",
  "publicPrivateCode": "N",
  "highwayUserType": "Auto",
  "warningDeviceType": "Crossbucks",
  "warningDeviceSignaledFailure": null,
  "trainSpeedMph": 50,
  "totalKilled": 0,
  "totalInjured": 0,
  "hazmatReleasedCars": null,
  "narrativeDescription": "Z-CHCSSE1-31U WAS TRAVERSING SINGLE MAIN TRACK AND STRUCK AND OCCUPIED VEHICLE AT PRIVATE CROSSING.NO INJURIES REPORTED. NO HAZMAT RELEASED. USER'S AGE UNKNOWN",
  "warningDeviceEquipment": null,
  "quietZoneStatus": "No",
  "predictedAccidentRisk": null
}
```

### Troubleshooting & Data Notes

- **Filing Lag and update cadence:** Rail carriers file Form 57 and Form 54 reports monthly under 49 CFR Part 225. FRA refreshes these Socrata datasets on an ongoing basis, but incidents typically appear 30 to 60 days after the reporting month, so the newest incidents are never real-time. In Form 71 mode the rows are crossing inventory records and `incidentDate` is the inventory revision date, not an incident date. Form 71 is a current inventory snapshot maintained by FRA and the railroads.
- **Socrata Rate Limits:** Keyless requests share public IP pools on data.transportation.gov. If you experience throttling during bulk historical backfills, pass a free Socrata app token via `socrataAppToken`.
- **Zero Matches:** If zero records match, verify your date window or expand state and railroad code filters.

If this keeps happening, please open an issue on this actor's Issues tab and we'll fix it fast.

### Changelog

- 0.1.2 (2026-11-01): Disclosure fix only, no data changes: the output table now states that `publicPrivateCode` and `warningDeviceSignaledFailure` are always null on Form 54 rows because the Form 54 dataset (85tf-25kj) publishes no public/private field and no signaled-warning code field, and that `warningDeviceType` carries the Form 54 signalization values ("Signaled" / "Not Signaled") in that segment. Form 54 run status messages now carry the same segment note.
- 0.1.1 (2026-11-01): Fixed field mappings verified against the live FRA datasets: hazmat released cars now comes only from the Form 54 count field (the Form 57 hazmat involvement code is no longer shipped as a car count); warning device type now uses the FRA warning device field instead of warning time and location text; signaled warning failure now derives from the FRA signaled warning code; Form 54 totals, crossing ID (gxid), and station now populate; the Form 54 injuries filter and the Form 71 public crossings filter now query columns that exist; Form 71 enrichment now reads the device counts and quiet zone ID the inventory actually publishes (predicted accident risk is not published there and ships null, disclosed above); inventory enrichment is batched by crossing ID instead of one request per row; skipped and unparseable rows now produce a PARTIAL status instead of a silent Complete.
- 0.1.0 (2026-11-01): Initial build.

# Actor input Schema

## `datasetFormType` (type: `string`):

Which FRA dataset to query: Form 57 (grade crossing collisions), Form 54 (train equipment accidents), or Form 71 (crossing inventory).

## `incidentDateFrom` (type: `string`):

Earliest incident date (YYYY-MM-DD). Defaults to January 1 of current year computed at run time.

## `maxItems` (type: `integer`):

Maximum number of records to return.

## `onlyPublicCrossings` (type: `boolean`):

Filter for incidents occurring at public highway-rail grade crossings only.

## `onlyWithInjuriesOrFatalities` (type: `boolean`):

Filter for accidents with total killed >= 1 or total injured >= 1.

## `railroadCodes` (type: `array`):

Filter by railroad reporting marks (e.g. UP, BNSF, CSX, NS). Empty array queries all railroads.

## `socrataAppToken` (type: `string`):

Optional Socrata app token for higher rate limits on data.transportation.gov.

## `states` (type: `array`):

Filter by 2-letter US state codes (e.g. TX, IL, CA). Empty array queries all states.

## `uniqueIncidentsOnly` (type: `boolean`):

For Form 54, deduplicate multiple railroad reports of the same incident by (date, state, county, time).

## Actor input object example

```json
{
  "datasetFormType": "FORM_57_GRADE_CROSSING_INCIDENTS",
  "maxItems": 1000,
  "onlyPublicCrossings": false,
  "onlyWithInjuriesOrFatalities": false,
  "railroadCodes": [
    "UP",
    "BNSF",
    "CSX",
    "NS"
  ],
  "states": [
    "TX",
    "IL",
    "CA",
    "GA",
    "OH",
    "IN"
  ],
  "uniqueIncidentsOnly": false
}
```

# Actor output Schema

## `results` (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("groundplanes/fra-rail-crossing-accident-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("groundplanes/fra-rail-crossing-accident-scraper").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 groundplanes/fra-rail-crossing-accident-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,groundplanes/fra-rail-crossing-accident-scraper"
        }
    }
}
```

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/gzkC2UBPvSwtnqzmq/builds/eshnIgTUskOSFOl4n/openapi.json
