API Reference

Base URL: https://api.publicsafetyapi.dev·Current version: v1·Data: HIFLD 2024

Authentication

Pass your API key via the X-API-Key header on every request. Alternatively, use Authorization: Bearer <key>.

curl "https://api.publicsafetyapi.dev/v1/stations/nearby?lat=34.50&lon=-117.19&type=fire" \
  -H "X-API-Key: psk_live_your_api_key"

Rate Limits

Two limits apply on every request:

PlanPer minutePer month
Free10 req/min500 req
Starter60 req/min10,000 req
Pro120 req/min50,000 req
Growth300 req/min200,000 req

Monthly quotas reset on the 1st of each calendar month. Exceeding the per-minute limit returns 429. Exceeding the monthly quota returns 402.

Endpoints

GET/v1/stations/nearby

Find the nearest public safety facilities to a coordinate, filtered by type. The primary endpoint — lat/lon in, ranked stations out.

Query Parameters
latnumberrequiredLatitude (WGS84)
lonnumberrequiredLongitude (WGS84)
typeenumoptional"fire" | "police" | "hospital" | "ems". Omit to return all types.
radiusnumberoptionalSearch radius in miles. Min 0.1, max 100, default 10.
limitintegeroptionalMax results. Min 1, max 100, default 10.
Example Response
{
  "data": [
    {
      "id": "fire_CA_12345",
      "name": "Apple Valley Fire Station 335",
      "type": "fire",
      "address": { "street": "20763 US-18", "city": "Apple Valley", "state": "CA", "zip": "92308" },
      "phone": null,
      "geo": { "lat": 34.4801, "lng": -117.2091 },
      "distance_miles": 1.47
    }
  ],
  "meta": { "requestId": "req_a1b2c3d4", "creditsUsed": 1, "creditsRemaining": 499 },
  "source": { "dataVersion": "2026-05", "updatedAt": "2026-05-27" }
}
GET/v1/stations/{station_id}

Get a single station by its ID.

GET/v1/stations

List all stations. Filter by type and/or state. Results are paginated.

Query Parameters
typeenumoptional"fire" | "police" | "hospital" | "ems"
statestringoptionalTwo-letter state abbreviation (e.g. CA)
limitintegeroptionalResults per page. Max 1000, default 100.
offsetintegeroptionalPagination offset. Default 0.
GET/v1/jurisdiction

Determine which Census-defined jurisdiction (city/town or county) contains a coordinate. Useful for building coverage reports or routing context.

Query Parameters
latnumberrequiredLatitude (WGS84)
lonnumberrequiredLongitude (WGS84)
Example Response
{
  "data": {
    "city": { "geoid": "0603526000", "name": "Apple Valley", "state": "CA", "type": "town" },
    "county": { "geoid": "06071", "name": "San Bernardino County", "state": "CA" }
  },
  "meta": { "requestId": "req_e5f6g7h8", "creditsUsed": 1, "creditsRemaining": 498 }
}
GET/v1/states/{code}/summary

State-level facility counts broken down by type.

Example Response
{
  "data": {
    "state": "CA",
    "counts": {
      "fire": 3210,
      "police": 1845,
      "hospital": 512,
      "ems": 934
    },
    "total": 6501
  },
  "meta": { ... },
  "source": { "dataVersion": "2026-05", "updatedAt": "2026-05-27" }
}
GET/v1/health

Service health check. Returns DB connectivity and data freshness. Does NOT consume a credit and does NOT require an API key.

Response Envelope

Every response is wrapped in a consistent envelope. Field names are camelCase.

{
  "data": { ... },
  "meta": {
    "requestId": "req_a1b2c3d4",
    "creditsUsed": 1,
    "creditsRemaining": 499
  },
  "source": {
    "dataVersion": "2026-05",
    "updatedAt": "2026-05-27"
  }
}

Error Codes

All errors return a consistent JSON body:

{
  "detail": {
    "code": "NO_STATIONS_NEARBY",
    "message": "No stations within 10 miles."
  }
}
HTTPCodeDescription
400INVALID_PARAMSRequired parameters are missing or invalid.
401INVALID_API_KEYThe API key is missing, invalid, or deactivated.
402QUOTA_EXCEEDEDMonthly request quota reached. Upgrade or wait for the monthly reset.
404STATION_NOT_FOUNDNo station found for the given ID.
404NO_STATIONS_NEARBYNo stations within the requested radius. Try a larger radius.
429RATE_LIMITEDToo many requests per minute. Slow down and retry.
500INTERNAL_ERRORUnexpected server error. Contact support if this persists.
📊

Data source

All records trace back to HIFLD (Homeland Infrastructure Foundation-Level Data), maintained by DHS/CISA. Public domain, commercially usable.

Datasets: Local Law Enforcement Locations, Fire Stations, Hospitals, and EMS Stations. Facility coordinates are WGS84, spatial-indexed with PostGIS for sub-100ms nearby queries.

We supplement with Census TIGER incorporated places and counties for the jurisdiction endpoint.

🤖

AI integration

A machine-readable reference covering all endpoints, schemas, and examples lives at:

publicsafetyapi.dev/llms.txt