Skip to content

Examples

This page provides examples of common queries and how to use the OpenAQ API to address them. For more complex solutions we recommend using one of the official API clients or SDKs, see Libraries for more information.

Terminal window
curl --request GET \
--url "https://api.openaq.org/v3/locations?parameters_id=2&limit=1000" \
--header "X-API-Key: YOUR-OPENAQ-API-KEY"

Where parameters_id 2 is the ID for PM2.5 and limits the number results to 1,000 per page.

Terminal window
curl --request GET \
--url "https://api.openaq.org/v3/locations?coordinates=136.90610,35.14942&radius=12000&limit=1000" \
--header "X-API-Key: YOUR-OPENAQ-API-KEY"

Where 136.90610,35.14942 is the central point in latitude,longitude and the radius is 12,000 meters (12km) and limits the number results to 1,000 per page. See the Geospatial queries guide for more information on geospatial querying. This radius query represents an area like:

Terminal window
curl --request GET \
--url "https://api.openaq.org/v3/locations?bbox=-118.668153,33.703935,-118.155358,34.337306&limit=1000" \
--header "X-API-Key: YOUR-OPENAQ-API-KEY"

Where -118.668153,33.703935,-118.155358,34.337306 is the bounding box within which to search and limits the number results to 1,000 per page. See the Geospatial queries guide for more information on geospatial querying. This bounding box represents an area like the following:

Terminal window
curl --request GET \
--url "https://api.openaq.org/v3/sensors/3917/measurements?limit=1000" \
--header "X-API-Key: YOUR-OPENAQ-API-KEY"

This fetches the original1 measurement values for sensor 3917, an Ozone sensor and limits the number results to 1,000 per page.

Terminal window
curl --request GET \
--url "https://api.openaq.org/v3/sensors/3917/days?limit=1000" \
--header "X-API-Key: YOUR-OPENAQ-API-KEY"

This fetches the daily average (mean) values, computed from the original measurement values for sensor 3917, an Ozone sensor, and limits the number results to 1,000 per page.

Fetch yearly average values, computed from daily averages for a sensor

Section titled “Fetch yearly average values, computed from daily averages for a sensor”
Terminal window
curl --request GET \
--url "https://api.openaq.org/v3/sensors/3917/days/yearly?limit=1000" \
--header "X-API-Key: YOUR-OPENAQ-API-KEY"

This fetches the yearly average (mean) values, computed from the daily average values for sensor 3917, an Ozone sensor, and limits the number results to 1,000 per page.

Terminal window
curl --request GET \
--url "https://api.openaq.org/v3/parameters/2/latest?limit=1000" \
--header "X-API-Key: YOUR-OPENAQ-API-KEY"

This fetches the latest PM2.5 (parameter ID 2) for all sensors across the OpenAQ dataset and limits the number results to 1,000 per page.

  1. “original” indicates the original resolution as provided and ingested.