#89 An example app showing a practical use case with the API
Using the Eskom load-shedding API is very straight forward however I have noticed that a lot of people get stuck on the last call where an html document is returned instead of Json data. This can throw a spanner in the works because a developer can’t just get the results as a key value pair… the HTML must be parsed and then put into Json before it can be used effectively.
This parsing process is actually quite easy and jut requires a loop with a bit of regex magic to return the values line by line.
Once the values are returned we can then place them into our own Json object and then do something useful with them like creating a loop which reads the times and compares them to the time on my PC then when the json objects time is 10 minutes away the loop then initiates a shutdown of my fan so that it doesn’t drain my ups battery unnecessarily.
Below I have written a small proof of concept application in C# to help inspire others with their projects.
I make use of the LoadShedding.NET.dll library made by IsaTippens using my endpoint documentation and documentation from PolarizedIons.
However in the end I only focused on 2 API endpoints to simplify the example app.
This makes my example much simpler.
You can take a look at my example code on GitHub