A small, public JSON API for when Britain’s electricity is cleanest. No key, CORS open, cached for 30 minutes. It runs on route handlers in this site and reads the NESO Carbon Intensity API.
Units: grams of CO₂ per kilowatt-hour (gCO₂/kWh). Times are ISO 8601 in UTC; finish_by is London wall-clock time, DST-aware.
Errors: always { "error": { "code", "message", "hint" } } with a matching status: 400 invalid_parameter, 422 not_enough_forecast, 502 upstream_unavailable.
Validation: every parameter is checked with zod; the first problem is named in message.
Caching: upstream calls revalidate every 30 minutes; responses send s-maxage=1800.
Endpoints
GET /api/v1/now
The current half-hour: intensity in gCO₂/kWh, NESO's index band, generation mix, how it compares with a typical same-weekday, same-hour value from the last 12 months.
region
Region id 1–14, 18 for all of Great Britain, or a slug such as london, north-scotland, south-wales or gb. See /api/v1/regions. Default 13.
GET /api/v1/forecast
48 hours of half-hourly forecast, plus the cleanest and dirtiest slots.
region
Region id 1–14, 18 for all of Great Britain, or a slug such as london, north-scotland, south-wales or gb. See /api/v1/regions. Default 13.
GET /api/v1/best-window
The cleanest contiguous window for a job: a sliding-window search over the forecast that ends by your deadline. Returns the window, its average intensity, the saving against starting now, and grams saved if you pass kwh.
region
Region id 1–14, 18 for all of Great Britain, or a slug such as london, north-scotland, south-wales or gb. See /api/v1/regions. Default 13.
hours
Duration, in steps of 0.5, from 0.5 to 12. Default 2.
finish_by
Latest finish, HH:MM in London time. The next occurrence is used. Omit for any time in the next 48 hours.
kwh
Energy the job uses. Adds savedGrams to the response.
GET /api/v1/regions
The 14 regions plus Great Britain with 12-month statistics: mean, min, max, share of half-hours under 100 g, cleanest and dirtiest hour of the day.
Widget
A tiny card that says clean now or wait until 14:30, tinted by the grid. Paste this anywhere that accepts HTML. Options: region (1–14, 18), hours (default 1).
<iframe src="https://greenhour-grid.vercel.app/embed?region=13"
title="Greenhour: is the grid clean right now?"
width="340" height="190" style="border:0;border-radius:16px" loading="lazy"></iframe>
Data and credit
Intensity and mix come from the Carbon Intensity API by NESO (National Energy System Operator) with the University of Oxford, EDF Energy’s Environmental Defense Fund Europe and WWF, licensed CC BY 4.0. Regional values are NESO’s estimates; Great Britain uses measured values when available. This is a concept project, not an official service and without any uptime promise.