OpenMap API Documentation

REST API for OpenMap data layers — crime, census, health, economics, environment, politics, and social data.

Base URL: https://api.getopenmap.com/api/v1/{category} (local: http://localhost:8080/api/v1/{category})

Authentication: Send header x-api-key: <API_DEV_KEY> on all data routes except GET /api/v1/health/ping.

Env keys: Copy backend/.env.example → backend/.env and replace placeholder values. Frontend needs matching VITE_API_DEV_KEY in frontend/.env.

Setup & diagnostics

GET /api/v1/health/ping

Public liveness check. No API key. Returns { "ok": true, "service": "openmap-backend" }.

GET /api/v1/health/status

Shows DB connection and which env vars are configured (boolean only). Requires x-api-key.


/api/v1/census

Requires CENSUS_API_KEY — Census API signup

GET /populationByState

State population estimates from U.S. Census Bureau PEP API.

ParameterRequiredDescription
yearNoData vintage year (default 2023)

Response: { source, year, count, states: [{ name, population, stateFips, stateCode }] }


/api/v1/economics

Requires BEA_API_KEY — BEA API signup

GET /gdpByState

State GDP (millions USD) from Bureau of Economic Analysis Regional accounts.

ParameterRequiredDescription
yearNoFour-digit year (default 2022)

Response: { source, year, count, states: [{ geoFips, geoName, gdpMillions, unit }] }


/api/v1/health

HEALTHDATA_API_KEY is optional (CDC Socrata app token for higher rate limits).

GET /uninsuredRateByState

Adult uninsured rate by state from CDC PLACES (access2_crudeprev).

Response: { source, indicator, count, states: [{ state, stateName, uninsuredPercent }] }


/api/v1/politics

No external API key — data from GovTrack public API.

GET /senators

Current U.S. senators with map coordinates for pin placement.

Response: { source, fetchedAt, count, senators: [{ id, name, state, party, lat, lng, photoUrl, ... }] }

GET /representatives

Current U.S. House representatives (50 states, voting districts).

Response: { source, fetchedAt, count, representatives: [{ id, name, state, district, party, lat, lng, ... }] }


/api/v1/social

No external API key — reference data served from the backend.

GET /ageOfConsentByState

Age of consent by state with map coordinates.

Response: { source, count, states: [{ state, ageOfConsent, latitude, longitude }] }


/api/v1/crime

Requires FBI_CRIME_KEY

GET /murderByState

FBI SHR murder totals by state. Optional year query param.

GET /arrestsByState

FBI arrest totals by state. Optional year, offenseCode.

GET /missingPersons

FBI missing persons CSV with county location data. No external key.


/api/v1/environment

EndpointKey required
GET /airQualityAQICN_API_TOKEN
GET /ghgEmissionsNone (EPA public data)
GET /wasteTreatmentDisposalSitesNone
GET /coalminesEIA_API_KEY
GET /oilSpillsNone (NOAA CSV)
GET /naturalDisasterIncidentsNone (FEMA OpenFEMA)
GET /dataCentersNone (local CSV)

/api/v1/lawEnforcement

GET /enforcementPopulation

FBI personnel data by state. Requires FBI_CRIME_KEY. Optional year.

GET /policeVictimCases

Mapping Police Violence case-level data (XLSX → JSON). No key.

GET /policeVictimDepts

Department-level aggregation. No key.

GET /policeVictimStates

State-level aggregation. No key.

GET /policeGenderViolence

Police sexual violence misconduct database. No key.

Response: { source, count, cases: [{ name, title, state, formOfViolence, arrestOrSentence, link }] }


Auth routes (no x-api-key)

RouteDescription
POST /api/v1/auth/registerRegister user; needs RESEND_API_KEY for email
GET /api/v1/auth/verify?token=...Verify email
POST /api/auth/loginLogin with email/password

Environment variables reference

VariableRequired for
API_DEV_KEYAll protected data routes
MONGODB_URIAuth / user accounts
CENSUS_API_KEYCensus routes
BEA_API_KEYEconomics routes
FBI_CRIME_KEYCrime + law enforcement FBI routes
EIA_API_KEYCoal mines
AQICN_API_TOKENAir quality
HEALTHDATA_API_KEYOptional CDC rate-limit token
RESEND_API_KEYRegistration emails

Error handling

Errors return JSON with an error string. Missing API keys return HTTP 503 with instructions to update backend/.env.

{ "error": "Census API key is still a placeholder. Replace CENSUS_API_KEY in backend/.env with your real API key." }