I recently had a smart meter installed at home which provides detailed information on my gas and electricity usage. My energy provider (OVO Energy) allow me to view this information via their website but unfortunately don’t provide the ability to export that data for further analysis. So I started poking around to understand the underlying APIs that their website uses to see if I could call them myself directly.. 

The first tool I used was the network tab in Chrome Developer Tools (hit F12) to inspect the XHR requests that were being made by my browser. Sure enough I could see the exact API endpoints and requests that were being sent: 

image

As with most APIs, I could see that in order to make successful requests I needed to pass a valid token (in this case via a cookie). This meant that I had to figure out how to authenticate myself and obtain a valid token using the username and password that I log into their website with. So I went back to the login page to discover the login endpoint and the payload to send containing my username and password:

image

Next I used postman to simulate the requests that my WDC would need to make to successfully retrieve the data I wanted to analyse in Tableau. In fact there were 3 separate requests I would need to make:

1) Login by sending a POST request to https://my.ovoenergy.com/api/auth/login and get a valid token and persistenToken to make subsequent requests with.

2) Retrieve my account details by making a GET request to https://paym.ovoenergy.com/api/paym/accounts. Specifically I needed the mpan numbers for my gas and electricity meters.

3) Get my consumption data by sending a GET request to https://live.ovoenergy.com/api/live/meters/1900025117740/consumptions/aggregated?from=2017-09-01T00%3A00%3A00.000Z&to=2017-10-01T00%3A00%3A00.000Z&granularity=DAY where  1900025117740 represents the mpan of the meter.

image

While this worked well from Postman, I found that I needed to implement a proxy for my JavaScript WDC code to successfully call the API. This is due to the well documented CORs issue which often prevents requests being made to a server that’s on a different domain than the one that’s hosting the web data connector’s HTML page. 

If you are interested in looking at the final version of the code including my PHP proxy, it is available on github hereIf you are also an OVO Energy user and would also like to analyse your consumption, the WDC is hosted here: 

http://files.tableaujunkie.com/ovo/html/ovoconnect.html

image

Finally, there is a simple viz of the results from my household on Tableau Public here (spot when I was on holiday :))

image