It is a simple REST API written in node and Express using TypeScript.
Given a meter_id
and a start_date
and end_date
it returns the energy footprint of the meter in the given period.
The footprint consists of the following properties:
- total energy consumption
- total CO2 emitted
- the fuel mix based on the National Grid's fuel mix data.
The total energy consumption is calculated by summing up the energy consumption of the meter in the given period.
The total amount of CO2 (kgs) emitted by the electricity generated for the given meter in the given period is calculated by taking the sum of the multiplication of the energy consumption of the meter in half-hourly intervals by the matching half-hourly CO2 average levels of the National Grid's CO2 level data.
The fuel mix is calculated by taking the sum of the multiplication of the energy consumption of the meter in half-hourly intervals by the matching half-hourly fuel mix of the National Grid's fuel mix data.
The backend dashboard uses the following REST API endpoints to retrieve the data:
- Openvolt API v.1 - openvolt.com
- Carbon Intensity API v.2.0.0- National Grid
Clone the repository and navigate into it.
Create an .env
file with the contents provided in the example.env
file. Make sure to set the X_API_KEY
value as suggested in the example.env
file.
Run
yarn install
to install all of the dependency packages.
yarn dev
to start the server in development mode.
Returns a data object for the given meter_id
or a combination of (meter_number
and customer_id
)
and a start_date
and end_date
with the granularity of half-hour (hh
).
The returned data object contains the following properties:
totalEnergyConsumption
:number
- the total energy consumption of the meter in the given periodtotalEnergyConsumptionUnit
:string
- the unit of the total energy consumption (e.g.,kWh
)emittedCO2
:number
- the total amount of CO2 emitted by the energy consumption of the meter in the given periodemittedCO2Unit
:string
- the unit of the emitted CO2 (e.g.,kg
)fuelMix
:Object
- the fuel mix of the meter in the given periodenergyWithUnknownOrigin
:number
- the total energy consumption of the meter in the given period for which the origin is unknownenergyWithUnknownOriginUnit
:string
- the unit of the energy consumption for which the origin is unknown (e.g.,kWh
)generationMix
:Object[]
- the fuel mix for a givenmeter_id
in the given periodbiomass
:number
- the share of biomass for a givenmeter_id
in the given periodcoal
:number
- the share of coal for a givenmeter_id
in the given periodimports
:number
- the share of imports for a givenmeter_id
in the given periodgas
:number
- the share of gas for a givenmeter_id
in the given periodnuclear
:number
- the share of nuclear for a givenmeter_id
in the given periodother
:number
- the share of other for a givenmeter_id
in the given periodhydro
:number
- the share of hydro for a givenmeter_id
in the given periodsolar
:number
- the share of solar for a givenmeter_id
in the given periodwind
:number
- the share of wind for a givenmeter_id
in the given period
meter_id
- the id of the meter for which the data is requestedmeter_number
- the number of the meter for which the data is requestedcustomer_id
- the id of the customer for which the data is requestedgranularity
- the granularity of the data (e.g.,hh
(half-hourly),day
,week
,month
,year
).start_date
- the start date (ISO 8601) of the requested period, default:2023-01-01T00:00:00Z
end_date
- the end date (ISO 8601) of the requested period, default:2023-02-01T00:00:00Z
lookback
- the look back period from current date (e.g.,1d
,2w
,3m
,4y
)
/footprint?meter_id=6514167223e3d1424bf82742&granularity=hh&start_date=2023-01-01T00:00:00Z&end_date=2023-02-01T00:00:00Z
Returns information about a meter with the given meter_id
.
The returned data object contains the following properties:
_id
:string
- the id of the meterobject
:string
- the type of the object (e.g.,meter
)account
:string
- the id of the account to which the meter belongsmeter_number
:string
- the number of the metercustomer
:Object
- the customer to which the meter belongs_id
:string
- the id of the customerobject
:string
- the type of the object (e.g.,customer
)account
:string
- the id of the account to which the customer belongsname
:string
- the name of the customeremail
:string
- the email of the customeraddress
:string
- the address of the customernotes
:string[]
- the notes of the customercreated_at
:string
- the date when the customer was created__v
:number
- the version of the customer
address
:string
- the address of the meterupdate_frequency
:string
- the update frequency of the meter (e.g.,weekly
)data_source
:string
- the data source of the meter (e.g.,electralink
)status
:string
- the status of the meter (e.g.,active
)notes
:string[]
- the notes of the metercreated_at
:string
- the date when the meter was created__v
:number
- the version of the meterdescription
:string
- the description of the meter
meter_id
- the id of the meter for which the data is requested
/meters/6514167223e3d1424bf82742
- the share values are fixed to 3 decimal places, so 0.000 is returned for a value of 0.0001.
- the
energyWithUnknownOrigin
is calculated by subtracting the sum of thegenerationMix
with accounted origin from thetotalEnergyConsumption
. - either
meter_id
or a combination of (meter_number
andcustomer_id
) must be provided. lookback
is an alternative tostart_date
andend_date
and it is used to calculate thestart_date
andend_date
based on the current date. In this example we only make use of thestart_date
andend_date
query parameters.granularity
value ofhh
is the only supported value at the moment.start_date
andend_date
must be provided in the ISO 8601 format.