Accessing the Newcastle Urban Observatory API with Python

I participated in the Datamorphosis Hack Event at Newcastle City Library. I used the amazing Newcastle Urban Observatory, which gives access to a whole host of sensors spread around Newcastle, from temperature to number of cars in various car parks. They also provide an API to query sensors in a number of ways. I used some inner city sensor values for humidity, pressure, temperature, and wind speed to implement a cheap version of Till Bovermann’s Wetterreim (see Bovermann et al: Auditory Augmentation). I’ll document that in the future. For now, a bit of code to access the API:

This is Python 2 code, but would probably also work in Python 3. I used the requests package to do the requests. Get yourself an API key from here.

[gist id=8d01ae69862c759bb54b5dae1210b862]

You could run the do_that function in a thread every few seconds to update the values and maybe do something more useful than just printing them out.