Documentation ¶
Overview ¶
Package ngeso implements the carbonintensity.org.uk Grid CO2 tracking service, which provides CO2 forecasting for the UK at a national and regional level. This service is provided by the National Grid Electricity System Operator (NGESO).
Index ¶
Constants ¶
const BaseURI = "https://api.carbonintensity.org.uk/"
BaseURI is the root path that the API is accessed from.
const ForecastNationalURI = BaseURI + "intensity/%s/fw48h"
ForecastNationalURI defines the location of the national forecast. Replace the first %s with the RFC3339 timestamp to fetch from.
const ForecastRegionalByIdURI = BaseURI + "regional/intensity/%s/fw48h/regionid/%s"
ForecastRegionalByIdURI defines the location of the regional forecast determined by Region ID. Replace the first %s with the RFC3339 timestamp to fetch from, and the second with the appropriate Region ID.
const ForecastRegionalByPostcodeURI = BaseURI + "regional/intensity/%s/fw48h/postcode/%s"
ForecastRegionalByPostcodeURI defines the location of the regional forecast determined by a given postcode. Replace the first %s with the RFC3339 timestamp to fetch from, and the second with the appropriate postcode.
Variables ¶
var ErrRegionalRequestInvalidFormat = errors.New("regional request object missing region")
Functions ¶
This section is empty.
Types ¶
type CarbonForecastNationalRequest ¶
type CarbonForecastNationalRequest struct{}
func ConstructNationalForecastRequest ¶
func ConstructNationalForecastRequest() *CarbonForecastNationalRequest
ConstructNationalForecastRequest returns a request object to be used when calling the national API.
func (*CarbonForecastNationalRequest) DoRequest ¶
func (r *CarbonForecastNationalRequest) DoRequest(client *request.Helper) (CarbonForecastResponse, error)
func (*CarbonForecastNationalRequest) URI ¶
func (r *CarbonForecastNationalRequest) URI() (string, error)
type CarbonForecastRegionalRequest ¶
type CarbonForecastRegionalRequest struct {
// contains filtered or unexported fields
}
func ConstructRegionalForecastByIDRequest ¶
func ConstructRegionalForecastByIDRequest(r string) *CarbonForecastRegionalRequest
ConstructRegionalForecastByIDRequest returns a validly formatted, fully qualified URI to the forecast valid for the given region.
func ConstructRegionalForecastByPostcodeRequest ¶
func ConstructRegionalForecastByPostcodeRequest(p string) *CarbonForecastRegionalRequest
ConstructRegionalForecastByPostcodeRequest returns a validly formatted, fully qualified URI to the forecast valid for the given postcode.
func (*CarbonForecastRegionalRequest) DoRequest ¶
func (r *CarbonForecastRegionalRequest) DoRequest(client *request.Helper) (CarbonForecastResponse, error)
func (*CarbonForecastRegionalRequest) URI ¶
func (r *CarbonForecastRegionalRequest) URI() (string, error)
type CarbonForecastRequest ¶
type CarbonForecastResponse ¶
type CarbonForecastResponse interface {
Results() []CarbonIntensityForecastEntry
}
type CarbonIntensity ¶
type CarbonIntensity struct { // The forecasted rate in gCO2/kWh Forecast float64 `json:"forecast"` // The rate recorded when this slot occurred - only available historically, otherwise nil Actual float64 `json:"actual"` // A human-readable representation of the level of emissions (e.g "low", "moderate") Index string `json:"index"` }
type CarbonIntensityForecastEntry ¶
type CarbonIntensityForecastEntry struct { ValidityStart shortrfc3339.Timestamp `json:"from"` ValidityEnd shortrfc3339.Timestamp `json:"to"` Intensity CarbonIntensity `json:"intensity"` }
type NationalIntensityResult ¶
type NationalIntensityResult struct {
Rates []CarbonIntensityForecastEntry `json:"data"`
}
NationalIntensityResult is returned either as a sub-element of a Regional request, or as the main result of a National request.
func (NationalIntensityResult) Results ¶
func (r NationalIntensityResult) Results() []CarbonIntensityForecastEntry
Results is a helper / interface function to return the current rate data.
type RegionalIntensityResult ¶
type RegionalIntensityResult struct {
Data RegionalIntensityResultData `json:"data"`
}
RegionalIntensityResult is returned by Regional requests. It wraps all data inside a data element. Because that makes sense, and makes all of this SO much easier. /s
func (RegionalIntensityResult) Results ¶
func (r RegionalIntensityResult) Results() []CarbonIntensityForecastEntry
type RegionalIntensityResultData ¶
type RegionalIntensityResultData struct { RegionId int `json:"regionid"` DNORegion string `json:"dnoregion"` ShortName string `json:"shortname"` Rates []CarbonIntensityForecastEntry `json:"data"` }
RegionalIntensityResultData is returned by Regional requests. It includes a bit of extra data.