Turns out that there's no way to get all the alerts in Utah directly if you were to do this:
alerts = nwsapy.get_all_alerts()
You'd have to parse the IndividualAlert.areaDesc string. It's not always a City, State structure: there's national parks, etc (such as Yavapai County Mountains; Yavapai County Valleys and Basins; Oak Creek and Sycamore Canyons), so something like [alert for alert in alerts if "UT" in alert.areaDesc] doesn't work.
The way to go about doing this is to parse (not get) the affectedZones list. At the end of the URL, it has zones where the alert is effecting it (i.e. FLZ001), where the first 2 letters is the name of the state.
Turns out that there's discontinuity within the API itself. If I wanted to get all of the alerts in Utah, I can easily make a request like this:
Turns out that there's no way to get all the alerts in Utah directly if you were to do this:
You'd have to parse the
IndividualAlert.areaDesc
string. It's not always aCity, State
structure: there's national parks, etc (such as Yavapai County Mountains; Yavapai County Valleys and Basins; Oak Creek and Sycamore Canyons), so something like[alert for alert in alerts if "UT" in alert.areaDesc]
doesn't work.The way to go about doing this is to parse (not
get
) theaffectedZones
list. At the end of the URL, it has zones where the alert is effecting it (i.e. FLZ001), where the first 2 letters is the name of the state.