Skip to content

Instantly share code, notes, and snippets.

@diodon
Created June 8, 2021 07:38
Show Gist options
  • Select an option

  • Save diodon/bbde3c3529d6d2d94bf129b76232e6d2 to your computer and use it in GitHub Desktop.

Select an option

Save diodon/bbde3c3529d6d2d94bf129b76232e6d2 to your computer and use it in GitHub Desktop.
Finding the AIMS weather station ID is necessary to get data from the instruments. This function returns the station name, ID and its metadata URL
## Get AIMS weather Station ID, name and metadata record link
import json
import requests
import prettytable
AIMSurl = "https://api.aims.gov.au/weather/latestreadings"
WSjson = json.loads(requests.get(AIMSurl).text)
tbl = prettytable.PrettyTable(['Station Name', "Station ID", "Metadata url"])
for station in range(len(WSjson)):
tbl.add_row([WSjson[station]['site_name'], WSjson[station]['site_id'], WSjson[station]['metadata']])
print(tbl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment