/aqi

Air quality data from the World Air Quality Index (WAQI)

Primary LanguageEmacs LispGNU General Public License v3.0GPL-3.0

Air Quality Index (AQI)

https://melpa.org/packages/aqi-badge.svg

The aqi package provides an interface to the World Air Quality Index.

“The World Air Quality Index project is a non-profit project started in 2007. Its mission is to promote air pollution awareness for citizens and provide a unified and world-wide air quality information. The project is providing transparent air quality information for more than 100 countries, covering more than 12,000 stations in 1000 major cities, via those two websites: aqicn.org and waqi.info.”

“The Air Quality Index is based on measurement of particulate matter (PM2.5 and PM10), Ozone (O3), Nitrogen Dioxide (NO2), Sulfur Dioxide (SO2) and Carbon Monoxide (CO) emissions. Most of the stations on the map are monitoring both PM2.5 and PM10 data, but there are few exceptions where only PM10 is available.”

Further information can be found on the WAQI site, in particular the sources & coverage, API docs and FAQ.

Installation, configuration and use

The aqi package can be installed from MELPA or manually via github.

To access the WAQI project API it’s necessary to register at http://aqicn.org/data-platform/token/ and generate a key. Once you have your API key it can be configured via use-package, M-x customize or manually.

(use-package aqi
 :config (setq aqi-api-key "your-api-key“
          aqi-use-cache t)

The simplest way to view AQI info is with M-x aqi-report which displays air quality info for your algorithmically derived location (equivalent to the location “here”) or the name of a place. A place can be the name of a city (in which case the nearest monitoring station is used) or the id of specific monitoring station.

By name…

(aqi-report "Ulaanbaatar")

By id…

(aqi-report "@7397")

A detailed report is displayed by default and a single line summary can be provided by using the keyword brief

(aqi-report "Taipei" 'brief)

To use the data programmatically, the functions aqi-report-full and aqi-report-brief return the report as a string. The function aqi-city-aqi will return the AQI for a given city as a number.

(aqi-city-aqi "Osaka")

There are macros that can be used to create accessors for specific data points from the city/station feed. For example, (aqi--make-city-raw-accessor 'aqi-station .attribution) will create the function aqi-station which returns the attribution field as specified in the API reference.

Further