Skip to main content Skip to navigation

Energy Tracker API Documentation

The Energy Tracker API allows basic consumption data to be integrated into other web apps, websites, display signage or other systems where small amounts of data are needed. This API allows open access to the metering data from a web based structured URL, which can be formed from using javascript for example, with data being returned in JSON/XML text format.

The data must be mapped through the Energy Tracker and public API usage must be enabled on a meter by meter basis subject to approval. Speak to someone from the Energy Team to discuss further.

Grabbing Data

The Energy Tracker API can be used by using URLs structured as in this example (you can click on this in most modern browsers to see an example of the output):

http://energy.warwick.ac.uk/EnergyTracker/api/consumption/getdata?&id=424&periodCount=-48&periodType=halfhour&dateTime=2013-12-03T10:30

Each part of the URL has a particular meaning:

id=424

This is the ID number for the metered data stream that you want. Speak to the Energy Team to get a list of the IDs relevent for you.

periodCount=-48

This can be a positive or negative number of periods with respect to the date. Negative numbers mean the dateTime provided below will be the last item of data. Positive numbers mean it will be the first. So here, we are going backwards from the given time.

periodType=halfhour

This is the period length that you want and can be halfhour, hour, day, week, month (only whole periods will be returned, dateTime will be “rounded” appropriately). The total consumption in that time period will be provided – i.e. 24 hours from midnight will total the same as 1 day.

dateTime=2013-12-03T10:30

This is the date and time you want to have data from/to in ISO format. This is optional as if its missing, then the current time will be used but it’s best to specify this properly and round it according to your periodType. Depending on periodCount, this will either be the first or last (or only) item of data you get.

The example here will go backwards 48 half hours from 10:30 at 3rd December 2013 at for meter ID 424. If this was the current date/time, then this would potentially give you the most recent day’s data. Data format is determined by content type HTTP header (application/json, application/xml)

Developer Tips

In your particular application, you are advised to form the URL with dates aligned according to the periodType. Also, if you try and get data that hasn’t arrived yet (or is in the future) then you see zeros with a padding flag set to true. You can use this flag to filter out such data, to ensure you don’t see “padded data” where the data isn’t actually available. For example, you could grab a bigger time window than needed and walk backwards until you see a positive value where there is no padded data – i.e. find real numbers.

Examples of the API in action

In this example, developed by the Student Union, the API was used to create a dynamic banner to sit below other content at the bottom of the Big Screen on the Piazza to raises awareness of our energy and water usage:
http://warwicksu.studio1251.com/energytracker/

Some very early examples from 2013 developped by one of the Energy Team use Google Charts to visualise how our Combined Heat & Power engines are operating:
http://homepages.warwick.ac.uk/staff/Mark.Jarvis/CHP.html
http://homepages.warwick.ac.uk/staff/Mark.Jarvis/Gauge.html

Need More?

This API is meant for relatively small amounts of data for web apps and website. If you need more substantial data in terms of large periods of time, or access to lots of metered data streams, or want access to data not otherwise available on the Energy Tracker, then the more advanced and secure DCS Web Service Interface may be more suitable. For details on this, please speak to the Energy Team to discuss further.