New API Endpoint for PEI Wind

If you’ve been following along over the years, you’ll recall that back in 2012, thanks to the imaginative efforts of a coder deep inside the provincial government, a JSON feed of Prince Edward Island’s electricity load and generation became available.

The efforts were imaginative because the coder created a public web page with gauges showing readings by emitting and then consuming JSON; because the JSON was public, it was thus available to anyone who wanted to use it. I’ve been archiving that data since 2012 (you can grab the archive here), and have been it using for everything from a mobile app to an Alexa skill (“Alexa, as PEI power for a summary”). I’ve done all this with an eye to increasing Islander’s “peripheral electricity literacy,” and I’ve frequently referenced this data in my presentations about open data.

The province has admirably continued to maintain the JSON feed all these years, and this week, as part of their migration to a new web platform, they’ve moved the mechanism by which the data is available, and, in the process, have formalized something which had heretofore been informal.

Here’s a one-liner that that illustrates the new system:

curl --header "Content-Type: application/json" -X POST --data '{"featureName": "WindEnergy"}' https://wdf.princeedwardisland.ca/prod/workflow

This will return a JSON object with the five values previously available, albeit wrapped in a slightly more complex data structure:

{
   "components":[
      {
         "type":7,
         "data":{
            "actualValue":186,
            "footer":"",
            "maxValue":300,
            "header":"Total On-Island Load: 186.59 MW",
            "color":"#008570"
         }
      },
      {
         "type":7,
         "data":{
            "actualValue":49,
            "footer":"",
            "maxValue":200,
            "header":"Wind Power Used On Island: 49.21 MW",
            "color":"#008570"
         }
      },
      {
         "type":7,
         "data":{
            "actualValue":55,
            "footer":"",
            "maxValue":300,
            "header":"Total On-Island Wind Generation: 55.22 MW",
            "color":"#008570"
         }
      },
      {
         "type":7,
         "data":{
            "actualValue":6,
            "footer":"",
            "maxValue":200,
            "header":"Wind Power Exported Off Island: 6.01 MW",
            "color":"#008570"
         }
      },
      {
         "type":7,
         "data":{
            "actualValue":0,
            "footer":"",
            "maxValue":200,
            "header":"Total On-Island Fossil Fuel Generation: 0.00 MW",
            "color":"#008570"
         }
      },
      {
         "type":5,
         "data":{
            "text":"Last updated October 31, 2018 10:44 AM"
         }
      }
   ]
}

I’ve modified my systems to use this new feed. If you want a simpler mechanism for grabbing the same data, pulled in real time from the source, you can:

curl "https://energy.reinvented.net/pei-energy/govpeca/get-govpeca-json.php?format=json"

which will return:

{
   "on-island-load":"186.59",
   "on-island-wind":"55.22",
   "on-island-fossil":"0.00",
   "wind-local":"49.21",
   "wind-export":"6.01",
   "percentage-wind":"29.59",
   "updatetime":1540993440,
   "updatetime_human":"2018-10-31 10:44:00"
}

Or, if you prefer XML:

curl "https://energy.reinvented.net/pei-energy/govpeca/get-govpeca-json.php?format=xml"

which returns:

<?xml version="1.0" encoding="UTF-8"?>
<govpeca>
    <on-island-load>186.59</on-island-load>
    <on-island-wind>55.22</on-island-wind>
    <on-island-fossil>0.00</on-island-fossil>
    <wind-local>49.21</wind-local>
    <wind-export>6.01</wind-export>
    <percentage-wind>29.59</percentage-wind>
    <updatetime>1540993440</updatetime>
    <updatetime_human>2018-10-31 10:44:00</updatetime_human>
</govpeca>

If you’d prefer a richer set of data, you can also use the endpoint I created to drive the pei.consuming.ca mobile app:

curl "https://energy.reinvented.net/pei-energy/govpeca/deliver-govpeca-data.php?format=json"

which returns:

{
   "current":{
      "updatetime":"2018-10-31 10:44:00",
      "uptimetimehuman":"Wednesday at 10:44 AM",
      "on-island-load":"186.59",
      "on-island-wind":"55.22",
      "on-island-fossil":"0.00",
      "wind-local":"49.21",
      "wind-export":"6.01",
      "percentage-wind":"29.59"
   },
   "previous":{
      "updatetime":"2018-10-31 10:29:00",
      "uptimetimehuman":"Wednesday at 10:29 AM",
      "on-island-load":"188.27",
      "on-island-wind":"63.76",
      "on-island-fossil":"0.00",
      "wind-local":"53.69",
      "wind-export":"10.07",
      "percentage-wind":"33.87"
   },
   "peak":{
      "peak":"188",
      "hightime":"10:29 AM"
   },
   "peakwind":{
      "peak":"91",
      "hightime":"3:14 AM"
   }
}

The data here is the same, but I include the previous sample, and the daily peaks for load and wind.

I’m self-hosting these endpoints, so please don’t hit them too hard (the data is only updated once every 15 minutes by Maritime Electric via the province, so there’s no need to poll more regularly than that).

The province’s own page of gauges visualizing this same information has also changed its location: you can now find it at PEI Wind Energy.

Comments