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.
Filtering locations by parameter
Section titled “Filtering locations by parameter” 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.
Finding locations near a point
Section titled “Finding locations near a point” 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:
Finding locations in a bounding box
Section titled “Finding locations in a bounding box” 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:
Fetch original measurements for a sensor
Section titled “Fetch original measurements for a sensor” 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.
Fetch daily average values for a sensor
Section titled “Fetch daily average values for a sensor” 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” 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.
Get the latest PM2.5 values
Section titled “Get the latest PM2.5 values” 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.
Footnotes
Section titled “Footnotes”-
“original” indicates the original resolution as provided and ingested. ↩