For Developers

Programmatic access to incident data via a REST API. Use the examples below or explore the interactive OpenAPI docs.

Base URL

https://prettigood-production.up.railway.app

OpenAPI (Swagger) docs: https://prettigood-production.up.railway.app/docs

Endpoints

List incidents (paginated)

GET /incidents

Query params: page, page_size, state, agency, city, date_from, date_to, status, fatal, tag, q (search in summary, official_claim, circumstances, agency)

curl -s "https://prettigood-production.up.railway.app/incidents?page=1&page_size=10"
curl -s "https://prettigood-production.up.railway.app/incidents?state=TX&fatal=true"

Get single incident

GET /incidents/{id}

curl -s "https://prettigood-production.up.railway.app/incidents/1"

Statistics

GET /stats/summary — GET /stats/by-state — GET /stats/by-agency — GET /stats/time-series

curl -s "https://prettigood-production.up.railway.app/stats/summary"
curl -s "https://prettigood-production.up.railway.app/stats/by-state"
curl -s "https://prettigood-production.up.railway.app/stats/time-series"

Export CSV or JSON (with optional filters)

GET /data/incidents.csv — GET /data/incidents.json

Same query params as list (state, agency, date_from, date_to, status, fatal, tag). Filename includes scope when filtered.

curl -o incidents.csv "https://prettigood-production.up.railway.app/data/incidents.csv"
curl -o incidents_TX.csv "https://prettigood-production.up.railway.app/data/incidents.csv?state=TX"

Python example

import requests

BASE = "https://prettigood-production.up.railway.app"

# List incidents (e.g. Texas, fatal, last year)
r = requests.get(
    f"{BASE}/incidents",
    params={"state": "TX", "fatal": True, "page_size": 100},
)
incidents = r.json()["items"]

# Export filtered CSV
r = requests.get(f"{BASE}/data/incidents.csv", params={"state": "TX"})
with open("prettigood_TX.csv", "wb") as f:
    f.write(r.content)

Rate limit

The API is rate-limited (e.g. 100 requests per hour per IP). Use filtered exports and pagination for large datasets.

Back to Data Export