# EPA compliance

> POST /epa/compliance searches EPA ECHO by facility name or FRS registry ID and returns violations, significant noncompliance, inspections, actions and penalties.

`POST https://api.qelka.com/v1/epa/compliance`

Check the environmental compliance record of a company or a facility in EPA ECHO (Enforcement and Compliance History Online), the public database of the US Environmental Protection Agency: how many of its facilities are in violation or in significant noncompliance, how many were inspected, what enforcement actions and penalties they had, and which facilities have the most serious record. Each lookup costs 1 credit when a facility matches; searches that match nothing or too much, errors and test keys are never billed.

## Request

Send a facility or company name, optionally with a state, or the 12-digit registry ID of one facility.

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `name` | string | One of `name` and `registry_id` | none | A facility or company name, or part of it, as EPA records it, 2 to 120 characters. |
| `registry_id` | string | One of `name` and `registry_id` | none | The EPA Facility Registry Service (FRS) identifier, exactly 12 digits. |
| `state` | string | No | none | A two-letter US state or territory code, in any case, that narrows the search to that state. |
| `fresh` | boolean | No | `false` | `true` skips the 7-day result cache and asks ECHO again. |

Send exactly one of `name` and `registry_id`: a body with both, or with neither, is a `400 invalid_request`. A name is matched anywhere in the facility name, so `Tesla` also finds `TESLA MOTORS INC`; ECHO refuses names so short or common that they match too many facilities, which gives `too_broad`.

A lookup makes two requests to ECHO, one after the other, each with a 15-second limit, so every snippet sets a 60-second client timeout.

```bash title="cURL"
curl https://api.qelka.com/v1/epa/compliance \
  --max-time 60 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Tesla", "state": "CA"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/epa/compliance', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ name: 'Tesla', state: 'CA' }),
  signal: AbortSignal.timeout(60_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/epa/compliance",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"name": "Tesla", "state": "CA"},
    timeout=60,
)
result = response.json()
print(result)
```
```php title="PHP"
<?php
$ch = curl_init('https://api.qelka.com/v1/epa/compliance');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('QELKA_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode(['name' => 'Tesla', 'state' => 'CA']),
    CURLOPT_TIMEOUT => 60,
]);
$result = json_decode(curl_exec($ch), true);
print_r($result);
```
```go title="Go"
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"time"
)

func main() {
	payload, _ := json.Marshal(map[string]any{"name": "Tesla", "state": "CA"})
	request, _ := http.NewRequest(http.MethodPost, "https://api.qelka.com/v1/epa/compliance", bytes.NewReader(payload))
	request.Header.Set("Authorization", "Bearer "+os.Getenv("QELKA_API_KEY"))
	request.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 60 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	var result map[string]any
	if err := json.NewDecoder(response.Body).Decode(&result); err != nil {
		panic(err)
	}
	fmt.Println(result)
}
```
```ruby title="Ruby"
require 'json'
require 'net/http'

uri = URI('https://api.qelka.com/v1/epa/compliance')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{ENV.fetch('QELKA_API_KEY')}"
request['Content-Type'] = 'application/json'
request.body = JSON.generate({ name: 'Tesla', state: 'CA' })

response = Net::HTTP.start(uri.host, uri.port, use_ssl: true, read_timeout: 60) do |http|
  http.request(request)
end
result = JSON.parse(response.body)
puts result
```

## Response

Every valid request gets a `200`. Read `status` first: only `found` fills `summary` and `facilities`.

| Field | Type | Description |
|---|---|---|
| `id` | string | Identifier of this lookup: `lkp_` followed by 26 characters. |
| `object` | string | Always `epa_compliance`. |
| `input` | string | The `registry_id` or `name` you sent, without surrounding spaces. |
| `query` | object | What was searched: `name` in upper case with single spaces, `registry_id` and `state` in upper case, each string or null. |
| `status` | string | `found`, `not_found` or `too_broad`. |
| `summary` | object or null | Totals over every matching facility. `null` unless `status` is `found`. |
| `summary.facilities` | integer | Facilities that match. |
| `summary.with_significant_violations` | integer | Facilities in significant noncompliance: Significant Non-Compliers, or High Priority Violators under the Clean Air Act, in at least one program. |
| `summary.with_current_violations` | integer | Facilities with a current violation. |
| `summary.with_violations_3_years` | integer | Facilities with a violation in at least one of the last 12 quarters. |
| `summary.with_formal_actions_5_years` | integer | Facilities with a formal enforcement action in the last 5 years. |
| `summary.with_informal_actions_5_years` | integer | Facilities with an informal enforcement action in the last 5 years. |
| `summary.inspected_5_years` | integer | Facilities inspected or evaluated in the last 5 years. |
| `summary.penalties_5_years` | number | Penalties assessed against the matching facilities over 5 years, in US dollars. |
| `facilities` | array of objects | Up to 10 matching facilities, most serious record first. |
| `facilities.registry_id` | string | The FRS identifier of the facility. |
| `facilities.name` | string | Facility name as EPA records it. |
| `facilities.street`, `facilities.city`, `facilities.state`, `facilities.zip` | string or null | Facility address. |
| `facilities.naics_codes`, `facilities.sic_codes` | array of strings | The NAICS and SIC codes EPA records for the facility. |
| `facilities.compliance_status` | string or null | The overall status EPA reports, such as `Significant Violation`, `Violation Identified`, `Violation` or `No Violation Identified`. |
| `facilities.significant_non_compliance` | boolean | `true` when the facility is a Significant Non-Complier or High Priority Violator in at least one program. |
| `facilities.quarters_in_noncompliance` | integer or null | Quarters in violation out of the last 12. |
| `facilities.inspections_5_years` | integer or null | Inspections and evaluations in the last 5 years. |
| `facilities.last_inspection` | string or null | Date of the latest one, `YYYY-MM-DD`. |
| `facilities.formal_actions_5_years` | integer or null | Formal enforcement actions in the last 5 years. |
| `facilities.last_formal_action` | string or null | Date of the latest one, `YYYY-MM-DD`. |
| `facilities.penalties_5_years` | number or null | Penalties of the last 5 years, in US dollars. |
| `facilities.last_penalty`, `facilities.last_penalty_amount` | string or null, number or null | Date and amount of the latest penalty. |
| `facilities.url` | string | The Detailed Facility Report of the facility on ECHO. |
| `credits_used` | integer | Credits debited for this call: 1 when `status` is `found` with a live key, else `0`. |
| `cached` | boolean | `true` when the answer came from the 7-day cache. |

This example shows 2 of the 10 facilities returned:

```json title="Response"
{
  "id": "lkp_01M8CEFGHB1RXTWPNPJ78EKP1N",
  "object": "epa_compliance",
  "input": "Tesla",
  "query": { "name": "TESLA", "registry_id": null, "state": "CA" },
  "status": "found",
  "summary": {
    "facilities": 246,
    "with_significant_violations": 1,
    "with_current_violations": 5,
    "with_violations_3_years": 10,
    "with_formal_actions_5_years": 1,
    "with_informal_actions_5_years": 3,
    "inspected_5_years": 14,
    "penalties_5_years": 275000
  },
  "facilities": [
    {
      "registry_id": "110000482898",
      "name": "TESLA MOTORS INC",
      "street": "45500 FREMONT BLVD",
      "city": "FREMONT",
      "state": "CA",
      "zip": "94538",
      "naics_codes": ["33611", "336110", "336111", "336399"],
      "sic_codes": ["3711"],
      "compliance_status": "Significant Violation",
      "significant_non_compliance": true,
      "quarters_in_noncompliance": 12,
      "inspections_5_years": 7,
      "last_inspection": "2025-07-23",
      "formal_actions_5_years": 1,
      "last_formal_action": "2022-02-17",
      "penalties_5_years": 275000,
      "last_penalty": "2022-02-17",
      "last_penalty_amount": 275000,
      "url": "https://echo.epa.gov/detailed-facility-report?fid=110000482898"
    },
    {
      "registry_id": "110071138550",
      "name": "TESLA INC",
      "street": "700 D'ARCY PARKWAY",
      "city": "LATHROP",
      "state": "CA",
      "zip": "95330",
      "naics_codes": ["335910"],
      "sic_codes": [],
      "compliance_status": "Violation",
      "significant_non_compliance": false,
      "quarters_in_noncompliance": 7,
      "inspections_5_years": 1,
      "last_inspection": "2025-05-20",
      "formal_actions_5_years": 0,
      "last_formal_action": null,
      "penalties_5_years": 0,
      "last_penalty": null,
      "last_penalty_amount": 0,
      "url": "https://echo.epa.gov/detailed-facility-report?fid=110071138550"
    }
  ],
  "credits_used": 1,
  "cached": false
}
```

## Act on the status

| `status` | What it means | What to do | Billed |
|---|---|---|---|
| `found` | At least one facility matches. | Read `summary` for the overall record, then each facility. Check addresses: a name search can match unrelated facilities with a similar name. | Yes, and cached 7 days |
| `not_found` | No active facility matches the name, or no facility has the registry ID. | Try a shorter part of the name, or the name of the plant rather than of the group. A company with no regulated facility has no record. | No |
| `too_broad` | ECHO refused the search because it matches too many facilities. | Add a `state`, or send a longer name. | No |

Answers other than `found` are never cached, so the next request asks ECHO again.

## How the lookup works

1. A name is trimmed, its spaces collapsed and turned to upper case; a state is turned to upper case.
2. The ECHO facility search is called with the name, matched anywhere in the facility name among active facilities only, or with the registry ID, whatever the status of the facility, and with the state when you sent one. ECHO answers with the totals of every matching facility, which become `summary`, and an identifier for the rows. When ECHO answers that the search would return too many facilities, the status is `too_broad`.
3. The first 1,000 facility rows are read with that identifier.
4. They are ranked by seriousness: significant noncompliance first, then the number of formal actions, the penalties, the quarters in noncompliance, the compliance status and the number of inspections, then by name. The first 10 are returned.

ECHO combines the inspection, violation and enforcement data of the Clean Air Act, the Clean Water Act, the Resource Conservation and Recovery Act and the Safe Drinking Water Act, much of it reported by the states. Actions taken under state law alone may be missing, and a company can run facilities under names a search does not match.

## Examples

### Search a name with a test key

Test keys return a sample facility without calling ECHO: a name that contains `nomatch` returns `not_found`, the name `inc` returns `too_broad`, and any other name or registry ID returns the sample below. With a test key in `QELKA_API_KEY`, this request returns:

```bash title="cURL"
curl https://api.qelka.com/v1/epa/compliance \
  --max-time 60 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Acme Widgets", "state": "il"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/epa/compliance', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ name: 'Acme Widgets', state: 'il' }),
  signal: AbortSignal.timeout(60_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/epa/compliance",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"name": "Acme Widgets", "state": "il"},
    timeout=60,
)
result = response.json()
print(result)
```

```json title="Response"
{
  "id": "lkp_01M8CG31R7XW4TQ2B9NDKZ6H5E",
  "object": "epa_compliance",
  "input": "Acme Widgets",
  "query": { "name": "ACME WIDGETS", "registry_id": null, "state": "IL" },
  "status": "found",
  "summary": {
    "facilities": 1,
    "with_significant_violations": 0,
    "with_current_violations": 1,
    "with_violations_3_years": 1,
    "with_formal_actions_5_years": 1,
    "with_informal_actions_5_years": 0,
    "inspected_5_years": 1,
    "penalties_5_years": 12500
  },
  "facilities": [
    {
      "registry_id": "110000000001",
      "name": "ACME WIDGETS PLANT",
      "street": "1 TEST WAY",
      "city": "SPRINGFIELD",
      "state": "IL",
      "zip": "62701",
      "naics_codes": ["332999"],
      "sic_codes": ["3499"],
      "compliance_status": "Violation Identified",
      "significant_non_compliance": false,
      "quarters_in_noncompliance": 2,
      "inspections_5_years": 3,
      "last_inspection": "2026-03-10",
      "formal_actions_5_years": 1,
      "last_formal_action": "2025-08-14",
      "penalties_5_years": 12500,
      "last_penalty": "2025-08-14",
      "last_penalty_amount": 12500,
      "url": "https://echo.epa.gov/detailed-facility-report?fid=110000000001"
    }
  ],
  "credits_used": 0,
  "cached": false
}
```

## Errors

| Status | Type | When |
|---|---|---|
| 400 | [invalid_request](https://qelka.com/docs/errors#invalid_request) | Both or neither of `name` and `registry_id`, `name` shorter than 2 or longer than 120 characters, `registry_id` that is not 12 digits, `state` that is not 2 letters, a body that is not a JSON object, or a field the request table does not list |
| 401 | [invalid_api_key](https://qelka.com/docs/errors#invalid_api_key) | The key is missing, unknown or revoked |
| 402 | [insufficient_credits](https://qelka.com/docs/errors#insufficient_credits) | Your balance is less than 1 credit (live keys only) |
| 403 | [forbidden](https://qelka.com/docs/errors#forbidden) | The key is restricted to other endpoints |
| 405 | [invalid_request](https://qelka.com/docs/errors#invalid_request) | The method is not `POST` |
| 429 | [rate_limited](https://qelka.com/docs/errors#rate_limited) | Too many requests: wait `Retry-After` seconds |
| 500 | [internal_error](https://qelka.com/docs/errors#internal_error) | Unexpected error on our side: retry with backoff |
| 502 | [upstream_unavailable](https://qelka.com/docs/errors#upstream_unavailable) | ECHO could not be reached, answered with an error, refused the search for a reason other than its size, or did not answer in time: retry later |

No error is billed. A search that matches nothing, or too much, is not an error: it is a `200` with `status: "not_found"` or `"too_broad"` and `credits_used: 0`.

## Related

- [EPA compliance API](https://qelka.com/products/epa-compliance)
- Free tools: [EPA compliance check](https://qelka.com/tools/epa-compliance-check), [SIC code lookup](https://qelka.com/tools/sic-code-lookup), [NAICS code lookup](https://qelka.com/tools/naics-code-lookup)
- [Batch](https://qelka.com/docs/api-reference/batch): up to 100 lookups in one call, each item with `type: "epa_compliance"`
- [Bulk](https://qelka.com/docs/api-reference/bulk): a whole column of facility names or registry IDs with `type=epa_compliance`
- [Caching](https://qelka.com/docs/caching), [Errors](https://qelka.com/docs/errors), [Test mode](https://qelka.com/docs/test-mode)
