Need help getting started with REST API

Hi - I am trying to get started with the REST API using Python and need some help. I can get the current observation using the following Python code:

Get Latest Observation

resp = requests.get(‘’ + stationID + ‘?token=’ + token)
if resp.status_code != 200:
print(‘Error accessing station’)

However, I don’t understand how to modify this to get a range of observations by passing things like the “obs_air”, “day_offset”, “time_start”, “time_end”, and “format” parameters. Could someone please advise or provide an example?


You can pass the extra parameters as query string parameters in the URL. That is you pass them after the ? in the URL (token is a query string parameter as well), and you separate them with an ampersand. For example, you can use time_start and time_end like:

or you can use day_offset like:

Hope this helps!

if click on the api in the menu on the top of this page, you can play with it and see how it is formatted

Super helpful - thank you!!!

OK - still having problems. I can get the station status information but when I try to retrieve the observations I am getting an authorization error. The command works the api webpage but not from my python script. Advice appreciated! Code below.

Try getting observations from the station

deviceID = ‘129977’
resp = requests.get(‘’ )
if resp.status_code != 200:
# This means something went wrong.

Have you generated a token from your account and use it to authenticate ?

In settings, down the page Data authorizations to generate one or find it back if already generated

1 Like

As Eric said the URL you are using in requests.get is missing the token= parameter. Follow Eric’s instructions to get a token and then add this into the URL. You may also want to change the format=csv parameter as I have no idea how requests will deal with this option. It might work fine, so feel free to ignore

1 Like

Thanks guys! I ended up authenticating using the cURL command provided in the API webpage and things seem to work OK now. Seems like the format-csv parameter works OK. Now to figure out how to get the resulting mess into a pandas dataframe. (The idea of dumping the observations into a series of Google Sheets documents using the IFTTT initially sounded messy, but is sounding better now. This whole process seems more complicated than it should be (at least for me)…