{"openapi":"3.1.0","info":{"title":"Greenhour API","version":"1.0.0","description":"Carbon intensity of electricity in Great Britain: current value, 48-hour forecast and a best-window optimiser. A concept project built on the NESO Carbon Intensity API (CC BY 4.0). Responses are cached for 30 minutes.","license":{"name":"Data: CC BY 4.0, NESO Carbon Intensity API"}},"servers":[{"url":"/"}],"paths":{"/api/v1/now":{"get":{"summary":"Current carbon intensity","parameters":[{"name":"region","in":"query","required":false,"description":"Region id 1–14 or 18 (Great Britain), or a slug such as london, north-scotland, gb (see /api/v1/regions). Default 13 (London).","schema":{"type":"string","default":"13","examples":["13","london","north-scotland","gb"]}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Now"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/forecast":{"get":{"summary":"48-hour half-hourly forecast","parameters":[{"name":"region","in":"query","required":false,"description":"Region id 1–14 or 18 (Great Britain), or a slug such as london, north-scotland, gb (see /api/v1/regions). Default 13 (London).","schema":{"type":"string","default":"13","examples":["13","london","north-scotland","gb"]}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Forecast"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/best-window":{"get":{"summary":"Cleanest window for a job","description":"Sliding-window search over the 48-hour forecast. Returns the window with the lowest mean intensity that ends by finish_by, and the saving versus starting now.","parameters":[{"name":"region","in":"query","required":false,"description":"Region id 1–14 or 18 (Great Britain), or a slug such as london, north-scotland, gb (see /api/v1/regions). Default 13 (London).","schema":{"type":"string","default":"13","examples":["13","london","north-scotland","gb"]}},{"name":"hours","in":"query","description":"Duration in hours, multiples of 0.5, 0.5–12.","schema":{"type":"number","default":2,"minimum":0.5,"maximum":12}},{"name":"finish_by","in":"query","description":"Latest finish time, HH:MM 24-hour London time. The next occurrence is used. Omit for any time in the next 48 hours.","schema":{"type":"string","pattern":"^([01]\\d|2[0-3]):[0-5]\\d$","example":"07:00"}},{"name":"kwh","in":"query","description":"Energy the job uses, to return savedGrams.","schema":{"type":"number","minimum":0}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BestWindow"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/regions":{"get":{"summary":"Regions with 12-month statistics","responses":{"200":{"description":"OK"}}}}},"components":{"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"enum":["invalid_parameter","upstream_unavailable","not_enough_forecast","not_found"]},"message":{"type":"string"},"hint":{"type":"string"}}}}},"Now":{"type":"object","properties":{"region":{"type":"object"},"intensity":{"type":"number","description":"gCO2/kWh"},"index":{"type":"string"},"basis":{"enum":["measured","forecast"]},"vsTypicalPercent":{"type":["number","null"]}}},"Forecast":{"type":"object","properties":{"slots":{"type":"array","items":{"type":"object","properties":{"from":{"type":"string"},"to":{"type":"string"},"intensity":{"type":"number"},"index":{"type":"string"}}}}}},"BestWindow":{"type":"object","properties":{"window":{"type":"object","properties":{"start":{"type":"string"},"end":{"type":"string"},"avgIntensity":{"type":"number"},"baselineAvgIntensity":{"type":"number"},"savedGPerKwh":{"type":"number"},"savedPercent":{"type":"number"},"savedGrams":{"type":["number","null"]},"startsNow":{"type":"boolean"}}}}}}}}