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.
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):
Each part of the URL has a particular meaning:
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.
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.
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.
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)
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:
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:
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.