Quick start
This guide shows how to fetch data from the OpenAQ API. As an example, we will retrieve location details for the “New Delhi” station in New Delhi, India, with OpenAQ location ID 8118.
This tutorial uses curl to make HTTP requests and assumes you are familiar with using the command line on your computer.
-
Run
curl --version
in the command line to see if curl exists on your machine. If version details show, curl exists. If you seecommand not found: curl
, download and install it. For more details, visit the curl download page at https://curl.se/download.html. -
Sign up for an OpenAQ API key at https://explore.openaq.org. After signing up, find your API key in your settings. Use this key to authenticate requests.
-
Run the following
curl
command, including your API key in theX-API-Key
header. ReplaceYOUR-OPENAQ-API-KEY
with your API key (placeholder value will not work). -
The JSON response will give you the data for location 8118. You have now used the OpenAQ API successfully.