Coder Social home page Coder Social logo

octopusenergy's Introduction

logo

Octopus Energy Golang API client


PkgGoDev License Release tests Go Report Card GitHub go.mod Go version GitHub issues

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.