# EPA ECHO facilities - permits, inspections, violations (API) (`retrainmap/epa-echo-facilities`) Actor

Search EPA ECHO by state, city, zip, NAICS and program (air, water, hazardous waste, drinking water) and get one row per regulated facility: registry id, address, permits, compliance status, quarters in noncompliance, inspections, enforcement, penalties, report URL.

- **URL**: https://apify.com/retrainmap/epa-echo-facilities.md
- **Developed by:** [RetrainMap Team](https://apify.com/retrainmap) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 records

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/actors/running/actors-in-store.md#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

## EPA ECHO facilities — permits, inspections, violations (API)

One row per EPA-regulated facility from ECHO (Enforcement and Compliance History Online),
EPA's public facility search web service. Filter by state, city, ZIP, NAICS code and
program (Clean Air Act, Clean Water Act / NPDES, RCRA hazardous waste, SDWA drinking water);
get the FRS registry id, address, county, coordinates, NAICS/SIC codes, program flags and
permit ids, compliance status per program, quarters in noncompliance (3 years), inspections,
enforcement actions and penalties (5 years) and the detailed facility report URL — one flat
row per facility, ready for CSV or JSON.

**The default input (Raleigh, NC, all programs, up to 500 rows) succeeds within 5 minutes
and returns rows** — Apify auto-tests it daily.

### Data source and status

| | |
|---|---|
| Publisher | U.S. Environmental Protection Agency — ECHO (https://echo.epa.gov) |
| API | ECHO web services, Facility Search (All Data): `echodata.epa.gov/echo/echo_rest_services.get_facilities` then `.get_qid` — public, no key (documentation: https://echo.epa.gov/tools/web-services/facility-search-all-data) |
| What this Actor reads | One `get_facilities` GET with `p_st`, `p_ct`, `p_zip`, `p_ncs`, `p_med`, `p_act` and a fixed `qcolumns` list, which answers a `QueryID` and ECHO's own match counts; then `get_qid` pages of 1,000 facilities, at most one request per second |
| Refresh cadence | ECHO refreshes its facility data **weekly** (data pulled from the program systems ICIS-Air, ICIS-NPDES, RCRAInfo, SDWIS; see https://echo.epa.gov/resources/echo-data/about-the-data). The Actor reads live on every run; `fetched_at` on each row is the fetch time |
| Copyright | Works of the United States Government are not subject to copyright in the U.S. (17 U.S.C. §105). The data are public; please cite EPA ECHO as the source |
| Known caveats | ECHO refuses result sets above its query-set limit — a whole large state (e.g. NC alone = 118,707 facilities) fails with ECHO's "Queryset Limit would be exceeded" message; add a city, ZIP, NAICS or program. ECHO silently ignores filters it does not know and returns 0 rows for an unknown state, so the Actor validates state, ZIP and NAICS itself. Many facilities carry no compliance status, inspection or penalty data (nulls) — ECHO only holds what the program systems report. Counts follow ECHO's windows: inspections, enforcement and penalties over 5 years, quarters in noncompliance over 3 years (12 quarters). EPA's own caveats on data quality apply: https://echo.epa.gov/resources/echo-data/known-data-problems |

Honesty note: the rows are ECHO's own columns renamed and converted (strings to numbers,
Y/N and 1/0 to booleans, MM/DD/YYYY to ISO dates) — nothing is inferred, scored or
classified by this Actor, and a run stops with an error rather than guess when ECHO's shape
changes; the violation filter is cross-checked against ECHO's own count.

Identification: the requests carry a product-token User-Agent and the operator's
contact address in the standard `From:` header (RFC 9110 §10.1.2).

### Input

| Field | Type | Meaning |
|---|---|---|
| `state` | USPS code | e.g. `NC`. Required unless `zip` is given |
| `city` | string | Optional, as ECHO records it (case-insensitive); needs `state` |
| `zip` | 5 digits | Optional |
| `naics` | 2–6 digits | Optional NAICS code or prefix (`62` = health care) |
| `program` | select | `all`, `air`, `water`, `hazardous_waste`, `drinking_water` |
| `only_with_violations` | boolean | Keep only facilities with a violation identified in the last 3 years (ECHO `ViolFlag`) |
| `active_only` | boolean | ECHO `p_act=Y` |
| `max_records` | integer | Default 500, at most 20,000 |
| `request_interval_ms` | integer | Default 1000 (floor 250) |
| `contact_email` | string | Sent in the `From:` header |

Example — hazardous-waste handlers in Houston with a violation in the last three years:

```json
{ "state": "TX", "city": "Houston", "program": "hazardous_waste", "only_with_violations": true, "max_records": 2000 }
```

### Output (dataset row)

`registry_id` (FRS), `facility_name`, `address`, `city`, `state`, `zip`, `county`, `county_fips`,
`epa_region`, `latitude`, `longitude`, `naics_codes`, `sic_codes`, `active`, `major`,
`program_air`, `program_water`, `program_hazardous_waste`, `program_drinking_water`,
`program_tri`, `program_ghg`, `air_permit_ids`, `npdes_permit_ids`, `rcra_ids`, `sdwa_ids`,
`tri_ids`, `caa_permit_types`, `cwa_permit_types`, `rcra_permit_types`, `compliance_status`,
`caa_compliance_status`, `cwa_compliance_status`, `rcra_compliance_status`,
`sdwa_compliance_status`, `violation_3yr`, `current_violation`,
`current_significant_violation`, `significant_noncompliance`, `programs_with_snc`,
`quarters_noncompliance_3yr`, `compliance_history_3yr` (ECHO's 12-character quarter string),
`inspections_5yr`, `last_inspection_date`, `days_since_last_inspection`,
`informal_actions_5yr`, `formal_actions_5yr`, `last_formal_action_date`, `penalties_5yr_usd`,
`penalty_count_5yr`, `last_penalty_date`, `last_penalty_usd`, `echo_url` (detailed facility
report), `fetched_at`, `source`.

A run summary (filters, ECHO's query id and its own counts — matches, current violations,
3-year violations, inspections, penalties — pages, requests, whether the pay-per-event
budget stopped the run) is stored as `RUN_SUMMARY` in the run's key-value store.

### Pricing (pay per event)

| Event | Price |
|---|---|
| `run-start` — once per run | $0.10 |
| `record` — per row written | $0.005 |

The default pull (≤ 500 rows) costs at most $2.60; 2,000 facilities cost $10.10. Rows stop
when your run's maximum charge is reached; the run summary says so.

### Operator

Steelyard Ventures LLC (RetrainMap) — info@steelyardclinical.com. Not affiliated with the
U.S. EPA. The Actor writes only to its own dataset and key-value store; it stores no
credentials and sends nothing else.

# Actor input Schema

## `state` (type: `string`):

Two-letter USPS code (50 states, DC, AS, GU, MP, PR, VI), passed as p\_st. Required unless a zip is given.

## `city` (type: `string`):

Optional city name as ECHO records it (case-insensitive), passed as p\_ct. Needs a state.

## `zip` (type: `string`):

Optional five-digit ZIP, passed as p\_zip.

## `naics` (type: `string`):

Optional 2-6 digit NAICS code, passed as p\_ncs; a prefix matches every code under it (62 = health care, 3116 = animal slaughtering).

## `program` (type: `string`):

Restrict to facilities regulated under one program: air (Clean Air Act, p\_med=A), water (Clean Water Act / NPDES, W), hazardous waste (RCRA, R), drinking water (SDWA, S). all = no program filter.

## `only_with_violations` (type: `boolean`):

Keep only rows whose ECHO ViolFlag is set (a violation identified in the last three years). Applied client-side after reading the result set and cross-checked against ECHO's own V3Rows count.

## `active_only` (type: `boolean`):

Pass p\_act=Y so ECHO returns only facilities with an active permit or status.

## `max_records` (type: `integer`):

Stop after this many facility rows have been written. ECHO returns 1,000 facilities per page.

## `request_interval_ms` (type: `integer`):

Politeness delay towards echodata.epa.gov. Each request returns up to 1,000 facilities; the floor is 250 ms.

## `contact_email` (type: `string`):

Sent in the standard From: request header so the data owner can reach the operator (RFC 9110 s10.1.2).

## Actor input object example

```json
{
  "state": "NC",
  "city": "Raleigh",
  "program": "all",
  "only_with_violations": false,
  "active_only": false,
  "max_records": 500,
  "request_interval_ms": 1000,
  "contact_email": "info@steelyardclinical.com"
}
```

# Actor output Schema

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

Every matched facility as one row: registry id, address, NAICS, program flags and permit ids, compliance status, violations, inspections, enforcement, penalties, report URL.

## `results_csv` (type: `string`):

The same rows as a CSV file.

# 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 = {
    "state": "NC",
    "city": "Raleigh"
};

// Run the Actor and wait for it to finish
const run = await client.actor("retrainmap/epa-echo-facilities").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 = {
    "state": "NC",
    "city": "Raleigh",
}

# Run the Actor and wait for it to finish
run = client.actor("retrainmap/epa-echo-facilities").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 '{
  "state": "NC",
  "city": "Raleigh"
}' |
apify call retrainmap/epa-echo-facilities --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,retrainmap/epa-echo-facilities"
        }
    }
}
```

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/6wXTU9ESmH03E9iBI/builds/KQuOJwGHrVRl0eXdn/openapi.json
