Marmaradar API – Usage via Gateway

All APIs are consumed through the Marmaradar gateway. This site (api.marmaradar.com) hosts documentation only — send API requests to the gateway base URL below.

Base URL (production): http://35.239.129.237:8081
Base URL (local): http://127.0.0.1:8081
Documentation URL: https://api.marmaradar.com/docs/apiusage.html
OpenAPI spec: /openapi.json — machine-readable subset; this page is the full usage guide.

1. Authentication

Most endpoints require a JWT. Send it in the header:

Authorization: Bearer <your_access_token>

Obtain a token via the Auth API (no token required). When the access token expires, call POST /v1/auth/refresh with the refresh_token.

MethodPathAuthDescription
POST /v1/auth/register None Register with email and password (min. 8 characters). Returns access + refresh tokens and user info.
POST /v1/auth/login None Email/password login; returns access + refresh tokens and user info.
POST /v1/auth/refresh None Rotate tokens. Body: refresh_token.
POST /v1/auth/oauth None Google/Apple sign-in. Body: provider (google | apple), id_token, optional nonce (Apple).
POST /v1/auth/forgot-password None Request password reset email. Body: email. Response: {"ok": true}.
POST /v1/auth/reset-password None Complete reset with token (from email) and password (min. 8). Response: {"ok": true}.
GET /reset-password None HTML reset form (query: token). Not a JSON API.

2. API Areas (via Gateway)

All paths below are relative to the gateway base URL. Protected routes expect Authorization: Bearer <access_token>.

Route prefixes:

2.1 Auth

/v1/auth/* — Register, login, refresh, OAuth, forgot/reset password (see table above). No Bearer token required.

2.2 Geo data (cameras, corridors, sync)

/v1/cameras/* · /v1/corridors/* · /v1/sync — Public map data. No auth.

2.3 Users, stats & leaderboard

/v1/users/* · /v1/leaderboard — Require Bearer token.

2.4 Drives

/v1/drives/* — Recorded trips. Requires Bearer token.

2.5 Reports (crowd / mobile radar)

/v1/reports/* — Requires Bearer token.

2.6 Live reports

/v1/live-reports/* — Short-lived hazards (police / accident).

2.7 ETA, amenities & TTS

All require Bearer token.

3. Request & response DTOs (reference)

JSON uses snake_case property names. Date/time values are ISO 8601 (RFC3339). Errors return {"error": "human-readable message"} with an appropriate HTTP status.

3.1 Auth

Request bodies

EndpointProperties (JSON)
POST /v1/auth/registeremail, password (min. 8)
POST /v1/auth/loginemail, password
POST /v1/auth/refreshrefresh_token
POST /v1/auth/oauthprovider, id_token, nonce (optional, Apple)
POST /v1/auth/forgot-passwordemail
POST /v1/auth/reset-passwordtoken, password (min. 8)

AuthResult (register / login / refresh / oauth)

{
  "access_token": "string (JWT)",
  "refresh_token": "string",
  "expires_in": 900,
  "user": { "id": "uuid", "email": "string" }
}

3.2 Users & preferences

UserProfileResponse — GET/PATCH /v1/users/me, profile-picture upload:

{
  "id": "uuid",
  "email": "string",
  "username": "string | null",
  "profile_picture_url": "/v1/uploads/avatars/{id}.jpg | null",
  "vehicle_type": "sedan | hatchback | station_wagon | kamyon | tir",
  "vehicle_color": "#RRGGBB"
}

UpdatePreferencesRequest — PATCH /v1/users/me (partial; omit unchanged fields):

{
  "username": "string (optional; a-z0-9_; 3–20; unique)",
  "vehicle_type": "sedan | hatchback | station_wagon | kamyon | tir",
  "vehicle_color": "#RRGGBB"
}

profile_picture_url is a relative path on the gateway. Display as http://35.239.129.237:8081 + path. Avatars need no Bearer token.

3.3 Leaderboard

GET /v1/leaderboard?category=distance|reports returns:

{
  "category": "distance",
  "entries": [
    {
      "rank": 1,
      "user_id": "uuid",
      "username": "string",
      "profile_picture_url": "string | null",
      "vehicle_type": "sedan",
      "vehicle_color": "#E8262D",
      "value": 152340.5
    }
  ],
  "me": { "rank": 142, "user_id": "uuid", "username": "string", "...": "...", "in_top": false }
}

value is meters for distance, contribution count for reports. Top 100 plus always the caller’s me row.

3.4 Drives

Create — POST /v1/drives:

{
  "started_at": "2026-01-01T12:00:00Z",
  "ended_at": "2026-01-01T12:30:00Z",
  "name": "string | null",
  "points": [
    { "lat": 0, "lon": 0, "speed_mps": 0, "recorded_at": "2026-01-01T12:00:00Z" }
  ]
}

List/detail include summary fields (length_m, point_count, speed stats). Detail also returns points[] and optional snapped_points[].

3.5 Reports & live reports

Create report — POST /v1/reports: lat, lon, optional heading_deg, region. Response includes id, status, votes, expires_at, merged.

Vote — POST /v1/reports/{id}/votes: value (1|-1), lat, lon.

Live report — POST /v1/live-reports: lat, lng, report_type (police|accident). Active list returns id, lat, lng, report_type, verification_state, weighted_score, timestamps.

3.6 ETA, amenities & TTS

ETA — POST /v1/eta/cameras:

{
  "origin": { "lat": 0, "lon": 0 },
  "destinations": [{ "camera_id": "string", "lat": 0, "lon": 0 }]
}

Response: [{ "camera_id", "distance_m", "duration_sec", "status" }]. Max 3 destinations. 503 if Matrix API unavailable.

Amenities — POST /v1/amenities/cells: cells[] with lat_index/lon_index; optional types (gas_station, rest_stop). Max 3 cells.

TTS speak — phrase_key examples: camera.fixed, camera.mobile, report.police, corridor.warn, corridor.over. Distance phrases need params.distance_m. Response body is raw audio/mpeg.

3.7 Errors

Validation or business errors typically return 400 with {"error": "string"}. Unauthorized: 401. Forbidden: 403. Not found: 404. Conflict (e.g. username taken, invalid vote): 409. Rate limited: 429.

4. CORS

Allowed origins include https://marmaradar.com, https://www.marmaradar.com, https://api.marmaradar.com, and localhost (e.g. http://localhost:5173). For other origins, coordinate with the API owner.

5. Health

GET {gateway}/health — Returns 200 with {"status":"ok"} if the API is up. No authentication required.

6. Checklist for integrating

Last updated: 2026-09 — switched docs UI to gateway usage guide. When new APIs or DTOs change, update this page and regenerate OpenAPI via backend/scripts/generate-openapi.sh for annotated endpoints.