Air Quality API

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:

  • Carbon monoxide (CO)
  • Nitrogen dioxide (NO2)
  • Ozone (O3)
  • Sulphur dioxide (SO2)
  • PM2.5 particulates
  • PM10 particulates

/v1/airquality GET

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.


Parameters

  • lat  required

    Latitude of desired location.

  • lon  required

    Longitude of desired location.

  • — or —
  • city  required

    City name.

  • state  optional

    US state (for United States cities only).

  • country  optional

    Country name.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Sample Request Live Demo!

city
https://api.api-ninjas.com/v1/airquality?city=London

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
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 } }

Code Examples

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.