Skip to content

# Air Quality API

GET/v1/sensordata/air/{station_id}

Latest readings at one OpenAQ monitor (station_id openaq_{location_id}) with the US EPA AQI. An id that is not tracked returns status pending with known false; find ids with /stations/near. Refreshes every 60 minutes.

Price

$0.005/ call

Edge cache

1800s

Uptime 24h

100.00%

p95

224ms

MCP tool

sensordata_air-station-id

The Air Quality API provides the latest readings at one OpenAQ monitor with the US EPA AQI. The API endpoint is /air/{station_id} and it refreshes every 60 minutes. The API returns the latest readings at a specified monitor station id. The station_id is required and should be in the format openaq_{location_id}. If the station_id is not tracked, the API returns a status pending with known false. You can find available station ids using the /stations/near endpoint. The price of this API is $0.005 per request.

Parameters

NameInTypeDescription
station_id* path string

Code

curl
# 1. No key, no payment: the gateway answers 402 with the price
curl -i "https://api.realtimeapi.ai/v1/sensordata/air/openaq_2178"

# 2. Pay: retry with a signed x402 payment (any x402 client builds this header)
curl "https://api.realtimeapi.ai/v1/sensordata/air/openaq_2178" -H "PAYMENT-SIGNATURE: $X402_PAYMENT"
TypeScript · @x402/fetch
// npm i @x402/fetch @x402/core @x402/evm viem
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = x402Client.fromConfig({ schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(privateKeyToAccount(PRIVATE_KEY)) }] });
const pay = wrapFetchWithPayment(fetch, client);
const data = await (await pay("https://api.realtimeapi.ai/v1/sensordata/air/openaq_2178")).json();
console.log(data);
Python · x402
# pip install "x402[requests,evm]==2.27.0" eth-account
from eth_account import Account
from x402 import x402ClientSync
from x402.http.clients import x402_requests
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact import register_exact_evm_client

client = x402ClientSync()
register_exact_evm_client(client, EthAccountSigner(Account.from_key(PRIVATE_KEY)))
session = x402_requests(client)
print(session.get("https://api.realtimeapi.ai/v1/sensordata/air/openaq_2178").json())
With an API key
curl "https://api.realtimeapi.ai/v1/sensordata/air/openaq_2178" -H "X-API-Key: $RTAPI_KEY"

Frequently asked questions

What is the API endpoint?

/air/{station_id}

What is the price of the API?

$0.005 per request

How often does the API refresh?

Every 60 minutes

Get a free key

1,000 calls a month across every feed. Who is setting it up?

No key needed at all: agents can pay per call in USDC with x402.