Loadshedding API?

Hey everyone, Can someone explain maybe where Eskomsepush gets their data from? From all the articles I have read they mention it's their parttime job and that they get information from online resources, but closer look city power does not provide certain locations that do fall under Johannesburg and even if they do the schedules don't align with their data. The same goes for the loadshedding.eskom.co.za site, schedules aren't the same at all. What gives?
 
Hey everyone, Can someone explain maybe where Eskomsepush gets their data from? From all the articles I have read they mention it's their parttime job and that they get information from online resources, but closer look city power does not provide certain locations that do fall under Johannesburg and even if they do the schedules don't align with their data. The same goes for the loadshedding.eskom.co.za site, schedules aren't the same at all. What gives?

They are likely pulling the data from multiple sources (municipalities, cities, Eskom schedule) and then combining it on a best guess.

No choice really, I have some python running doing the same, and it is messy. That being said, this is mostly for me trying out something which I am not too proficiant at, and learning as I go.
 
They are likely pulling the data from multiple sources (municipalities, cities, Eskom schedule) and then combining it on a best guess.

No choice really, I have some python running doing the same, and it is messy. That being said, this is mostly for me trying out something which I am not too proficiant at, and learning as I go.

But I have looked everywhere for my suburb and I can't find it publically available anywhere at all. But the app has the schedule and is pretty accurate so it's kind of confusing, to be honest.
 
But I have looked everywhere for my suburb and I can't find it publically available anywhere at all. But the app has the schedule and is pretty accurate so it's kind of confusing, to be honest.

if you were to jot down your schedule a few times when it came up a pattern would appear...
 
Hey everyone, Can someone explain maybe where Eskomsepush gets their data from? From all the articles I have read they mention it's their parttime job and that they get information from online resources, but closer look city power does not provide certain locations that do fall under Johannesburg and even if they do the schedules don't align with their data. The same goes for the loadshedding.eskom.co.za site, schedules aren't the same at all. What gives?

What area and suburb are you in?
 
Ok so I got stuck into this today for a community website. Feel free to edit the following. Replace anything in <> with the relevant value.

Get the current status (as posted earlier):

Call: http://loadshedding.eskom.co.za/LoadShedding/GetStatus
Returned data: Is a single character/value. If less than 1 then discard. If more or equal subtract 1 for the current stage.
Example: 1 = No load shedding, 2 = Stage 1, 5 = Stage 4

Get the schedule:

Province IDs:
1 = Eastern Cape
2 = Free State
3 = Gauteng
4 = KwaZulu-Natal
5 = Limpopo
6 = Mpumalanga
7 = North West
8 = Northern Cape
9 = Western Cape

List municipalitied in province:
Call: http://loadshedding.eskom.co.za/LoadShedding/GetMunicipalities/?Id=<province_id>
Example (Province = Western Cape): http://loadshedding.eskom.co.za/LoadShedding/GetMunicipalities/?Id=9
Returned JSON:
Code:
[{"Selected":false,"Text":"Beaufort West","Value":"10237"},{"Selected":false,"Text":"Bergrivier","Value":"10238"},{"Selected":false,"Text":"Bitou","Value":"10239"},{"Selected":false,"Text":"Breede Valley","Value":"10240"},{"Selected":false,"Text":"Cape Agulhas","Value":"10241"},{"Selected":false,"Text":"Cederberg","Value":"10242"},{"Selected":false,"Text":"City of Cape Town","Value":"10243"},{"Selected":false,"Text":"Drakenstein","Value":"10244"},{"Selected":false,"Text":"George","Value":"10245"},{"Selected":false,"Text":"Hessequa","Value":"10246"},{"Selected":false,"Text":"Kannaland","Value":"10247"},{"Selected":false,"Text":"Knysna","Value":"10248"},{"Selected":false,"Text":"Laingsburg","Value":"10249"},{"Selected":false,"Text":"Langeberg","Value":"10250"},{"Selected":false,"Text":"Matzikama","Value":"10251"},{"Selected":false,"Text":"Mossel Bay","Value":"10252"},{"Selected":false,"Text":"Oudtshoorn","Value":"10253"},{"Selected":false,"Text":"Overstrand","Value":"10254"},{"Selected":false,"Text":"Prince Albert","Value":"10255"},{"Selected":false,"Text":"Saldanha Bay","Value":"10256"},{"Selected":false,"Text":"Stellenbosch","Value":"10257"},{"Selected":false,"Text":"Swartland","Value":"10258"},{"Selected":false,"Text":"Swellendam","Value":"10259"},{"Selected":false,"Text":"Theewaterskloof","Value":"10260"},{"Selected":false,"Text":"Witzenberg","Value":"10261"}]

List suburbs of municipality:
Call: http://loadshedding.eskom.co.za/LoadShedding/GetSurburbData/?pageSize=100&pageNum=1&id=<municipality_id>
Example (Municipality = Overstrand): http://loadshedding.eskom.co.za/LoadShedding/GetSurburbData/?pageSize=100&pageNum=1&id=10254
- include the pageSize and pageNum parameters or the call will fail.
Returned JSON:
Code:
{"Total":111,"Results":[{"id":"1061253","text":"Afdak","Tot":267},{"id":"1069253","text":"Albertyn","Tot":535},{"id":"1061254","text":"Avila","Tot":0},{"id":"1061255","text":"Avoca","Tot":268},{"id":"1061256","text":"Baardskeerdersbos","Tot":268},{"id":"1061257","text":"Betty\u0027s Bay","Tot":268},{"id":"1061258","text":"Birkenhead","Tot":0},{"id":"1061259","text":"Blompark","Tot":0},{"id":"1061260","text":"Boesmansrivier","Tot":268},{"id":"1061261","text":"Bovendrift","Tot":268},{"id":"1061262","text":"Braemar","Tot":268},{"id":"1061263","text":"Bruinklip","Tot":268},{"id":"1061264","text":"Buffeljacht","Tot":272},{"id":"1069254","text":"Dagbreek","Tot":534},{"id":"1069255","text":"De Hoop","Tot":267},{"id":"1061265","text":"De Kelders","Tot":0},{"id":"1061266","text":"De Kelders 2","Tot":0},{"id":"1061267","text":"De Kelders 3","Tot":0},{"id":"1069256","text":"Denniston","Tot":267},{"id":"1061268","text":"Die Dam","Tot":272},{"id":"1061269","text":"Dirkuyskraal","Tot":272},{"id":"1061270","text":"Doringbosch","Tot":268},{"id":"1061271","text":"Duinefontein","Tot":0},{"id":"1061272","text":"Eluxolweni","Tot":0},{"id":"1061273","text":"Ertjiesvlei","Tot":268},{"id":"1061274","text":"Fisantskraal","Tot":272},{"id":"1061275","text":"Fisherhaven","Tot":267},{"id":"1061276","text":"Franskraal Strand","Tot":268},{"id":"1061277","text":"Gans Bay","Tot":536},{"id":"1061278","text":"Goedetrouw","Tot":268},{"id":"1061279","text":"Groenewaldskema","Tot":0},{"id":"1061280","text":"Groot Hagelkraal","Tot":0},{"id":"1061281","text":"Grootbos","Tot":268},{"id":"1061282","text":"Grootvlei","Tot":268},{"id":"1061283","text":"Hagelkraal","Tot":0},{"id":"1061284","text":"Hangklip","Tot":268},{"id":"1061285","text":"Hawston","Tot":0},{"id":"1061286","text":"Helderfontein","Tot":0},{"id":"1061287","text":"Hermanus","Tot":2412},{"id":"1061288","text":"Hermanus Outlying","Tot":0},{"id":"1061289","text":"High Noon","Tot":267},{"id":"1061290","text":"Honigsklip","Tot":268},{"id":"1061291","text":"Hoopjesrivier","Tot":267},{"id":"1061292","text":"Houhoek","Tot":267},{"id":"1061293","text":"Karwyderskraal","Tot":268},{"id":"1061294","text":"Kleinbaai","Tot":0},{"id":"1061295","text":"Kleinmond","Tot":536},{"id":"1061296","text":"Kleinrivierkloof","Tot":268},{"id":"1061297","text":"Klipfontein","Tot":0},{"id":"1061298","text":"Koksrivier","Tot":272},{"id":"1061299","text":"Kouderivier","Tot":268},{"id":"1061300","text":"Kouevlakte","Tot":268},{"id":"1069257","text":"Kromvlei","Tot":267},{"id":"1061301","text":"Lamloch","Tot":268},{"id":"1061302","text":"Langkloof","Tot":0},{"id":"1061303","text":"Le Mercy","Tot":268},{"id":"1069258","text":"Lebanon","Tot":267},{"id":"1061304","text":"LObos","Tot":0},{"id":"1061305","text":"Masakhane","Tot":0},{"id":"1061306","text":"Modderrivier","Tot":268},{"id":"1061307","text":"Moeraskloof","Tot":268},{"id":"1061308","text":"Mosselrivier","Tot":0},{"id":"1061309","text":"Mount Pleasant","Tot":0},{"id":"1061310","text":"New Granton","Tot":268},{"id":"1061311","text":"Nuwedam","Tot":268},{"id":"1061312","text":"Nuwepos","Tot":268},{"id":"1061313","text":"Onrus","Tot":535},{"id":"1061314","text":"Oudebosch","Tot":268},{"id":"1061315","text":"Paardenberg","Tot":268},{"id":"1061316","text":"Papiesvlei","Tot":268},{"id":"1061317","text":"Pearly Beach","Tot":0},{"id":"1061318","text":"Perlemoenbaai","Tot":0},{"id":"1061319","text":"Pringle Bay","Tot":268},{"id":"1061320","text":"Protea","Tot":0},{"id":"1061321","text":"Ratelrivier","Tot":272},{"id":"1061322","text":"Rooiels Bay","Tot":268},{"id":"1069259","text":"Salandra","Tot":268},{"id":"1061323","text":"Sandbaai","Tot":268},{"id":"1061324","text":"Sandberg","Tot":268},{"id":"1069260","text":"Sandfontein","Tot":272},{"id":"1061325","text":"Sandhoogte","Tot":268},{"id":"1061326","text":"Sandy\u0027s Glen","Tot":268},{"id":"1061327","text":"Silversands","Tot":268},{"id":"1061328","text":"Somerset West NU","Tot":0},{"id":"1061329","text":"Spookfontein","Tot":536},{"id":"1061330","text":"Stanford","Tot":804},{"id":"1061331","text":"Stompieskloof","Tot":0},{"id":"1061332","text":"Strands Kloof","Tot":268},{"id":"1061333","text":"Sunny Seas Estate","Tot":268},{"id":"1061334","text":"Sunnydale","Tot":804},{"id":"1061335","text":"The Springs","Tot":0},{"id":"1061336","text":"Tierfontein","Tot":268},{"id":"1061337","text":"Tweefontein","Tot":268},{"id":"1061338","text":"Uilenkraal","Tot":268},{"id":"1061339","text":"Uilenkraalsmond","Tot":268},{"id":"1061340","text":"Uitkoms","Tot":268},{"id":"1061341","text":"Van Dyksbaai","Tot":0},{"id":"1061342","text":"Vermont","Tot":267},{"id":"1061343","text":"Viljoenshof","Tot":272},{"id":"1069261","text":"Vredendal","Tot":268}]}
- If Tot is 0 then there won't be further data.

List load shedding schedule for suburb:
Call: http://loadshedding.eskom.co.za/LoadShedding/GetScheduleM/<suburb_id>/<stage>/<province_id>/<municipality_total>
- municipality_total must be 1 or more.
Example (Suburb = Hermanus, Stage = 2, Province = 9 (Western Cape)): http://loadshedding.eskom.co.za/LoadShedding/GetScheduleM/1061287/2/9/1
Returned HTML (you will need to parse this):

Wed, 08 Jan

18:00 - 20:30


Thu, 09 Jan

00:00 - 02:30


Fri, 10 Jan

00:00 - 02:30

08:00 - 10:30
Hi, Most of the suburbs I am interrested in has "0", so I cannot get the HTML with the time slots. Any idea why most of the suburbs has a "0"? Is there perhaps someone one can contact to find out why there is no data for most suburbs?
 
Maybe they are grouped together. Like 8-10 suburbs will have the same loadshedding so you have to see what group the are placed in. Maybe just thinking out loud.

I am currently developing an API for several months now so this is all on going for me the whole api thing. See if perhaps a parameter is missing or required instead of the suburb.
Thanks.
 
Any Update on this API. :? :)
My Area is always "tot: 0", Any idea on how to find other "similar" loadshedding areas?
my URL would be something like... but not working..
https://loadshedding.eskom.co.za/LoadShedding/GetScheduleM/1026738/2/3/1

Gauteng Group 7 .Looked for all the areas in Group 7 to see if i could get one with a "tot" thats not 0.
With the schedules on the Eskom site you have to choose either Eskom Direct or Municipal. The same area may appear on both lists (municipal and Eskom direct), but the schedules are different. If you are a Municipal customer follow the Municipal schedule.

ESP has made their API available for personal use, so maybe use that… Check the FAQ section for the API signup link (its says Business API, but you can select Personal on the form).
 
Here is a PHP-based web scraping script that returns the current loadshedding status from https://loadshedding.eksom.co.za

Code:
<?php
$request_time = time();
$timer=(10 * 60);

function write2db($time2db, $rate2db) {
$data = array(
    'timestamp' => $time2db,
    'loadshedding_status' => $rate2db,
);
$data = json_encode($data);
file_put_contents('data.db', $data);
}

$loaded_data = file_get_contents('data.db' );
$data = json_decode($loaded_data, TRUE);
$timestamp = $data["timestamp"];   //
$loadshedding_status = $data["loadshedding_status"]; 

if ($timestamp + $timer <= $request_time){
    $loadshedding_status = getLoadshedding();
    if (!empty($loadshedding_status)){

    write2db($request_time, $loadshedding_status);
    }
    else {
    write2db($request_time, '');
    }
}
if (!empty($loadshedding_status)){
    echo $loadshedding_status;
}
    
function getLoadshedding() {
  // Get loadshedding status live from eskom

$url = "https://loadshedding.eskom.co.za/LoadShedding/GetStatus?_=".$request_time;
$page_content = get_web_page($url);
$page_content = mb_convert_encoding($page_content, 'HTML-ENTITIES', "UTF-8");
return $page_content["content"];
}

   /**
     * Get a web file (HTML, XHTML, XML, image, etc.) from a URL.  Return an
     * array containing the HTTP server response header fields and content.
     */
    function get_web_page($url)
    {
        $user_agent='Mozilla/5.0 (Macintosh; PPC Mac OS X 10_8_7 rv:2.0) Gecko/20130831 Firefox/35.0';

        $options = array(

            CURLOPT_CUSTOMREQUEST  =>"GET",        //set request type post or get
            CURLOPT_POST           =>false,        //set to GET
            CURLOPT_USERAGENT      => $user_agent, //set user agent
            CURLOPT_COOKIEFILE     =>"cookie.txt", //set cookie file
            CURLOPT_COOKIEJAR      =>"cookie.txt", //set cookie jar
            CURLOPT_RETURNTRANSFER => true,     // return web page
            CURLOPT_HEADER         => false,    // don't return headers
            CURLOPT_FOLLOWLOCATION => true,     // follow redirects
            CURLOPT_ENCODING       => "",       // handle all encodings
            CURLOPT_AUTOREFERER    => true,     // set referer on redirect
            CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
            CURLOPT_TIMEOUT        => 120,      // timeout on response
            CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
        );

        $ch      = curl_init( $url );
        curl_setopt_array( $ch, $options );
        $content = curl_exec( $ch );
        $err     = curl_errno( $ch );
        $errmsg  = curl_error( $ch );
        $header  = curl_getinfo( $ch );
        curl_close( $ch );

        $header['errno']   = $err;
        $header['errmsg']  = $errmsg;
        $header['content'] = $content;
        return $header;
    }
?>

The downside is that it changes when loadshedding starts so you don't have a warning. You need to scrape their twitter feed for ahead of time notification.
 
Top
Sign up to the MyBroadband newsletter
X