Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-create a PR using Cape Town's "API" #479

Open
beyarkay opened this issue Sep 21, 2023 · 0 comments
Open

Auto-create a PR using Cape Town's "API" #479

beyarkay opened this issue Sep 21, 2023 · 0 comments

Comments

@beyarkay
Copy link
Owner

Turns out, the cape town website's loadshedding page has an API that can be queried without needing an API key, like so:

curl 'https://d42sspn7yra3u.cloudfront.net/coct-load-shedding-extended-status.json' | jq

The result is a JSON array of all loadshedding since 2023-05-17T20:00:00. I'm not sure what's special about that date, maybe it's when the API was set up? Here's a snippet

[
  {
    "start": "2023-05-17T20:00",
    "end": "2023-05-18T05:00",
    "stage": "6"
  },
  {
    "start": "2023-05-18T05:00",
    "end": "2023-05-18T22:00",
    "stage": "3"
  },
... [336 objects omitted] ...
  {
    "start": "2023-09-21T16:00",
    "end": "2023-09-21T22:00",
    "stage": "1"
  },
  {
    "start": "2023-09-21T22:00",
    "end": "2023-09-22T05:00",
    "stage": "3"
  }
]

There's also this endpoint which can be used to check when the schedule was last updated:

curl 'https://d42sspn7yra3u.cloudfront.net/coct-load-shedding-extended-status-metadata.json'
{
  "lastUpdated": "2023-09-21T06:04:18.764+02:00"
}

Together, these endpoints could fully automate Cape Town's loadshedding via the GitHub API. This should definitely be done, and it seems like the cape town twitter feed gets manually updated based on data from the website, so the website is a better source of truth.

There's a slight problem in that there's no constant URL to historical data, so old schedules won't have any way to be verified. It's possible that this can be fixed by using the waybackmachine if they've got an API that allows programmatic saving of webpages, and then the "source" can be a web archive link. SO post 1
. SO post 2. Web archive API docs. Example saved page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant