OpenAQ API
api.openaq.org · Science
Real-time and historical air quality data from 30,000+ monitoring stations in 100+ countries. PM2.5, PM10, ozone, NO2, CO, SO2 measurements. Free, no API key.
Authentication
No authentication requiredFree to use with no key needed.
Sample Requests
GET
Get locations
Get recently updated air quality stations in the US.
https://api.openaq.org/v3/locations?sort=desc&limit=5&order_by=lastUpdated&country_id=13
Hover any highlighted part to learn what it does
curl -X GET "https://api.openaq.org/v3/locations?sort=desc&limit=5&order_by=lastUpdated&country_id=13"
import requests
params = {
"sort": "desc",
"limit": "5",
"order_by": "lastUpdated",
"country_id": "13"
}
response = requests.get(
"https://api.openaq.org/v3/locations",
params=params,
)
print(response.json())const url = new URL('https://api.openaq.org/v3/locations');
url.searchParams.set('sort', 'desc');
url.searchParams.set('limit', '5');
url.searchParams.set('order_by', 'lastUpdated');
url.searchParams.set('country_id', '13');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.openaq.org/v3/locations")
q := baseURL.Query()
q.Set("sort", "desc")
q.Set("limit", "5")
q.Set("order_by", "lastUpdated")
q.Set("country_id", "13")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.openaq.org/v3/locations")
uri.query = URI.encode_www_form({
"sort" => "desc",
"limit" => "5",
"order_by" => "lastUpdated",
"country_id" => "13"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.openaq.org/v3/locations?" . http_build_query([
"sort" => "desc",
"limit" => "5",
"order_by" => "lastUpdated",
"country_id" => "13"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
GET
Get measurements
Get PM2.5 measurements for a station.
https://api.openaq.org/v3/measurements?limit=10&location_id=1¶meter_id=2
Hover any highlighted part to learn what it does
curl -X GET "https://api.openaq.org/v3/measurements?limit=10&location_id=1¶meter_id=2"
import requests
params = {
"limit": "10",
"location_id": "1",
"parameter_id": "2"
}
response = requests.get(
"https://api.openaq.org/v3/measurements",
params=params,
)
print(response.json())const url = new URL('https://api.openaq.org/v3/measurements');
url.searchParams.set('limit', '10');
url.searchParams.set('location_id', '1');
url.searchParams.set('parameter_id', '2');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.openaq.org/v3/measurements")
q := baseURL.Query()
q.Set("limit", "10")
q.Set("location_id", "1")
q.Set("parameter_id", "2")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.openaq.org/v3/measurements")
uri.query = URI.encode_www_form({
"limit" => "10",
"location_id" => "1",
"parameter_id" => "2"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.openaq.org/v3/measurements?" . http_build_query([
"limit" => "10",
"location_id" => "1",
"parameter_id" => "2"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- No API key needed
- Countries: GET /v3/countries
- Locations in country: GET /v3/locations?country_id=13&limit=10 (13=US)
- Parameter IDs: 1=PM1, 2=PM2.5, 3=PM10, 4=NO2, 5=CO, 6=SO2, 7=O3
- Measurements: GET /v3/measurements?location_id=ID¶meter_id=2&limit=10