Skip to main content

Server API Reference

All endpoints are served by server/server.js running on Express. The server acts as both a static file host and an API proxy layer — external API keys never reach the browser.

Endpoints

GET /config

Returns client-safe configuration values from environment variables.

Response

{
"cesiumIonToken": "eyJ...",
"codetrApiKey": "..."
}

Used by app.js on startup to initialize Cesium.Ion.defaultAccessToken.


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

ParamTypeDescription
znumberTile zoom level
xnumberTile X coordinate
ynumberTile Y coordinate
tsnumberTimestamp (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.


GET /airnow

Proxies AirNow API to fetch current AQI observations near a zip code.

Query Parameters

ParamTypeDescription
zipstringUS 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:

  1. Authenticates anonymously with Firebase (identitytoolkit.googleapis.com)
  2. Uses the resulting idToken to call https://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

ParamDescription
devIdDevice ID (e.g. dev:000000000000001)

Query Parameters

ParamTypeDescription
durationstringShorthand duration: 24h, 7d, 30d. Overrides start/end.
startnumberUnix timestamp (seconds) — start of range
endnumberUnix timestamp (seconds) — end of range
samplenumberTarget 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

ParamDescription
urlFull URL of the image to proxy

Response — raw image data with original Content-Type header.


GET /ny511-cameras

Proxy endpoint for the 511NY API. Requires NY511_API_KEY environment variable.

Response — 511NY API response (camera list).


Error Handling

All endpoints return JSON error objects on failure:

{ "error": "Human-readable description", "details": "..." }

HTTP status codes follow standard conventions: 400 for bad input, 500/503 for server/upstream errors.