Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: LWP::UserAgent Alternatives for API data

by Aldebaran (Deacon)
on Jul 07, 2020 at 05:38 UTC ( #11118991=note: print w/replies, xml ) Need Help??


in reply to Re: LWP::UserAgent Alternatives for API data
in thread LWP::UserAgent Alternatives for API data

I think marto's reply to a similar question from me is relevant: Re: polishing up a json fetching script for weather data.

# the API docs says you must identify yourself, please make this somet +hing legit my $name = '(example.com, contact@example.com)'; my $ua = Mojo::UserAgent->new; $ua->transactor->name( $name ); # get JSON response my $json = $ua->get( $url )->res->json->{properties};

I wonder if we're looking at the same API...are you shy to post your source?

Replies are listed 'Best First'.
Re^3: LWP::UserAgent Alternatives for API data
by johnfl68 (Scribe) on Jul 07, 2020 at 15:07 UTC

    I said it was the NWS API. Not hiding anything.

    https://api.weather.gov/

    I am working with 'Forecast' data. In the referenced Marto's reply post, they are trying to work with 'Latest Observations' which has even more issues than the Forecast data. I am sticking with the Latest Observations XML data from the NWS that comes from a different source than the NWS API. It has been much more reliable. Unfortunately they don't do the forecast data in XML like the latest observations, or I would use it instead right now.

    The NWS API is newer but it has been out for a few years now. It should be much more stable than it is at this point.

      He was probably referring to the fact that you haven't shown your source code with which you're having problems (which could reveal that there's something wrong / weird / off with what you're doing and that's where your problems are). Without your code (or an equivalent self-contained example snippet showing the same behavior) people are just guessing.

      The cake is a lie.
      The cake is a lie.
      The cake is a lie.

      Purely out of curiosity, can you be specific? Are you saying the API data differs from this XML source you have? Can you provide an example? If you believe there to be a discrepancy with the data have you reported this? It would likely be trivial to take the script provided and point it towards the XML source.

        When I started using the NWS API regularly about 2 months ago, the Current Obs were consistently coming back 4 or more hours old. The Current Obs are only supposed to be around an hour old at most.

        The forecasts at the time were coming back 2-4 hour old, but the NWS says that is about correct for those, as they are not updated as often. I just got back data for one location that is 239 hours old (loads the same old date in web browser matching the server version). Another forecast location has been giving back 503 error since late last night (both browser and server).

        For the Current Obs, instead of using (Station KMCO as example)

        https://api.weather.gov/stations/KMCO/observations/latest

        you would use

        https://w1.weather.gov/xml/current_obs/KMCO.xml

        to get the data. If you do this from a browser, you will get a style sheet version, just use view source to see the pure XML.

        There are some differences, but most of the basic information is the same. The XML data has been much more stable than the API versions.

        Hope that helps.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11118991]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2020-11-24 12:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?