Skip to content

Public API

Every endpoint below is read-only (GET), CORS-enabled, and backed by the same D1 tables shown on /status. Base URL: https://api.tajammalhussains.uk

Caching & rate limits

GET /api/v1/health

Liveness check — confirms the database is reachable.

{ "status": "ok", "time": "2026-01-01T12:00:00.000Z" }
GET /api/v1/carbon/current

The most recent half-hourly UK grid carbon intensity reading, plus generation mix for that period.

{
  "data": {
    "periodFrom": "2026-01-01T12:00Z",
    "periodTo": "2026-01-01T12:30Z",
    "actualIntensity": 61,
    "forecastIntensity": 52,
    "indexBand": "low",
    "generationMix": [{ "fuel_type": "wind", "percentage": 26.6 }]
  },
  "cacheHit": false
}
GET /api/v1/carbon/history?from=YYYY-MM-DD&to=YYYY-MM-DD&granularity=daily|raw

Historical readings. `daily` returns gold aggregates (one row per day); `raw` returns every silver reading in range.

{ "data": [{ "date": "2026-01-01", "avg_actual_intensity": 61.2, "reading_count": 48 }] }
GET /api/v1/carbon/mix?date=YYYY-MM-DD

Generation mix (fuel type shares) for a given date, or the most recent date if omitted.

{ "data": { "date": "2026-01-01", "mix": [{ "fuel_type": "wind", "avg_share": 26.6 }] } }
GET /api/v1/housing/regional?region=

Regional UK house price aggregates (HM Land Registry UK HPI, monthly) — 14 UK regions, average price plus month-on-month and year-on-year change. Omit `region` for the latest snapshot across all regions.

{
  "data": [
    {
      "period": "2026-06",
      "region": "london",
      "average_price": 553870,
      "mom_change_pct": null,
      "yoy_change_pct": null,
      "computed_at": "2026-08-25 07:47:33"
    }
  ]
}
GET /api/v1/meta/events?limit=

The site meta-pipeline's own event log — daily self-referential snapshots of every other pipeline's health, plus real deploy/build events reported by CI.

{
  "data": [
    {
      "id": 1,
      "eventType": "analytics_snapshot",
      "occurredAt": "2026-08-25T08:04:00.446Z",
      "detail": {
        "pipelineRunCounts": { "carbon": { "success": 3, "failed": 0, "running": 0 } },
        "qualityCheckFailures24h": 0,
        "totalAuditActions": 6,
        "bronzeObjectsTotal": 22
      }
    }
  ]
}
GET /api/v1/pipelines/status

Every pipeline's config, last run, and most recent data-quality check results.

{ "data": [{ "pipeline": "carbon", "paused": false, "lastRun": { "status": "success" } }] }