Alright Lads,
I'm a whole week into playing around with API's... Some of the rust is falling off my programming but boy is it still terrible. Anywho, wrapped up the little scripts I was writing into something more useful today.
It takes in a UK postcode, converts it to a set of GPS coordinates via google, then looks up all the air quality monitors in the UK (filtered by those still active using the kings college API) and does a bit of maths to figure out the distance from the address to each unit. Then the closest unit is chosen and polled using a separate API call to see what sensors it has. These sensors are then polled individually using another call, a days info is pulled, averaged and displayed to give an idea of what the air quality is like near you right now.
I'm happy with it, had never really done any JSON, API or array/list logic before so that took a lot of my time. I'm going to play with NTP tomorrow so the script always pulls the last 24 hours rather than a time period I listed.
I also want to make a dict describing the yearly goal number for every pollutant measured in the UK. I know what the numbers mean but having something to compare them against would make them more relevant.
Anywho its on the site
here. Each of the functions (with some tweaks and error handling included) have been properly described during the week so I went light on explanation today. Also I had to go back to work, I pricked about with it for an hour.
Let me know what you think!
Greg