Skip to content

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.

  1. Run curl --version in the command line to see if curl exists on your machine. If version details show, curl exists. If you see command not found: curl, download and install it. For more details, visit the curl download page at https://curl.se/download.html.

  2. 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.

  3. Run the following curl command, including your API key in the X-API-Key header. Replace YOUR-OPENAQ-API-KEY with your API key (placeholder value will not work).

    Terminal window
    curl --request GET \
    --url "https://api.openaq.org/v3/locations/8118" \
    --header "X-API-Key: YOUR-OPENAQ-API-KEY"
  4. The JSON response will give you the data for location 8118. You have now used the OpenAQ API successfully.