Skip to main content

air-quality-index

Download the current air quality map from AirNow, as GeoJSON or typed Python records.

This is a copy of AirNow's PM2.5 map. It is not an official source of health advice. For guidance on what to do about the air where you are, use AirNow and your local health agency.

Install

uv add air-quality-index

Use it from the command line

airqualityindex air-quality > air-quality.geojson
airqualityindex air-quality --timeout 60 --verbose

Use it from Python

import air_quality_index

data = air_quality_index.get_air_quality()  # GeoJSON
report = air_quality_index.get_air_quality_report()  # typed records
print(report.observed_at, len(report.areas))
for area in report.areas:
    print(area.level.label, area.level.aqi_range)

Use your own request function

Some projects send every web request through their own helper, for shared retries, logging or proxy settings. Pass that helper as get and the package will use it instead of requests.get. It is called like get(url, timeout=seconds) and must return something with a status_code and the file's content as bytes. The timeout and the retries still work, and failures still raise AirNowError.

import requests

import air_quality_index
from air_quality_index import Reply


def my_get(url: str, *, timeout: float) -> Reply:
    return requests.get(url, timeout=timeout, headers={"User-Agent": "my-project"})


data = air_quality_index.get_air_quality(get=my_get)

Things to know

  • It shows the level, not a number. AirNow's file says which air quality level each patch of the map is in, such as "Good" or "Unhealthy". It does not say the exact index number. The documentation lists the number range for each level.
  • It covers PM2.5 only. PM2.5 is fine particles, such as wildfire smoke. Ozone and other pollutants are not in this file.
  • It is fairly fresh. AirNow replaces the file every hour, and the hour it is for is in report.observed_at. This package does not keep old copies.
  • The data is not fully checked. AirNow says its data "are not subjected to the full validation used to officially submit and certify data" for the EPA's regulatory records.
  • Downloads retry. A request waits 30 seconds, then tries again on network errors and server errors, and raises air_quality_index.AirNowError if it still fails.
  • AI helped write this package. AI tools assisted in writing its code, tests and documentation. A person directed and reviewed the work.

The documentation has the field reference and the notes on AirNow's data.

Working on the code

This repository's full history is about 558 MB, because the scraped data files were saved to it for years. Copy only the latest version:

git clone --depth 1 https://github.com/datadesk/air-quality-index.git

Metadata

Release files for air-quality-index 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for air-quality-index 2.0.0
File Size Uploaded Provenance Actions
air_quality_index-2.0.0.tar.gz 131.7 kB With provenance Details for air_quality_index-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for air-quality-index 2.0.0
File Interpreter ABI Platform Actions
air_quality_index-2.0.0-py3-none-any.whl Python 3 none any Details for air_quality_index-2.0.0-py3-none-any.whl

Total release size: 145.4 kB

Release files / air_quality_index-2.0.0.tar.gz

Download URL air_quality_index-2.0.0.tar.gz
Size 131.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e698dd63169482e593cbce814639961cdc281bd45b0254ecf14deb4aff93b459
BLAKE2b-256 checksum
How to use checksums
b6cb5cc03dd3ec2fb0085002307f5c78e6ca4fd90fd5dfe9ad1470b3570b6778
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / air_quality_index-2.0.0-py3-none-any.whl

Download URL air_quality_index-2.0.0-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ee689c8df0ffa9323fb84cba591a42e1224086d64cd00b4c40e04b9e9c440fc
BLAKE2b-256 checksum
How to use checksums
11678405b75226aeeae1d28568ade1631dd1c2f6faddd55d132858137f36e7ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for air-quality-index 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for air_quality_index-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page