We were seeing failing requests (403 error code) to the waterservices API. Upon investigation of USGS documentation, local testing, and talking with IT at USGS, we now know that requests for data from the waterservices API older than 120 days should be requested from the url prefixed 'nwis'. Otherwise, the request gets redirected to a different origin (waterservices to nwis.waterservices) and the app encounters CORS issues in the browser. The CORS failure is sneakily masquerading as the 403.
In discussion with USGS, we clarified some other details that I'll note here:
There is no rate limiting on these endpoints
There is no combination of params to pull most recent data
We'd have to provide some time band through startDate, period and/or modifiedSince. modifiedSince looks promising at a glance but it's not actually different in usage than the other options, in terms of becoming stale.
Pulling "too much" data should not break the request
Demo
Using the un-prefixed URL:
Testing Instructions
Open the netlify build on this PR. Refresh wildly and ensure the API requests come back successfully each time.
Overview
We were seeing failing requests (
403
error code) to the waterservices API. Upon investigation of USGS documentation, local testing, and talking with IT at USGS, we now know that requests for data from the waterservices API older than 120 days should be requested from the url prefixed 'nwis'. Otherwise, the request gets redirected to a different origin (waterservices to nwis.waterservices) and the app encounters CORS issues in the browser. The CORS failure is sneakily masquerading as the403
.In discussion with USGS, we clarified some other details that I'll note here:
startDate
,period
and/ormodifiedSince
.modifiedSince
looks promising at a glance but it's not actually different in usage than the other options, in terms of becoming stale.Demo
Using the un-prefixed URL:
Testing Instructions
Open the netlify build on this PR. Refresh wildly and ensure the API requests come back successfully each time.