USGS Data Fetching
Revision as of 16:21, 29 May 2025 by DaveSanderman (talk | contribs)
USGS Data Fetching
We use URLs of the following format to fetch USGS data:
https://waterservices.usgs.gov/nwis/iv/?format=json&indent=on¶meterCd=00060,00065&siteStatus=all&sites=12141300&period=PT22M29.5308163S
This is provided by the "Instantaneous Values" service, documented here: https://waterservices.usgs.gov/docs/instantaneous-values/instantaneous-values-details/
The important pieces of the URL:
- parameterCd=00060,00065 -- This indicates that we want parameters 00060 and 00065, which are water height and discharge
- sites=12141300 -- This is which gauge we want to look at
- period=PT22M29.5308163S -- This is the time range we want to fetch data for; basically it will be an encoded version of "since the last time we asked".
Notes about changes
The USGS is updating their systems, and we'll have to make changes to support the updated format. This is a series of notes about the changes we'll have to make.
- URL Base is changing
- parameter names are changing but the encoding appears to be the same
- e.g. "period" parameter will still be encoded in "P1D" format
- all the metadata gunk in the response is going away, yay
- will want to get an API Key to avoid rate-limiting (although 100 requests/hour is probably more than we need)
- keys will allow 1000 per hour which is definitely plenty