> For the complete documentation index, see [llms.txt](https://docs.airqo.net/airqo-rest-api-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.airqo.net/airqo-rest-api-documentation/api-endpoints/historical-measurements.md).

# Historical Measurements

Explore the diverse endpoints tailored to your historical data needs:

## 1. Get Historical Measurements by Site ID

<mark style="color:blue;">`GET`</mark> `https://api.airqo.net/api/v2/devices/measurements/sites/{SITE_ID}/historical`

Retrieve measurements for a specific site by providing the site ID

#### Path Parameters

| Name                                      | Type   | Description           |
| ----------------------------------------- | ------ | --------------------- |
| Site ID<mark style="color:red;">\*</mark> | string | This is the Site's ID |

#### Query Parameters

| Name                                    | Type   | Description                                                                                                                                           |
| --------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| startTime                               | string | The date in this format: YYYY-MM-DD or the UTC time format in case you would like to access data at specific times, eg: 2021-05-24T12:45:24.000Z      |
| endTime                                 | string | The date in this format: YYYY-MM-DD. or the UTC time format in case you would like to access data at specific times, example: 2021-05-24T12:45:24.000 |
| token<mark style="color:red;">\*</mark> | string | the security token                                                                                                                                    |

{% tabs %}
{% tab title="200 " %}

```
{
    "success": true,
    "isCache": false,
    "message": "successfully returned the measurements",
    "meta": {
        "total": 38,
        "skip": 0,
        "limit": 1000,
        "page": 1,
        "pages": 1
    },
    "measurements": [
        {
      "device": "aq_##",
      "device_id": "5f2036bc70223655545#####",
      "is_reading_primary": false,
      "health_tips": [
        {
          "_id": "64283ce9e82a77001e5#####",
          "title": "For Everyone",
          "description": "Today is a great day for outdoor activity.",
          "image": "https://firebasestorage.googleapis.com/v0/b/airqo-#####"
        },
        {
          "_id": "64283d37b2e9e5001e#####",
          "title": "For pregnant women",
          "description": "Reduce the intensity of your outdoor activities to keep you and your baby healthy.",
          "image": "https://firebasestorage.googleapis.com/#####"
        },
        {
          "_id": "64283d749c7eaf001e#####",
          "title": "For elderly people",
          "description": "Reduce the intensity of your outdoor activities.",
          "image": "https://firebasestorage.googleapis.com/v0/b/#####"
        }
      ],
      "site_id": "60d058c8048305120d#####",
      "time": "2024-05-30T13:00:00.000Z",
      "pm2_5": {
        "value": 20.9907
      },
      "pm10": {
        "value": 24.5982934194934
      },
      "frequency": "hourly",
      "no2": {

      },
      "siteDetails": {
        "_id": "60d058c8048305120d2#####",
        "description": "Nakasero II, Kampala",
        "country": "Uganda",
        "district": "Kampala",
        "sub_county": "Central",
        "parish": "Nakasero ii",
        "county": "Kampala",
        "name": "Nakasero II, Kampala",
        "city": "Kampala",
        "formatted_name": "31 Buganda Rd, Kampala, Uganda",
        "region": "Central Region",
        "street": "Buganda Road",
        "town": "Kampala",
        "village": "Kampala Central Division",
        "search_name": "Nakasero II",
        "location_name": "Kampala, Uganda",
        "approximate_latitude": 0.320055590723009,
        "approximate_longitude": 32.5718209000665,
        "data_provider": "AirQo"
      },
      "timeDifferenceHours": 1.49036444444444,
      "aqi_color": "ffff00",
      "aqi_category": "Moderate",
      "aqi_color_name": "Yellow"
    },
    {measurement object two},
    {measurement object three}
    ]
```

{% endtab %}

{% tab title="401: Unauthorized In case of bad requests" %}

```
{"success":false, "message":"Invalid authentication", "error":"Unauthorized."}
```

{% endtab %}
{% endtabs %}

## 2. Get Historical measurements by Device ID

<mark style="color:blue;">`GET`</mark> `https://api.airqo.net/api/v2/devices/measurements/devices/{DEVICE_ID}/historical`

Retrieve historical measurements for a specific device by providing the device ID.

#### Path Parameters

| Name                                        | Type   | Description             |
| ------------------------------------------- | ------ | ----------------------- |
| Device ID<mark style="color:red;">\*</mark> | string | This is the Device's ID |

#### Query Parameters

| Name                                    | Type   | Description                                                                                                                                           |
| --------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| token<mark style="color:red;">\*</mark> | String | the token for your clients                                                                                                                            |
| startTime                               | String | The date in this format: YYYY-MM-DD or the UTC time format in case you would like to access data at specific times, eg: 2021-05-24T12:45:24.000Z      |
| endTime                                 | String | The date in this format: YYYY-MM-DD. or the UTC time format in case you would like to access data at specific times, example: 2021-05-24T12:45:24.000 |

{% tabs %}
{% tab title="200 " %}

```
{
    "success": true,
    "isCache": false,
    "message": "successfully returned the measurements",
    "meta": {
        "total": 38,
        "skip": 0,
        "limit": 1000,
        "page": 1,
        "pages": 1
    },
    "measurements": [
        {
      "device": "aq_##",
      "device_id": "5f2036bc70223655545#####",
      "is_reading_primary": false,
      "health_tips": [
        {
          "_id": "64283ce9e82a77001e5#####",
          "title": "For Everyone",
          "description": "Today is a great day for outdoor activity.",
          "image": "https://firebasestorage.googleapis.com/v0/b/airqo-#####"
        },
        {
          "_id": "64283d37b2e9e5001e#####",
          "title": "For pregnant women",
          "description": "Reduce the intensity of your outdoor activities to keep you and your baby healthy.",
          "image": "https://firebasestorage.googleapis.com/#####"
        },
        {
          "_id": "64283d749c7eaf001e#####",
          "title": "For elderly people",
          "description": "Reduce the intensity of your outdoor activities.",
          "image": "https://firebasestorage.googleapis.com/v0/b/#####"
        }
      ],
      "site_id": "60d058c8048305120d#####",
      "time": "2024-05-30T13:00:00.000Z",
      "pm2_5": {
        "value": 20.9907
      },
      "pm10": {
        "value": 24.5982934194934
      },
      "frequency": "hourly",
      "no2": {

      },
      "siteDetails": {
        "_id": "60d058c8048305120d2#####",
        "description": "Nakasero II, Kampala",
        "country": "Uganda",
        "district": "Kampala",
        "sub_county": "Central",
        "parish": "Nakasero ii",
        "county": "Kampala",
        "name": "Nakasero II, Kampala",
        "city": "Kampala",
        "formatted_name": "31 Buganda Rd, Kampala, Uganda",
        "region": "Central Region",
        "street": "Buganda Road",
        "town": "Kampala",
        "village": "Kampala Central Division",
        "search_name": "Nakasero II",
        "location_name": "Kampala, Uganda",
        "approximate_latitude": 0.320055590723009,
        "approximate_longitude": 32.5718209000665,
        "data_provider": "AirQo"
      },
      "timeDifferenceHours": 1.49036444444444,
      "aqi_color": "ffff00",
      "aqi_category": "Moderate",
      "aqi_color_name": "Yellow"
    },
    {measurement object two},
    {measurement object three}
    ]
```

{% endtab %}

{% tab title="401: Unauthorized This is when a user provides an incorrect username or password." %}

```
{"success":false, "message":"Invalid authentication", "error":"Unauthorized."}
```

{% endtab %}
{% endtabs %}

## 3. Get Historical Measurements by Grid ID

<mark style="color:blue;">`GET`</mark> `https://api.airqo.net/api/v2/devices/measurements/grids/{GRID_ID}/historical`

Retrieve historical measurements for a specific Grid by providing the Grid ID

#### Path Parameters

| Name                                      | Type   | Description         |
| ----------------------------------------- | ------ | ------------------- |
| Grid ID<mark style="color:red;">\*</mark> | string | This is the Grid ID |

#### Query Parameters

| Name                                    | Type   | Description                                                                                                                                           |
| --------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| startTime                               | string | The date in this format: YYYY-MM-DD or the UTC time format in case you would like to access data at specific times, eg: 2021-05-24T12:45:24.000Z      |
| endTime                                 | string | The date in this format: YYYY-MM-DD. or the UTC time format in case you would like to access data at specific times, example: 2021-05-24T12:45:24.000 |
| token<mark style="color:red;">\*</mark> | string | the security token                                                                                                                                    |

{% tabs %}
{% tab title="200 " %}

```
{
    "success": true,
    "isCache": false,
    "message": "successfully returned the measurements",
    "meta": {
        "total": 38,
        "skip": 0,
        "limit": 1000,
        "page": 1,
        "pages": 1
    },
    "measurements": [
        {
      "device": "aq_##",
      "device_id": "5f2036bc70223655545#####",
      "is_reading_primary": false,
      "health_tips": [
        {
          "_id": "64283ce9e82a77001e5#####",
          "title": "For Everyone",
          "description": "Today is a great day for outdoor activity.",
          "image": "https://firebasestorage.googleapis.com/v0/b/airqo-#####"
        },
        {
          "_id": "64283d37b2e9e5001e#####",
          "title": "For pregnant women",
          "description": "Reduce the intensity of your outdoor activities to keep you and your baby healthy.",
          "image": "https://firebasestorage.googleapis.com/#####"
        },
        {
          "_id": "64283d749c7eaf001e#####",
          "title": "For elderly people",
          "description": "Reduce the intensity of your outdoor activities.",
          "image": "https://firebasestorage.googleapis.com/v0/b/#####"
        }
      ],
      "site_id": "60d058c8048305120d#####",
      "time": "2024-05-30T13:00:00.000Z",
      "pm2_5": {
        "value": 20.9907
      },
      "pm10": {
        "value": 24.5982934194934
      },
      "frequency": "hourly",
      "no2": {

      },
      "siteDetails": {
        "_id": "60d058c8048305120d2#####",
        "description": "Nakasero II, Kampala",
        "country": "Uganda",
        "district": "Kampala",
        "sub_county": "Central",
        "parish": "Nakasero ii",
        "county": "Kampala",
        "name": "Nakasero II, Kampala",
        "city": "Kampala",
        "formatted_name": "31 Buganda Rd, Kampala, Uganda",
        "region": "Central Region",
        "street": "Buganda Road",
        "town": "Kampala",
        "village": "Kampala Central Division",
        "search_name": "Nakasero II",
        "location_name": "Kampala, Uganda",
        "approximate_latitude": 0.320055590723009,
        "approximate_longitude": 32.5718209000665,
        "data_provider": "AirQo"
      },
      "timeDifferenceHours": 1.49036444444444,
      "aqi_color": "ffff00",
      "aqi_category": "Moderate",
      "aqi_color_name": "Yellow"
    },
    {measurement object two},
    {measurement object three}
    ]
```

{% endtab %}

{% tab title="401: Unauthorized In case of bad requests" %}

```
{"success":false, "message":"Invalid authentication", "error":"Unauthorized."}
```

{% endtab %}
{% endtabs %}

## 4. Get Historical Measurements by Cohort ID

<mark style="color:blue;">`GET`</mark> `https://api.airqo.net/api/v2/devices/measurements/cohorts/{COHORT_ID}/historical`

Retrieve historical measurements for a specific Cohort by providing the Cohort ID

#### Path Parameters

| Name                                        | Type   | Description           |
| ------------------------------------------- | ------ | --------------------- |
| Cohort ID<mark style="color:red;">\*</mark> | string | This is the Cohort ID |

#### Query Parameters

| Name                                    | Type   | Description                                                                                                                                           |
| --------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| startTime                               | string | The date in this format: YYYY-MM-DD or the UTC time format in case you would like to access data at specific times, eg: 2021-05-24T12:45:24.000Z      |
| endTime                                 | string | The date in this format: YYYY-MM-DD. or the UTC time format in case you would like to access data at specific times, example: 2021-05-24T12:45:24.000 |
| token<mark style="color:red;">\*</mark> | string | the security token                                                                                                                                    |

{% tabs %}
{% tab title="200 " %}

```
{
    "success": true,
    "isCache": false,
    "message": "successfully returned the measurements",
    "meta": {
        "total": 38,
        "skip": 0,
        "limit": 1000,
        "page": 1,
        "pages": 1
    },
    "measurements": [
        {
      "device": "aq_##",
      "device_id": "5f2036bc70223655545#####",
      "is_reading_primary": false,
      "health_tips": [
        {
          "_id": "64283ce9e82a77001e5#####",
          "title": "For Everyone",
          "description": "Today is a great day for outdoor activity.",
          "image": "https://firebasestorage.googleapis.com/v0/b/airqo-#####"
        },
        {
          "_id": "64283d37b2e9e5001e#####",
          "title": "For pregnant women",
          "description": "Reduce the intensity of your outdoor activities to keep you and your baby healthy.",
          "image": "https://firebasestorage.googleapis.com/#####"
        },
        {
          "_id": "64283d749c7eaf001e#####",
          "title": "For elderly people",
          "description": "Reduce the intensity of your outdoor activities.",
          "image": "https://firebasestorage.googleapis.com/v0/b/#####"
        }
      ],
      "site_id": "60d058c8048305120d#####",
      "time": "2024-05-30T13:00:00.000Z",
      "pm2_5": {
        "value": 20.9907
      },
      "pm10": {
        "value": 24.5982934194934
      },
      "frequency": "hourly",
      "no2": {

      },
      "siteDetails": {
        "_id": "60d058c8048305120d2#####",
        "description": "Nakasero II, Kampala",
        "country": "Uganda",
        "district": "Kampala",
        "sub_county": "Central",
        "parish": "Nakasero ii",
        "county": "Kampala",
        "name": "Nakasero II, Kampala",
        "city": "Kampala",
        "formatted_name": "31 Buganda Rd, Kampala, Uganda",
        "region": "Central Region",
        "street": "Buganda Road",
        "town": "Kampala",
        "village": "Kampala Central Division",
        "search_name": "Nakasero II",
        "location_name": "Kampala, Uganda",
        "approximate_latitude": 0.320055590723009,
        "approximate_longitude": 32.5718209000665,
        "data_provider": "AirQo"
      },
      "timeDifferenceHours": 1.49036444444444,
      "aqi_color": "ffff00",
      "aqi_category": "Moderate",
      "aqi_color_name": "Yellow"
    },
    {measurement object two},
    {measurement object three}
    ]
```

{% endtab %}

{% tab title="401: Unauthorized In case of bad requests" %}

```
{"success":false, "message":"Invalid authentication", "error":"Unauthorized."}
```

{% endtab %}
{% endtabs %}

## Usage Instructions

Follow the guidelines in each section to craft your API requests based on the entity ID of interest. Our API is designed to provide you with accurate historical air quality measurements, ensuring a seamless experience as you explore past data trends.

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.airqo.net/airqo-rest-api-documentation/api-endpoints/historical-measurements.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
