Author Topic: NWS API forecast request limits  (Read 1306 times)

0 Members and 1 Guest are viewing this topic.

Offline daneast

  • Member
  • *
  • Posts: 48
NWS API forecast request limits
« on: January 26, 2019, 05:43:54 PM »
What are the realistic rate limits of the NWS API? The only information I found talked about not retrieving data more often than the known refresh frequency.  IE if a forecast is updated every 6 hours, don't poll more frequently than that.  Beyond that there are no actual stated limits.

Here's the scenario.  Say I create a weather app for iPhone / Android which retrieves forecast data directly from the NWS.  Each device caches data appropriately and doesn't request more often than refresh frequency for that data.  So all is well and good... however let's say I have 1 million people install my app.  That's 1 million weather requests coming in.  Since NWS does not have access tokens, and since the devices would all have different IP addresses and use a generic useragent, the NWS has absolutely no way of knowing those requests are from a common app.

Does anyone have any information on this type of access?  I guess since NWS doesn't require access tokens they feel this kind of usage is acceptable?  After all it would be no different than my including a webview in my app that pulls up their forecast directly on the NWS site.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS API forecast request limits
« Reply #1 on: January 26, 2019, 06:18:45 PM »
I've not seen any discussion regarding rate limits.  The api.weather.gov service is being set up on Akamai so can likely handle a prodigious number of requests per second.

My advforecast2.php V5 script (JSON) caches the result for 1 hour if successful.  Keep in mind that it usually requires 2 API requests - one for the /point/{lat},{long}/forecast which returns the /gridpoints/{WFO}/{x},{y}/forecast URL which then returns the actual forecast JSON you want.
I cache separately the /point/{lat},{long}/forecast => /gridpoints/{wfo}/{x},{y}/forecast in a lookup to cut the API calls to 1 after the first successful one. Note: the lat/long need to have no more than 4 decimal places or the API gripes.
Other API calls have to be made/stored for 'static' info about the point .. I store those also after the first lookup.
It's amongst the messiest of the REST APIs I've seen .. they think they're making it canonical .. I think they're making it unduly complicated, but so be it.

Quote
<!-- advforecast2.php (JSON) - V5.09 - 26-May-2018 on PHP 7.2.14-->
<!-- RAW NWS URL: http://forecast.weather.gov/MapClick.php?lat=37.26383&lon=-122.02301460000001&unit=0&lg=english&FcstType=text&TextType=2 -->
<!-- zone=CAZ513 -->
<!-- loaded URLcache from ./cache/forecast-URLcache.txt with 9 entries -->
<!-- corrected NWS API URL='https://api.weather.gov/points/37.2638,-122.023/forecast' -->
<!-- replaced point URL with gridpoint URL from URLcache -->
<!-- curl fetching 'https://api.weather.gov/gridpoints/MTR/97,101/forecast' -->
<!-- HTTP stats:  RC=200 dest=23.36.32.118
      Times: dns=0.045 conn=0.088 pxfer=0.275 get=0.045 total=0.320 secs -->
<!-- loaded point-forecast https://api.weather.gov/points/37.2638,-122.023/forecast - 10214 bytes -->
<!-- wrote cache file ./cache/forecast-CAZ513-0-json.txt -->
<!-- meta info re: point='37.2638,-122.023' zone='CAZ513' metacache= './cache/forecast-CAZ513-0-json-meta.txt' -->
<!-- metaZoneURL='https://api.weather.gov/zones/forecast/CAZ513' -->
<!-- loaded meta info from ./cache/forecast-CAZ513-0-json-meta.txt -->
<!-- META
Array
(
    [city] => Saratoga
    [state] => CA
    [point] => 37.2638,-122.023
    [forecastOfficeURL] => https://api.weather.gov/offices/MTR
    [forecastZoneURL] => https://api.weather.gov/zones/forecast/CAZ513
    [forecastZone] => CAZ513
    [forecastHourlyURL] => https://api.weather.gov/points/37.2638,-122.023/forecast/hourly
    [forecastGridDataURL] => https://api.weather.gov/gridpoints/MTR/97,101
    [observationStationsURL] => https://api.weather.gov/points/37.2638,-122.023/stations
    [countyZoneURL] => https://api.weather.gov/zones/county/CAC085
    [countyZone] => CAC085
    [fireWeatherZoneURL] => https://api.weather.gov/zones/fire/CAZ513
    [fireWeatherZone] => CAZ513
    [timeZone] => America/Los_Angeles
    [radarStation] => KMUX
    [zoneName] => Santa Clara Valley Including San Jose
    [WFOname] => San Francisco Bay Area/Monterey, CA
    [WFOphone] => (831) 656-1725
    [WFOemail] => w-mtr.webmaster@noaa.gov
)
 -->
« Last Edit: January 26, 2019, 06:23:53 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

 

anything