# OpenAQ Air Quality Tracker — PM2.5, PM10, NO2, O3, CO, SO2 (`gochujang/openaq-air-quality-tracker`) Actor

Fetch real-time and historical air quality measurements from 30,000+ monitoring stations worldwide via the OpenAQ API v3. Supports PM2.5, PM10, NO2, O3, CO, SO2 across any country. Returns AQI category per reading. No API key required — optional key raises rate limits.

- **URL**: https://apify.com/gochujang/openaq-air-quality-tracker.md
- **Developed by:** [Hojun Lee](https://apify.com/gochujang) (community)
- **Categories:** Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## OpenAQ Air Quality Tracker

Collect real-time and historical air quality measurements from **30,000+ monitoring stations worldwide** using the [OpenAQ API v3](https://api.openaq.org). Track PM2.5, PM10, NO2, O3, CO, and SO2 across any country — with built-in AQI category labels and no required API key.

***

### What it does

| Mode | Description |
|------|-------------|
| `latest` | Most recent measurement per station per pollutant |
| `historical` | All measurements in a user-specified date range |
| `locations` | Station metadata only (coordinates, city, country) |

Each output record includes location name, city, country, GPS coordinates, pollutant name, value, unit, AQI category (for PM2.5), and timestamp.

***

### Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `mode` | string | `latest` | `latest`, `historical`, or `locations` |
| `countries` | array | `[]` | ISO 2-letter country codes (e.g. `US`, `KR`, `DE`). Empty = all |
| `parameters` | array | `[]` | Pollutant IDs: `pm25`, `pm10`, `no2`, `o3`, `co`, `so2`. Empty = all |
| `maxLocations` | integer | `50` | Max stations per country |
| `dateFrom` | string | `""` | ISO 8601 start for historical mode (e.g. `2026-08-01T00:00:00Z`) |
| `dateTo` | string | `""` | ISO 8601 end for historical mode |
| `openaqApiKey` | string | `""` | Optional API key — increases rate limits |

***

### Output

```json
{
  "location_id": 12345,
  "location_name": "Seoul Station",
  "city": "Seoul",
  "country": "KR",
  "coordinates": { "lat": 37.5566, "lon": 126.9722 },
  "parameter": "pm25",
  "value": 23.5,
  "unit": "µg/m³",
  "aqi_category": "Moderate",
  "measured_at": "2026-09-02T08:00:00Z",
  "source": "OpenAQ"
}
```

#### AQI Categories (PM2.5, US EPA)

| µg/m³ | Category |
|--------|----------|
| 0 – 12 | Good |
| 12 – 35.4 | Moderate |
| 35.5 – 55.4 | Unhealthy for Sensitive Groups |
| 55.5 – 150.4 | Unhealthy |
| 150.5 – 250.4 | Very Unhealthy |
| 250.5+ | Hazardous |

***

### Pricing (Pay-Per-Event)

| Event | Price |
|-------|-------|
| Actor start | $0.005 |
| Per measurement record | $0.001 |

Example: querying 3 countries × 50 stations × 3 pollutants ≈ 450 records → ~$0.46

***

### Data source

[OpenAQ](https://openaq.org) aggregates data from government monitoring networks around the world. Data quality and availability vary by country and station.

- API docs: https://api.openaq.org/v3
- Get a free API key: https://explore.openaq.org/register

# Actor input Schema

## `mode` (type: `string`):

Operation mode: 'latest' fetches the most recent measurement per station, 'historical' fetches measurements in a date range, 'locations' returns station metadata only.

## `countries` (type: `array`):

Country codes to query, e.g. US, KR, DE. Leave empty to query all countries (may be slow).

## `parameters` (type: `array`):

Pollutant IDs to filter. Supported: pm25, pm10, no2, o3, co, so2. Leave empty for all.

## `maxLocations` (type: `integer`):

Maximum number of monitoring stations to query per country.

## `dateFrom` (type: `string`):

Start date for historical mode, e.g. 2026-08-01T00:00:00Z. Ignored in latest/locations mode.

## `dateTo` (type: `string`):

End date for historical mode, e.g. 2026-08-31T23:59:59Z. Ignored in latest/locations mode.

## `openaqApiKey` (type: `string`):

Optional API key from openaq.org. Increases rate limits. Leave blank for anonymous access.

## Actor input object example

```json
{
  "mode": "latest",
  "countries": [
    "US",
    "KR",
    "DE"
  ],
  "parameters": [
    "pm25",
    "pm10",
    "no2"
  ],
  "maxLocations": 50,
  "dateFrom": "",
  "dateTo": ""
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `summary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "countries": [
        "US",
        "KR",
        "DE"
    ],
    "parameters": [
        "pm25",
        "pm10",
        "no2"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("gochujang/openaq-air-quality-tracker").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "countries": [
        "US",
        "KR",
        "DE",
    ],
    "parameters": [
        "pm25",
        "pm10",
        "no2",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("gochujang/openaq-air-quality-tracker").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "countries": [
    "US",
    "KR",
    "DE"
  ],
  "parameters": [
    "pm25",
    "pm10",
    "no2"
  ]
}' |
apify call gochujang/openaq-air-quality-tracker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,gochujang/openaq-air-quality-tracker"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/YdhLQPSq5E7qv4Ox4/builds/dpRBmXgdt7h6k1tMD/openapi.json
