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 looks something like the following:

    {
    "meta": {
    "name": "openaq-api",
    "website": "/",
    "page": 1,
    "limit": 100,
    "found": 1
    },
    "results": [
    {
    "id": 8118,
    "name": "New Delhi",
    "locality": "India",
    "timezone": "Asia/Kolkata",
    "country": { "id": 9, "code": "IN", "name": "India" },
    "owner": { "id": 4, "name": "Unknown Governmental Organization" },
    "provider": { "id": 119, "name": "AirNow" },
    "isMobile": false,
    "isMonitor": true,
    "instruments": [{ "id": 2, "name": "Government Monitor" }],
    "sensors": [
    {
    "id": 23534,
    "name": "pm25 µg/m³",
    "parameter": {
    "id": 2,
    "name": "pm25",
    "units": "µg/m³",
    "displayName": "PM2.5"
    }
    }
    ],
    "coordinates": { "latitude": 28.63576, "longitude": 77.22445 },
    "licenses": [
    {
    "id": 33,
    "name": "US Public Domain",
    "attribution": {
    "name": "Unknown Governmental Organization",
    "url": null
    },
    "dateFrom": "2016-01-30",
    "dateTo": null
    }
    ],
    "bounds": [77.22445, 28.63576, 77.22445, 28.63576],
    "distance": null,
    "datetimeFirst": {
    "utc": "2016-11-09T19:00:00Z",
    "local": "2016-11-10T00:30:00+05:30"
    },
    "datetimeLast": {
    "utc": "2024-12-13T14:30:00Z",
    "local": "2024-12-13T20:00:00+05:30"
    }
    }
    ]
    }