Server API Reference
All endpoints are served by server/server.js running on Express. The server proxies selected providers and keeps their credentials server-side. See Known Security Limitations for the current client-key and proxy boundaries.
/detect-image, /detect-fdot-batch, /co2-interpolate, and /flood-workshop/replay forward to services in UCF-UrbanGeoLens-backend, which run on Jetstream2 at Indiana University through NSF ACCESS allocation CIS251126. See the Acknowledgments.
Authentication and permissions
Every endpoint below except /tomtom-traffic and the static pages requires Authorization: Bearer <Supabase access token> (the browser adds it automatically, see js/core/access.js). A missing or invalid token returns 401. These also need a permission, otherwise 403:
| Endpoint | Permission |
|---|---|
/em-event-data | feature.emergency |
/sensor-data, /co2-sensors, /co2-sensors/:devId/history, /co2-interpolate | feature.co2 |
/power-outages/duke-fl | feature.power_outage |
/flood-workshop/replay | feature.flood_replay |
/detect-image, /detect-fdot-batch* | feature.detection |
/config?planet=mars, /config?planet=moon | planet.mars, planet.moon |
/admin/api/* | admin.users |
Also added: GET /access/me (the caller's role and permissions), POST /co2-interpolate (server-side relay to the Jetstream2 CO₂ service), and the /admin page. Details: Roles and Permissions.
Endpoints
GET /config
Returns client-safe configuration values from environment variables. Requires a signed-in user; ?planet=mars|moon also requires that world's permission.
Response
{
"cesiumIonToken": "eyJ..."
}
Used by the Earth, Mars, and Moon pages to initialize Cesium.Ion.defaultAccessToken. Co-DETR credentials remain server-side and are not returned here.
GET /cameras
Returns the full NY 511 camera dataset from client/public/data/response.json.
Response, array of camera objects:
[
{
"ID": "TS1",
"Name": "Times Square Camera",
"DirectionOfTravel": "North",
"RoadwayName": "Broadway",
"Latitude": 40.758,
"Longitude": -73.9855,
"Url": "https://...",
"VideoUrl": "https://..."
}
]
GET /tomtom-traffic
Proxies TomTom traffic flow tile images to bypass CORS restrictions.
Query Parameters
| Param | Type | Description |
|---|---|---|
z | number | Tile zoom level |
x | number | Tile X coordinate |
y | number | Tile Y coordinate |
ts | number | Timestamp (cache-busting) |
Response, PNG image (Content-Type: image/png)
GET /fdot-cameras
Proxies Florida DOT CCTV camera data from the TrafficView API.
Response, array of FDOT device objects with location and feed URL properties.
POST /detect-image
Fetches a public image URL and forwards the image to Co-DETR. For each request and redirect, the server validates DNS results and pins the HTTP connection to those checked public addresses while keeping the original hostname for TLS and the Host header. It limits images to 10 MB and gives interactive detections priority over batch work.
| Query parameter | Description |
|---|---|
url | Public HTTP or HTTPS image URL |
score_threshold | Detection threshold from 0 to 1 (default 0.5) |
response_mode | image (default), json, or both; passed through to the Co-DETR backend |
json returns the backend JSON summary. both returns that summary with the rendered image in its image base64 field. image returns the rendered image bytes.
POST /detect-fdot-batch
Starts asynchronous Co-DETR detection for online FDOT cameras whose image-feed URLs are present in the TrafficView camera catalog. The request accepts numeric longitude/latitude bounds and an optional polygon (coordinate pairs are [longitude, latitude]):
{
"region": {
"west": -82,
"south": 27,
"east": -80,
"north": 29,
"polygon": [[-82, 27], [-80, 27], [-80, 29], [-82, 29]]
},
"score_threshold": 0.5
}
The polygon is optional; when provided, a camera must be inside both it and the bounding box. Polygons support 3 to 5,000 points. Responses use HTTP 202 and return the job snapshot, including id, status, progress counters, aggregate vehicle objects/vehicleTotal, and per-camera results. Only car, truck, bus, motorcycle, bicycle, train, boat, and airplane counts are included. A successful zero-count result has status: "succeeded" and vehicleTotal: 0; failed cameras have status: "failed" and an error.
GET /detect-fdot-batch/:id and DELETE /detect-fdot-batch/:id
GET returns the current snapshot; DELETE cancels queued downloads and inference work and returns the canceled snapshot, retaining completed partial results. Job states are queued, running, completed, partial, failed, or canceled. Jobs are limited to two active batches, with four concurrent camera downloads per batch and one serialized Co-DETR request at a time. Interactive /detect-image requests take priority over waiting batch inferences. Completed jobs expire after 30 minutes (with a 30-job in-memory retention cap). Jobs are held in the server process memory, so they cannot be polled after a server restart and are local to one server process.
GET /airnow
Proxies AirNow API to fetch current AQI observations near a zip code.
Query Parameters
| Param | Type | Description |
|---|---|---|
zip | string | US zip code |
Response, AirNow JSON array of observation records.
GET /em-event-data
Fetches active emergency events from the CORD2 Firebase Cloud Function. The server:
- Authenticates anonymously with Firebase (
identitytoolkit.googleapis.com) - Uses the resulting
idTokento callhttps://us-central1-cord2-6c88c.cloudfunctions.net/api/events
Response, array of emergency event objects.
GET /sensor-data
Proxies the Blues Notehub API for legacy Notecard sensor event data.
Query Parameters, none (returns last 50 events from sensors.qo file)
Response, Notehub event array.
GET /co2-sensors
Returns the latest CO₂ sensor reading for every device in the Firebase Firestore devices collection.
Response
[
{
"dev_id": "dev:000000000000001",
"co2": 412,
"humidity": 54.2,
"temp": 23.1,
"lat": 28.5,
"lon": -81.3,
"time": 1700000000,
"last_seen": 1700000000
}
]
Each object is a flattened reading from devices/{devId}/readings/{doc}.data.readings[0].
GET /co2-sensors/:devId/history
Returns historical CO₂ readings for a specific sensor device, with optional time filtering and automatic downsampling.
Path Parameters
| Param | Description |
|---|---|
devId | Device ID (e.g. dev:000000000000001) |
Query Parameters
| Param | Type | Description |
|---|---|---|
duration | string | Shorthand duration: 24h, 7d, 30d. Overrides start/end. |
start | number | Unix timestamp (seconds), start of range |
end | number | Unix timestamp (seconds), end of range |
sample | number | Target number of data points to return (default: 200) |
Response
{
"events": [
{
"body": { "readings": [{ "co2": 410, "temp": 22, "humidity": 53 }] },
"when": 1700000000
}
]
}
The server reads up to 5,000 Firestore documents and downsamples to sample points if needed.
GET /proxy-image
Proxies an image from any URL to bypass client-side CORS restrictions.
Query Parameters
| Param | Description |
|---|---|
url | Full URL of the image to proxy |
Response, raw image data with original Content-Type header.
See Known Security Limitations before passing untrusted URLs to this route.
GET /ny511-cameras
Proxy endpoint for the 511NY API. Requires NY511_API_KEY environment variable.
Response, 511NY API response (camera list).
GET /flood-workshop/replay
Proxies the Hurricane Ian flood replay dataset from the JetStream2 backend (FLOOD_BACKEND_URL, defaults to the UCF JetStream2 host).
Response, full replay payload: meta, grid, timeline, shelters, frames. See Hurricane Ian Flood Replay for the field-level breakdown.
Returns 503 while the backend is still pre-computing the simulation at startup.
Known Security Limitations
- The Earth client contains browser-visible provider keys for Google 3D Tiles and OpenWeatherMap. Restrict browser keys with the provider's referrer and API controls; treat them as public.
- Emergency-event and FDOT camera values from external services are interpolated into Earth popup
innerHTMLand inline handlers (createEmergencyEventInfoBoxand the FDOT camera popup). This leaves a DOM-injection risk if those feeds contain markup or script payloads. /proxy-imagefetches its supplied URL directly without restricting the host to public addresses, so callers can make the server request internal network addresses. Do not use it with untrusted URLs. The separate/detect-imageflow validates public image hosts and redirects.
Error Handling
Most JSON API endpoints return JSON error objects on failure. /airnow and /proxy-image use plain-text errors, as does /tomtom-traffic when tile parameters are missing:
{ "error": "Human-readable description", "details": "..." }
HTTP status codes follow standard conventions: 400 for bad input, 500/503 for server/upstream errors.
GET /power-outages/duke-fl
Live Duke Energy Florida outages, from the same free feed outagemap.duke-energy.com uses. Cached 5 minutes; on upstream failure the last good payload is returned with stale: true.
{
"source": "Duke Energy Florida",
"fetchedAt": "ISO timestamp",
"totals": { "outages": 16, "customersAffected": 89, "customersServed": 2052172 },
"outages": [{ "id", "lat", "lng", "customersAffected", "cause", "countyFips", "countyName", "hull" }],
"counties": [{ "fips", "name", "customersServed", "customersAffected", "outageCount", "pctOut", "geometry" }]
}
Counties are matched by point-in-polygon against client/public/data/us_counties_fips.geojson, so fips joins directly to the SVI CSV. Coverage is Duke customers only (not OUC, FPL, TECO or co-ops).