Skip to content

Python code snippet – How do i connect to the nation api on PNW?

#NOTE: This is for python applications
import requests, json

nationID = "nationID you want data on"
apikey = "Your PNW api key (found on the account page)"

nationreq = requests.get(f"{nationID}&key={apikey}")
nationreq = nationreq.json()


cityids = nationreq["cityids"]
nationid = nationreq["nationid"]
nation_name = nationreq["name"]
nation_prename = nationreq["prename"]
uniqueid = nationreq["uniqueid"]

print(f"{cityids} {nationid} {nation_name} {nation_prename} {uniqueid}")
See also  Python code snippet - How to set index pandas?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.