An open API service indexing awesome lists of open source software.

https://github.com/teamjorge/eskomlol

Eskom Loadshedding API package
https://github.com/teamjorge/eskomlol

Last synced: 5 months ago
JSON representation

Eskom Loadshedding API package

Awesome Lists containing this project

README

          

# eskomlol

Eskom Loadshedding API package

`eskomlol` (eskom lekker ol' loadshedding)

## Overview

`eskomlol` provides a thin wrapper around the existing Eskom API for loadshedding. This package attempts to simplify using the not-so-friendly base API. Please note that changes of the API will potentially break this package. If we don't expect Eskom to properly maintain powerstations, we probably can't expect them to maintain an API.

## Usage

```go
package main

import (
"context"
"fmt"
"log"
"time"

"github.com/teamjorge/eskomlol"
)

func main() {
// Creating a new client with no options
client := eskomlol.New()

// Creating a client with some options
client = eskomlol.New(eskomlol.WithTimeout(60 * time.Second))

// Get current loadshedding stage
stage, err := client.Status(context.Background())
if err != nil {
log.Fatal(err)
}

fmt.Println("Stage\n", stage)

// Hopefully prints -1 or 0 :D
}
```

Additional calls you can make are:

* `Municipalities`
* `Suburbs`
* `SearchSuburbs` (Similar to Suburbs but does not require a municipality)
* `Schedule`

## Notes

During testing I've noticed that some of the suburbs do not have schedules available. I'm not 100% sure if this is due to the municipalities not making them available or if it's just Eskom not having them. I'm not sure how ESP are sourcing their info, but I'm assuming it's via scraping. That could potentially be added later if there's demand for it.

## Contributing

If you find bugs or have feature requests, don't be afraid to gooi a PR or create a new issue. I'm happy to improve this if folks are actually using it.