The Air Quality API provides the latest air quality information for any city or geographic location in the world. It provides not only the holistic Air Quality Index (AQI) but also concentrations for major pollutants:
https://api.api-ninjas.com/v1/airquality
Get air quality by city or location coordinates (latitude/longitude). Returns the air quality index (AQI) and concentrations of major pollutants.
lat
requiredLatitude of desired location.
lon
requiredLongitude of desired location.
city
requiredCity name.
state
optionalUS state (for United States cities only).
country
optionalCountry name.
X-Api-Key
requiredAPI Key associated with your account.
https://api.api-ninjas.com/v1/airquality?city=London
Headers
X-Api-Key
Log in or sign up to get your API Key
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{
"overall_aqi": 55,
"CO": {
"concentration": 223.64,
"aqi": 2
},
"PM10": {
"concentration": 3.62,
"aqi": 3
},
"SO2": {
"concentration": 5.13,
"aqi": 7
},
"PM2.5": {
"concentration": 1.82,
"aqi": 5
},
"O3": {
"concentration": 60.8,
"aqi": 55
},
"NO2": {
"concentration": 9.68,
"aqi": 12
}
}
1
2
3
4
5
6
7
8
import requests
city = 'london'
api_url = 'https://api.api-ninjas.com/v1/airquality?city={}'.format(city)
response = requests.get(api_url, headers={'X-Api-Key': 'YOUR_API_KEY'})
if response.status_code == requests.codes.ok:
print(response.text)
else:
print("Error:", response.status_code, response.text)
If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.