Categorygithub.com/danopstech/octopusenergy
modulepackage
0.0.1
Repository: https://github.com/danopstech/octopusenergy.git
Documentation: pkg.go.dev

# README

logo

Octopus Energy Golang API client


PkgGoDev License Release tests

This package provides a Golang client to Octopus Energy's API. Octopus Energy provides a REST API for customers to interact with our platform. Amongst other things, it provides functionality for:

  • Browsing energy products, tariffs and their charges.
  • Retrieving details about a UK electricity meter-point.
  • Browsing the half-hourly consumption of an electricity or gas meter.
  • Determining the grid-supply-point (GSP) for a UK postcode.

If you are an Octopus Energy customer, you can generate an API key from your online dashboard.

Authentication

Authentication is required for all API end-points when using this API client. This is performed via HTTP Basic Auth. This is configured when you instantiate a new client with a config object. Warning: Do not share your secret API keys with anyone.

Not an Octopus Energy customer?

Please read about the Octopus tariffs and ensure they are right for you, if you think they are, then please use my referral link. (at the time of writing this we will both receive £50 credit)

Usage

More in the examples folder

ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
defer cancel()

var netClient = http.Client{
    Timeout: time.Second * 10,
}

client := octopusenergy.NewClient(octopusenergy.NewConfig().
    WithApiKeyFromEnvironments().
    WithHTTPClient(netClient),
)

consumption, err := client.Consumption.GetPagesWithContext(ctx, &octopusenergy.ConsumptionGetOptions{
    MPN:          "1111111111", // <--- replace
    SerialNumber: "1111111111", // <--- replace
    FuelType:     octopusenergy.FuelTypeElectricity,
    PeriodFrom:   octopusenergy.Time(time.Now().Add(-48 * time.Hour)),
})

if err != nil {
    log.Fatalf("failed to getting consumption: %s", err.Error())
}

Links

# Packages

No description provided by the author

# Functions

Bool returns a pointer to the bool value passed in.
Int returns a pointer to the int value passed in.
NewClient accepts a config object and returns an initiated client ready to use.
NewConfig returns a new Config pointer that can be chained with builder methods to set multiple configuration values inline without using pointers.
String returns a pointer to the string value passed in.
Time returns a pointer to the time.Time value passed in.

# Constants

electricity.
gas.
ProductCodeAgile180221 is the product code to Octopus current Agile tariff.
day-unit-rates.
night-unit-rates.
standard-unit-rates.
standing-charges.

# Structs

No description provided by the author
Config provides service configuration for client.
ConsumptionGetOptions is the options for GetConsumption.
ConsumptionGetOutput is the returned struct from GetConsumption.
GridSupplyPointGetOptions is the options for GetGridSupplyPoint.
GridSupplyPointGetOutput is the returned struct from GetGridSupplyPoint.
MeterPointGetOptions is the options for GetMeterPoint.
MeterPointGetOutput is the returned struct from GetMeterPoint.
ProductsGetOptions is the options for GetProduct.
ProductsGetOutput is the returned struct from GetProduct.
ProductsListOptions is the options for ListProduct.
ProductsListOutput is the returned struct from ListProduct.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TariffChargesGetOptions is the options for GetTariffCharges.
TariffChargesGetOutput is the returned struct from GetTariffCharges.
No description provided by the author

# Type aliases

ConsumptionService handles communication with the consumption related Octopus API.
No description provided by the author
GridSupplyPointService handles communication with the grid supply point related Octopus API.
MeterPointService handles communication with the meter point related Octopus API.
ProductService handles communication with the product related Octopus API.
Rate is the type of charge, example standing-charges, day-unit-rates, standard-unit-rates.
TariffChargeService handles communication with the tariff related Octopus API.