
Update 18 Jan 2016: We’re holding an informal meet up on OpenAQ 10 Feb evening in Washington, DC. Come join us! More info here + RSVP here.
We’ve got nearly 1.5 million air quality data points and counting aggregated into our database for anyone to check out. But honestly? Unless you’re a software developer, we know the data are not super easy to access without knowing a little bit about APIs. So we’ve been working on increasing accessibility to this ‘data playground’ from a few of angles: (1) We’re actively working on building user-friendliness into the platform for a wider audience, (2) We’re getting help from the OpenAQ Community (check out this lovely data interface created by Dulguun B. at our recent UB OpenAQ Workshop), and, (3) in the meantime, below we’re posting detailed and simple instructions on how you can get the data you want via an API. These instructions will evolve with time as our platform evolves, so check back from time to time!

But for Now: How can I access OpenAQ Data from the website and API?
This exercise explains how to use the OpenAQ Platform to access the more than 1,400,000 air quality data points from 400 stations in 11 countries available on the site. We tested this out at the UB OpenAQ workshop, and it went great. NOTE: The OpenAQ Prototype Platform is quickly evolving. If you have questions on this exercise, find it out of date or detect an error, please email: info@openaq.org or join our slack channel, where you can ask questions to members of the OpenAQ Community in a chat-room: https://openaq-slackin.herokuapp.com
Data on the OpenAQ Platform is accessible in two ways:
(1) All data collected for any given location (i.e. a unique air quality station) is downloadable in bulk on the OpenAQ website under ‘Sources.’ The file type is .csv, which you can open in a program like Excel, for example.
(2) You’ll notice that the data files available on the ‘Sources’ site is great for downloading bulk data, but you may want specific types of pollutant data (e.g. only PM2.5 data), from multiple locations in a whole city, and/or only for specific date ranges. You can use the API to make a customizable query.
The base for any query to the API is:
We can add stuff to this URL to get the information you want from the system. The full documentation is on docs.openaq.org, which you may want to open as we go through a few examples.
USING THE API
EXAMPLE 1: Let’s look at data from Amsterdam.
(A) Get all of the available air quality data in the system for Amsterdam: https://api.openaq.org/v1/measurements?city=Amsterdam
This returns the data in json format. Don’t like that? Don’t worry — the last step will turn it into a csv file.
(B) Let’s get all of the available SO2 data in the system for Amsterdam:
https://api.openaq.org/v1/measurements?city=Amsterdam¶meter=so2
(Note: Once you add more than one query parameter, you separate them with ‘&’ symbols. The first query parameter used a ‘?’ symbol)
(C) But, wait, we only want SO2 data in Amsterdam from October 1st and forward:
https://api.openaq.org/v1/measurements?city=Amsterdam¶meter=so2&date_from=2015-10-01
(D) Oops! Actually, as it turns out, we only want SO2 data in Amsterdam between October 1st and October 15:
(E) And finally, if you’d prefer to download the data in a .csv file:
Try these tasks: [Answers at the end of this post]
TASK 1: Recently, there were many reports in the international media about a severe air quality episode — a so-called ‘airpocalypse’ in Shenyang, China. Also, air pollution levels were reported to soar in New Delhi due to the holiday of Diwali.
How could we use the API to access recent Shenyang and New Delhi PM2.5 data in .csv format for the period of 1 Nov to 15 Nov 2015?
TASK 2: If you wanted to populate a map in an app or on a website with the real-time (latest) PM2.5 data in UB, how could we use the API to do this? HINT: UB is referred to as ‘Ulaanbaatar’ in the API.
TASK 3: How could you use the API to determine which stations in UB are reporting the highest NO2?
So now you should try out your own calls! Make any cool graphics or visualizations with the data? Let us know!
Access these exercises in pdf + docx forms, as well as all of our recent workshop’s materials here.
Answers:
Task 1:
Shenyang:
New Delhi:
And this is what the result looks like, if you’re curious:

Task 2:
https://api.openaq.org/v1/latest?city=Ulaanbaatar¶meter=pm25
Task 3:
You could do this a couple of ways. Here’s one:
https://api.openaq.org/v1/measurements?city=Ulaanbaatar¶meter=no2&order_by=value&sort=desc