AQI calculator (US EPA)
GET /api/aqi-calcUS EPA Air Quality Index from the pollutant concentrations you supply: PM2.5 and PM10 (µg/m³, 24-hour), ozone (ppb, 8-hour), carbon monoxide (ppm, 8-hour), sulfur dioxide and nitrogen dioxide (ppb, 1-hour). Send GET /api/aqi-calc with no required fields (6 optional) and pay $0.001 per call over x402 or MPP, or call it free by solving a proof-of-work challenge. It returns a JSON object with aqi, category, dominantPollutant, pollutants and scale.
Returns each pollutant's sub-index and category, the overall AQI (the highest sub-index) and the pollutant that sets it, using the published EPA breakpoint tables with the 2024 PM2.5 revision.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pm25 | number | no | PM2.5, µg/m³, 24-hour average |
pm10 | number | no | PM10, µg/m³, 24-hour average |
o3 | number | no | Ozone, ppb, 8-hour average |
co | number | no | Carbon monoxide, ppm, 8-hour average |
so2 | number | no | Sulfur dioxide, ppb, 1-hour average |
no2 | number | no | Nitrogen dioxide, ppb, 1-hour average |
Example request
curl -i "https://agent402.tools/api/aqi-calc?pm25=35.4&pm10=80&o3=60"
Without payment this returns HTTP 402 Payment Required with the exact price for aqi-calc; any x402 v2 or MPP client pays it and retries.
Example response
{
"aqi": 100,
"category": "Moderate",
"dominantPollutant": "pm25",
"pollutants": [
{
"pollutant": "pm25",
"name": "PM2.5",
"concentration": 35.4,
"unit": "µg/m³",
"averaging": "24-hour",
"aqi": 100,
"category": "Moderate"
},
{
"pollutant": "pm10",
"name": "PM10",
"concentration": 80,
"unit": "µg/m³",
"averaging": "24-hour",
"aqi": 63,
"category": "Moderate"
},
{
"pollutant": "o3",
"name": "Ozone",
"concentration": 60,
"unit": "ppb",
"averaging": "8-hour",
"aqi": 67,
"category": "Moderate"
}
],
"scale": "US EPA Air Quality Index (40 CFR Part 58 Appendix G; PM2.5 breakpoints as revised in 2024)"
}| Field | Type | Always present | In the example |
|---|---|---|---|
aqi | number | yes | 100 |
category | string | yes | Moderate |
dominantPollutant | string | yes | pm25 |
pollutants | array of objects | yes | 3 items in the example |
scale | string | yes | US EPA Air Quality Index (40 CFR Part 58 Appendix G; PM2.5 breakpoints as rev... |
From an MCP client
catalog.call {
"slug": "aqi-calc",
"params": {
"pm25": 35.4,
"pm10": 80,
"o3": 60
}
}On the hosted connector at https://agent402.tools/mcp, catalog.call runs aqi-calc free (rate-limited, no wallet). Local install: npx -y agent402-mcp@0.13.32.
Errors and behavior
- Every field is optional. An input the tool rejects returns an HTTP 4xx whose body carries
error,tool,expected,requiredandexample. - A paid call that ends in any status of 400 or above is not charged over x402, MPP or a prepaid credits key: settlement runs after the tool and only on a successful response. The exception is a Tempo push credential, a transfer the buyer sent before the call: it settles before the tool runs, so if the tool then fails the payment is recorded as a refund owed to the paying wallet.
- Free tier: no outbound network call leaves the server for this tool, so proof-of-work (16 leading zero bits of sha256) pays for it.
- A
POSTwith a JSON body to /api/aqi-calc is served as this GET, with the body as the input. - An
Idempotency-Keyheader makes a retried paid call replay the first 200 instead of charging again (an answer larger than 1 MB is not replayed).
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
client.setSpendControls?.({ maxAmountPerPayment: "$0.001" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/aqi-calc?pm25=35.4&pm10=80&o3=60");No wallet? Pay with compute
Fetch a challenge, solve the sha256 puzzle (16 leading zero bits, a fraction of a second of CPU), and resend with the X-Pow-Solution header:
import { createHash } from "node:crypto";
const lz = (b) => { let t = 0; for (const x of b) { if (!x) { t += 8; continue; } t += Math.clz32(x) - 24; break; } return t; };
const c = await (await fetch("https://agent402.tools/api/pow/challenge?slug=aqi-calc")).json();
let n = 0;
while (lz(createHash("sha256").update(c.challenge + ":" + n).digest()) < c.difficulty) n++;
await fetch("https://agent402.tools/api/aqi-calc?pm25=35.4&pm10=80&o3=60", { method: "GET", headers: { "X-Pow-Solution": c.token + ":" + n } });Related tools
Air quality (global)
Air quality index and current pollutant concentrations for any location: US AQI, PM2.5, PM10, ozone, NO2, SO2, CO.
Degree days calculator
Heating, cooling and growing degree days from a daily temperature series you supply: daily means, or min/max pairs (the.
Heat index and wind chill calculator
Heat index, wind chill, humidex, dew point and wet-bulb temperature from the temperature, humidity and wind you supply.
A2A Agent Card validate
Validate an A2A (Agent2Agent protocol) Agent Card: required fields, skill shape, transport names, capability flags.
Amortization schedule
Build the full per-period amortization schedule for a fully-amortizing loan.
Annuity present/future value
Present and future value of a level annuity (equal periodic payments).