Check the setup
- Python 3.10 or newer
- A notebook environment such as Jupyter or Google Colab
- An AirNow API key saved in the AIRNOW_API_KEY environment variable
Preliminary real-time AQI observations and forecasts for building local air-quality displays, relays, and operational awareness tools.
From source to product signal
AirNow distributes AQI observations and forecasts reported by participating air-quality agencies. Start with the current monitoring-site service for a small geographic box and preserve the official AQI values and categories. Observations are preliminary, not regulatory data, and must not be altered or presented as independent health or regulatory advice.
Install the packages, then run the notebook cell.
python -m pip install pandas requests
import os
from datetime import datetime, timedelta, timezone
import pandas as pd
import requests
end = datetime.now(timezone.utc).replace(minute=0, second=0, microsecond=0)
start = end - timedelta(hours=2)
response = requests.get(
"https://www.airnowapi.org/aq/data/",
params={
"startDate": start.strftime("%Y-%m-%dT%H"),
"endDate": end.strftime("%Y-%m-%dT%H"),
"parameters": "O3,PM25",
"BBOX": "-77.20,38.80,-76.80,39.10",
"dataType": "A",
"format": "application/json",
"verbose": 1,
"monitorType": 0,
"includerawconcentrations": 0,
"API_KEY": os.environ["AIRNOW_API_KEY"],
},
timeout=30,
)
response.raise_for_status()
observations = pd.DataFrame(response.json())
observations["retrieved_at_utc"] = pd.Timestamp.now(tz="UTC")
columns = ["UTC", "Parameter", "AQI", "Category", "Latitude", "Longitude"]
print(observations.reindex(columns=columns).head(20))Test a useful signal
Display the latest official AirNow AQI values and categories returned for a small geographic area.
U.S. Environmental Protection Agency AirNow Program is a government source. Last verified 2026-08-11. Temporal coverage: current and recent observations and forecasts.