Skip to content

Using USGS API

David Shi edited this page Mar 31, 2017 · 2 revisions

As of March 31, 2017:

Here's the URL for the data received from USGS for discharge and gage height: example

Parsing the data can be a little confusing because there are dictionaries within lists within dictionaries. Many lists are single element many dictionaries only contain one pair. Here's how we navigate to Discharge data:

Verifying which measurement with the parameter code and finding it

response = request.get(url)    
time_series = response.json()["value"]["timeSeries"]
param_code = time_series["variable"]["variableCode"][0]["value"]

Here param_code was 00060 which maps to Discharge.

Going into actual data:

values = time_series["values"][0]["value"]

values yields a list of dictionaries, inside which contains the value, time stamp and qualifier.

Clone this wiki locally