Skip to main content

Get measurements

You can start using Measurements with this query. This will be valid across all Krakens; however, you may see different behavior. This is most relevant to Mobile App developers who need to communicate with more than a single Kraken. Consumer Sites do not have this additional complexity.

query getMeasurements(
  $accountNumber: String!,
  $first: Int!,
  $utilityFilters: [UtilityFiltersInput!],
  $startOn: Date,
  $endOn: Date,
  $startAt: DateTime,
  $endAt: DateTime,
  $timezone: String,
  $cursor: String
) {
  account(accountNumber: $accountNumber) {
    properties {
      id
      measurements(
        first: $first,
        utilityFilters: $utilityFilters,
        startOn: $startOn,
        endOn: $endOn,
        startAt: $startAt,
        endAt: $endAt,
        timezone: $timezone,
        after: $cursor
    ) {
        edges {
          node {
            value
            unit
            ... on IntervalMeasurementType {
              startAt
              endAt
              __typename
            }
            metaData {
              statistics {
                costExclTax {
                  costCurrency
                  estimatedAmount
                  __typename
                }
                value
                description
                label
                type
                __typename
              }
              __typename
            }
            __typename
          }
          __typename
        }
        pageInfo {
          hasNextPage
          hasPreviousPage
          startCursor
          endCursor
          __typename
        }
        __typename
      }
      __typename
    }
    __typename
  }
}

Set up your input. We're using hard coded values from OEGB's Prod Environment here, but the overall structure will be the same for all Krakens.

{
  "accountNumber": "A-F523797D",
  "first": 1000,
  "startAt": "2024-10-01T00:00:00.000",
  "endAt": "2024-10-07T00:00:00.000",
  "timezone": "Europe/London",
  "utilityFilters": [
    {
      "electricityFilters": {
        "readingFrequencyType": "DAY_INTERVAL",
        "marketSupplyPointId": "2700008749510",
        "readingDirection": "GENERATION",
        "deviceId": "30-EB-5A-FF-FF-E0-91-E8"
      }
    }
  ]
}

Input Object

This is a fairly complicted input. Many fields are self-explanatory; however, a few are worth covering in more detail.

  • marketSupplyPointId - varies per client. See the Global reference .
  • readingFrequencyType - this will be target aggregation granularity. The most commonly used are:
    • THIRTY_MIN_INTERVAL
    • HOUR_INTERVAL
    • DAY_INTERVAL
  • readingDirection - defaults to CONSUMPTION but can be GENERATION for some electricity supply points. Here, we know we have an Export meter.
  • registerId - an optional input to specify a register for the marketSupplyPointId. This meter doesn't need a registerId.
  • deviceId - an optional input to specific a specific sub device. I.e., an Electric Vehicle, a specific meter under the supply point, etc.


Response

Expand
{
  "data": {
    "account": {
      "properties": [
        {
          "id": "308641",
          "measurements": {
            "edges": [
              {
                "node": {
                  "value": "6.525000",
                  "unit": "kwh",
                  "startAt": "2024-10-01T00:00:00+01:00",
                  "endAt": "2024-10-02T00:00:00+01:00",
                  "__typename": "IntervalMeasurementType",
                  "metaData": {
                    "statistics": [
                      {
                        "costExclTax": {
                          "costCurrency": "GBP",
                          "estimatedAmount": "0.00",
                          "__typename": "EstimatedMoneyType"
                        },
                        "value": null,
                        "description": "Daily charge rate (standing charge)",
                        "label": null,
                        "type": "STANDING_CHARGE_COST",
                        "__typename": "StatisticOutput"
                      },
                      {
                        "costExclTax": {
                          "costCurrency": "GBP",
                          "estimatedAmount": "182.30",
                          "__typename": "EstimatedMoneyType"
                        },
                        "value": null,
                        "description": "The calculated value of generation for the interval",
                        "label": "GENERATION",
                        "type": "GENERATION_VALUE",
                        "__typename": "StatisticOutput"
                      }
                    ],
                    "__typename": "MeasurementsMetadataOutput"
                  }
                },
                "__typename": "MeasurementEdge"
              },
              {
                "node": {
                  "value": "8.401000",
                  "unit": "kwh",
                  "startAt": "2024-10-02T00:00:00+01:00",
                  "endAt": "2024-10-03T00:00:00+01:00",
                  "__typename": "IntervalMeasurementType",
                  "metaData": {
                    "statistics": [
                      {
                        "costExclTax": {
                          "costCurrency": "GBP",
                          "estimatedAmount": "0.00",
                          "__typename": "EstimatedMoneyType"
                        },
                        "value": null,
                        "description": "Daily charge rate (standing charge)",
                        "label": null,
                        "type": "STANDING_CHARGE_COST",
                        "__typename": "StatisticOutput"
                      },
                      {
                        "costExclTax": {
                          "costCurrency": "GBP",
                          "estimatedAmount": "229.32",
                          "__typename": "EstimatedMoneyType"
                        },
                        "value": null,
                        "description": "The calculated value of generation for the interval",
                        "label": "GENERATION",
                        "type": "GENERATION_VALUE",
                        "__typename": "StatisticOutput"
                      }
                    ],
                    "__typename": "MeasurementsMetadataOutput"
                  }
                },
                "__typename": "MeasurementEdge"
              },
              {
                "node": {
                  "value": "11.537000",
                  "unit": "kwh",
                  "startAt": "2024-10-03T00:00:00+01:00",
                  "endAt": "2024-10-04T00:00:00+01:00",
                  "__typename": "IntervalMeasurementType",
                  "metaData": {
                    "statistics": [
                      {
                        "costExclTax": {
                          "costCurrency": "GBP",
                          "estimatedAmount": "0.00",
                          "__typename": "EstimatedMoneyType"
                        },
                        "value": null,
                        "description": "Daily charge rate (standing charge)",
                        "label": null,
                        "type": "STANDING_CHARGE_COST",
                        "__typename": "StatisticOutput"
                      },
                      {
                        "costExclTax": {
                          "costCurrency": "GBP",
                          "estimatedAmount": "297.89",
                          "__typename": "EstimatedMoneyType"
                        },
                        "value": null,
                        "description": "The calculated value of generation for the interval",
                        "label": "GENERATION",
                        "type": "GENERATION_VALUE",
                        "__typename": "StatisticOutput"
                      }
                    ],
                    "__typename": "MeasurementsMetadataOutput"
                  }
                },
                "__typename": "MeasurementEdge"
              },
              {
                "node": {
                  "value": "11.818000",
                  "unit": "kwh",
                  "startAt": "2024-10-04T00:00:00+01:00",
                  "endAt": "2024-10-05T00:00:00+01:00",
                  "__typename": "IntervalMeasurementType",
                  "metaData": {
                    "statistics": [
                      {
                        "costExclTax": {
                          "costCurrency": "GBP",
                          "estimatedAmount": "0.00",
                          "__typename": "EstimatedMoneyType"
                        },
                        "value": null,
                        "description": "Daily charge rate (standing charge)",
                        "label": null,
                        "type": "STANDING_CHARGE_COST",
                        "__typename": "StatisticOutput"
                      },
                      {
                        "costExclTax": {
                          "costCurrency": "GBP",
                          "estimatedAmount": "293.22",
                          "__typename": "EstimatedMoneyType"
                        },
                        "value": null,
                        "description": "The calculated value of generation for the interval",
                        "label": "GENERATION",
                        "type": "GENERATION_VALUE",
                        "__typename": "StatisticOutput"
                      }
                    ],
                    "__typename": "MeasurementsMetadataOutput"
                  }
                },
                "__typename": "MeasurementEdge"
              },
              {
                "node": {
                  "value": "10.949000",
                  "unit": "kwh",
                  "startAt": "2024-10-05T00:00:00+01:00",
                  "endAt": "2024-10-06T00:00:00+01:00",
                  "__typename": "IntervalMeasurementType",
                  "metaData": {
                    "statistics": [
                      {
                        "costExclTax": {
                          "costCurrency": "GBP",
                          "estimatedAmount": "0.00",
                          "__typename": "EstimatedMoneyType"
                        },
                        "value": null,
                        "description": "Daily charge rate (standing charge)",
                        "label": null,
                        "type": "STANDING_CHARGE_COST",
                        "__typename": "StatisticOutput"
                      },
                      {
                        "costExclTax": {
                          "costCurrency": "GBP",
                          "estimatedAmount": "280.10",
                          "__typename": "EstimatedMoneyType"
                        },
                        "value": null,
                        "description": "The calculated value of generation for the interval",
                        "label": "GENERATION",
                        "type": "GENERATION_VALUE",
                        "__typename": "StatisticOutput"
                      }
                    ],
                    "__typename": "MeasurementsMetadataOutput"
                  }
                },
                "__typename": "MeasurementEdge"
              },
              {
                "node": {
                  "value": "5.371000",
                  "unit": "kwh",
                  "startAt": "2024-10-06T00:00:00+01:00",
                  "endAt": "2024-10-07T00:00:00+01:00",
                  "__typename": "IntervalMeasurementType",
                  "metaData": {
                    "statistics": [
                      {
                        "costExclTax": {
                          "costCurrency": "GBP",
                          "estimatedAmount": "0.00",
                          "__typename": "EstimatedMoneyType"
                        },
                        "value": null,
                        "description": "Daily charge rate (standing charge)",
                        "label": null,
                        "type": "STANDING_CHARGE_COST",
                        "__typename": "StatisticOutput"
                      },
                      {
                        "costExclTax": {
                          "costCurrency": "GBP",
                          "estimatedAmount": "145.75",
                          "__typename": "EstimatedMoneyType"
                        },
                        "value": null,
                        "description": "The calculated value of generation for the interval",
                        "label": "GENERATION",
                        "type": "GENERATION_VALUE",
                        "__typename": "StatisticOutput"
                      }
                    ],
                    "__typename": "MeasurementsMetadataOutput"
                  }
                },
                "__typename": "MeasurementEdge"
              }
            ],
            "pageInfo": {
              "hasNextPage": false,
              "hasPreviousPage": false,
              "startCursor": "YXJyYXljb25uZWN0aW9uOjA=",
              "endCursor": "YXJyYXljb25uZWN0aW9uOjU=",
              "__typename": "PageInfo"
            },
            "__typename": "MeasurementConnection"
          },
          "__typename": "PropertyType"
        }
      ],
      "__typename": "AccountType"
    }
  }
}

Authentication

Account Users and Organizations

Account users and organizations will use the obtainKrakenToken mutation to recieve a Kraken token. See the Blueprint docs for more information about this.

mutation getKrakenAPIToken($input:ObtainJSONWebTokenInput!){
  obtainKrakenToken(input:$input) {
    token
  }
}

Input

{
  "input": {
    "email": "account user email here",
    "password": "account user password",
    "organizationSecretKey": "org secret key here - exclusive with email + password"
  }
}

Output

{
  "data": {
    "obtainKrakenToken": {
      "token": "eyJhbGciOiJSUzI1NiIsImlzcyI6Imh0dHBzOi8vc3VwcG9ydC5vZWVzLWtyYWtlbi5lbmVyZ3kiLCJqa3UiOiJodHRwczovL2F1dGgub2Vlcy1rcmFrZW4uZW5lcmd5Ly53ZWxsLWtub3duL2p3a3MuanNvbiIsImtpZCI6Ilpsb1FacVJaQUZYN3IyZWZCSjZMaEtFc0NoMkJXaUIxOGt4czBHX2pqMjgiLCJ0eXAiOiJKV1QifQ.eyJzdWIiOiJrcmFrZW58YWNjb3VudC11c2VyOjIzMDA3MyIsImd0eSI6Ik1BU1FVRVJBREUiLCJlbWFpbCI6ImpvYW5uZS5taWxsZXJAdW5pcWxvLmV1IiwidG9rZW5Vc2UiOiJhY2Nlc3MiLCJpc3MiOiJodHRwczovL3N1cHBvcnQub2Vlcy1rcmFrZW4uZW5lcmd5IiwiaWF0IjoxNzMwODM0MTkxLCJleHAiOjE3MzA4Mzc3OTEsIm9yaWdJYXQiOjE3MzA4MzQxOTEsImFjdCI6eyJzdWIiOiJrcmFrZW58c3VwcG9ydC11c2VyOjY2MiJ9fQ.mrFJS2lJvvo-Ho36wjqb9M5TOItxWggu_d9Q581vfYhnKelq8ItMwH0M4gi8gPQhHx8dMfhfP6ZTJZwO_uVKmQHPjbMpfIK722pAir8c_1fnk6D2mIuNikrbRjEv9Wu8Jo3XjMox5ZGKWxVTUZ4grUWyanOE-b_0FO54bHT_aaccpssF1g_-2uE8fkqMB5EblVboBh0A1IcFBDDB04JUOn4SdyhXuT50z6K0HzauSzgfPQgBcsACdG1GAeqXO8yKQzmFN13-Ezw-opoSftZCZtVNTIOiCk01cMOzz30F-MfBvzSHOkW0uQ-NYWOQCxj_8PxrABfYC1VZ6THy06e8Fg"
    }
  }
}

Auth server

Recieving any output from most Krakens APIs will require a Kraken token for access. Account Users are granted these tokens when they login with their email and password. OAuth Applications will use the auth server's /token/ REST endpoint. See the python example below.

import requests

def print_token(client_id: str, client_secret: str):
    response = requests.post(
        "https://auth.octopus.energy/token/",
        data={
            "grant_type": "client_credentials",
            "client_id": client_id,
            "client_secret": client_secret,
        },
    )
    tokens = response.json()
    print(tokens["access_token"])

if name == "__main__":
    client_id = "auth_app_client_id_here"
    client_secret = "auth_app_client_secret_here"
    print_token(client_id, client_secret)

Once you have this token, you'll add it to your API request headers like so.

{
  "Authorization": "your-kraken-token-here"
}