Author Topic: NWS CAP/ATOM v1.2 feed - news for scripters  (Read 382 times)

0 Members and 1 Guest are viewing this topic.

Offline JPB

  • Member
  • *
  • Posts: 26
NWS CAP/ATOM v1.2 feed - news for scripters
« on: December 11, 2022, 10:20:08 PM »
Are people aware of the NWS changing to the v1.2 CAP feed, away from v1.1?

My little weather script package has traditionally received alert information by querying a National Weather Service CAP/ATOM server at alerts.weather.gov - I assume like most scripts do.

However, recently, I've learned about the "at some point in the undetermined future" dropping of this v1.1 CAP service, which provides information in XML format. the NWS wants us to use a v1.2 CAP service, which provides information by default in JSON format. (but since learned: retrieving the information in XML is possible!)

I've modified my script to support both for the time being - the one used based on a configuration parameter, to allow me to compare the results of the two systems. It's fun hunting down severe weather in the US to find a zone/county with active alerts to allow for testing. ;)

My point in this note is to simply say that it's not hard to convert to using v1.2 JSON. There are a few minor differences in what the two formats contain, but those are not insurmountable.

I encourage scriptwriters to consider starting to build support for v1.2/JSON alerts in their scripts, if they haven't already. It wasn't all that painful to do, and it's best to begin sooner rather than later so the work doesn't have to be done in a hurry in case the NWS shuts down the v1.1 feed.
« Last Edit: December 12, 2022, 11:43:16 AM by JPB »
Davis Pro 2, Meteohub

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 910
    • LexMAWeather
Re: NWS CAP/ATOM v1.2 feed - news for scripters
« Reply #1 on: December 12, 2022, 10:47:53 AM »
CAP v1.2 still supports XML. You can fetch alerts in XML via the NWS API (api.weather.gov) by setting the "accept" header to "application/atom+xml".

E.g.

Code: [Select]
curl -X GET "https://api.weather.gov/alerts/active?status=actual&area=CA&limit=500" -H  "accept: application/atom+xml"

Offline JPB

  • Member
  • *
  • Posts: 26
Re: NWS CAP/ATOM v1.2 feed - news for scripters
« Reply #2 on: December 12, 2022, 11:41:57 AM »
CAP v1.2 still supports XML. You can fetch alerts in XML via the NWS API (api.weather.gov) by setting the "accept" header to "application/atom+xml".

E.g.

Code: [Select]
curl -X GET "https://api.weather.gov/alerts/active?status=actual&area=CA&limit=500" -H  "accept: application/atom+xml"

Thank you for this! Having briefly considered it, I’ll stay with my JSON supporting code, because, honestly, I find the JSON format simpler to read, and better supported by PHP.
Davis Pro 2, Meteohub

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 910
    • LexMAWeather
Re: NWS CAP/ATOM v1.2 feed - news for scripters
« Reply #3 on: December 12, 2022, 01:07:30 PM »
Thank you for this! Having briefly considered it, I’ll stay with my JSON supporting code, because, honestly, I find the JSON format simpler to read, and better supported by PHP.

I came to the same conclusion when I did my alerts rewrite a while back!

Offline rrrick8

  • Senior Contributor
  • ****
  • Posts: 209
    • Vermilion weather
Severe Weather Manager-Vermilion County EMA
CWOP-CW9931 KILDANVI5

Offline JPB

  • Member
  • *
  • Posts: 26
Re: NWS CAP/ATOM v1.2 feed - news for scripters
« Reply #5 on: December 14, 2022, 09:32:13 AM »
Yes, thank you,  I discovered this later.

Since my code now supports xml/json 1.2 as well as xml 1.1, I can now offer up the use of the other service as backup during the pre-removal of 1.1, as they are hosted on different servers.

One point to make is that the v1.2 service does not offer an alert image to you. You have to “guess one” (I use the VTEC do do that, and if there isn’t an image for it then use one of the images (the one with the exclamation point) as a default, choosing a color of it to match the severity level noted.)

 
Also...
https://www.wxforum.net/index.php?topic=44502.0
Davis Pro 2, Meteohub

 

anything