# publicsafetyapi.dev — LLM Reference publicsafetyapi.dev is a REST API for US public safety facilities: police stations, fire stations, hospitals, and EMS bases. Built on HIFLD (Homeland Infrastructure Foundation-Level Data), maintained by DHS/CISA. Public domain, commercially usable. Base URL: https://api.publicsafetyapi.dev Current version: v1 Data vintage: HIFLD 2024 (loaded May 2026) Coverage: 50,000+ facilities across the United States. Facility types: fire, police, hospital, ems --- ## Authentication Pass an API key on every request using one of: Header: X-API-Key: psk_live_... Header: Authorization: Bearer psk_live_... API keys are obtained free at https://publicsafetyapi.dev/dashboard (500 requests/month, no credit card). GET /v1/health does NOT require an API key. --- ## Rate Limits | Plan | Per minute | Per month | |------------|------------|-----------| | Free | 10 | 500 | | Starter | 60 | 10,000 | | Pro | 120 | 50,000 | | Growth | 300 | 200,000 | Exceeding per-minute limit → 429 RATE_LIMITED Exceeding monthly limit → 402 QUOTA_EXCEEDED Monthly quotas reset on the 1st of each calendar month. --- ## Response Envelope Every successful response uses this envelope: { "data": , "meta": { "requestId": "req_a1b2c3d4", "creditsUsed": 1, "creditsRemaining": 499 }, "source": { "dataVersion": "2026-05", "updatedAt": "2026-05-27" } } Field names in responses are camelCase (e.g. entityType, distanceMiles, jurisdictionNote). Each API call costs 1 credit regardless of results returned. --- ## Facility Types fire Fire stations (HIFLD Fire Stations dataset) police Police/law enforcement locations (HIFLD Local Law Enforcement Locations) hospital Hospitals (HIFLD Hospitals) ems EMS stations (HIFLD EMS Stations) --- ## Endpoints ### GET /v1/stations/nearby Find the nearest public safety facilities to a coordinate. Returns stations sorted by distance ascending. Required parameters: lat number Latitude (WGS84) lon number Longitude (WGS84) Optional parameters: type enum "fire" | "police" | "hospital" | "ems" (omit to return all types) radius number Search radius in miles. Min 0.1, max 100, default 10 limit integer Max results. Min 1, max 100, default 10 Example request: GET /v1/stations/nearby?lat=34.50&lon=-117.19&type=fire&radius=10&limit=5 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. Path parameter: station_id string e.g. "fire_CA_12345" Response: same Station schema, wrapped in "data": { ... } (not an array). --- ### GET /v1/stations List all stations. Filter by type and/or state. Optional parameters: type enum "fire" | "police" | "hospital" | "ems" state string Two-letter state abbreviation (e.g. "CA") limit integer Results per page. Max 1000, default 100 offset integer Pagination offset. Default 0 --- ### GET /v1/jurisdiction Determine which Census-defined jurisdiction contains a coordinate. Required parameters: lat number Latitude (WGS84) lon number Longitude (WGS84) Example request: GET /v1/jurisdiction?lat=34.50&lon=-117.19 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 by type. Path parameter: code string Two-letter state abbreviation (e.g. "CA") Example response: { "data": { "state": "CA", "counts": { "fire": 3210, "police": 1845, "hospital": 512, "ems": 934 }, "total": 6501 } } --- ### GET /v1/health Service health check. No credit consumed. No API key required. Example response: { "status": "ok", "db": true, "source": { "data_version": "2026-05", "data_updated_at": "2026-05-27" } } --- ## Station Object Schema id string Unique station ID (format: "{type}_{state}_{hifld_id}") name string Facility name type enum "fire" | "police" | "hospital" | "ems" address.street string Street address address.city string City address.state string Two-letter state abbreviation address.zip string ZIP code phone string Phone number (often null) geo.lat number Latitude (WGS84) geo.lng number Longitude (WGS84) distance_miles number Only present in /v1/stations/nearby responses Any field may be null when not present in HIFLD source data. --- ## Error Response Schema All errors return: { "detail": { "code": "ERROR_CODE", "message": "Human-readable description" } } Error codes: 400 INVALID_PARAMS Required parameters missing or invalid 401 INVALID_API_KEY Key missing, invalid, or revoked 402 QUOTA_EXCEEDED Monthly request quota reached 404 STATION_NOT_FOUND No station found for that ID 404 NO_STATIONS_NEARBY No stations within the requested radius 429 RATE_LIMITED Too many requests per minute 500 INTERNAL_ERROR Server error --- ## Common LLM Use Cases Finding the nearest fire station to a location: GET /v1/stations/nearby?lat=&lon=&type=fire&radius=10&limit=1 → data[0] is the nearest fire station. Finding all nearby emergency services: GET /v1/stations/nearby?lat=&lon=&limit=20 → Returns mix of all facility types, sorted by distance. Finding the nearest hospital: GET /v1/stations/nearby?lat=&lon=&type=hospital&radius=25&limit=1 Determining jurisdiction for a location: GET /v1/jurisdiction?lat=&lon= → Returns city and county names, useful for routing or coverage reporting. Getting state facility counts: GET /v1/states/CA/summary → Returns breakdown by type for California. --- ## Data Source HIFLD — Homeland Infrastructure Foundation-Level Data: Agency: Department of Homeland Security / CISA License: Public domain, commercial use permitted URL: https://hifld-geoplatform.hub.arcgis.com/ Datasets used: Local Law Enforcement Locations (police) Fire Stations (fire) Hospitals (hospital) EMS Stations (ems) Jurisdiction boundaries from Census TIGER/Line 2024 incorporated places and counties. PostGIS spatial indexing enables sub-100ms nearby queries. --- ## Links Homepage: https://publicsafetyapi.dev Demo: https://publicsafetyapi.dev/demo Docs: https://publicsafetyapi.dev/docs Pricing: https://publicsafetyapi.dev/pricing Status: https://publicsafetyapi.dev/status Support: hello@districtapi.dev