# Pagination Guide

## 1. **Query Parameters**

* **skip:** Specifies the number of records to skip. Default is 0.&#x20;
* **limit:** Defines the maximum number of records to return per page. Default is 1000.&#x20;
* **page:** Indicates the page number to retrieve.&#x20;
* **startTime:** Specifies the start time for data retrieval.&#x20;
* **endTime:** Defines the end time for data retrieval.

### **1.1 Example Response**

```
"meta": {
    "total": 22835,
    "skip": 0,
    "limit": 1000,
    "page": 1,
    "pages": 23,
    "startTime": "2023-11-14T20:00:45.061Z",
    "endTime": "2023-11-21T20:00:45.061Z"
}

```

## 2. Making Subsequent Requests

When making subsequent requests, it's crucial to align the values of query parameters (`page`, `startTime`, and `endTime`) with the information provided in the "`meta`" field of the API response. This ensures accurate navigation through the dataset. Here's how to interpret and utilise these values:

{% hint style="info" %}
**The BASE\_URL:** `https://api.airqo.net/api/{VERSION_NUMBER}`
{% endhint %}

### 2.1 Aligning Query Parameters

#### `- page`:

Use the `page` parameter to navigate through result pages. Increment the page number to retrieve the next set of records. Match the "page" value in the "`meta`" field for sequential navigation

**Example Request:**&#x20;

`GET: {BASE_URL}/rest-of-your-endpoint-path?page=2`

#### `- startTime` and `endTime:`

If the dataset spans multiple pages and time periods, make subsequent requests with updated startTime and endTime parameters based on the values provided in the "meta" field. Update these parameters based on the values from the "meta" field to narrow down the time range for each request.

**Example Request:**

`GET: {BASE_URL}/rest-of-your-endpoint-path?page=2&startTime=yourStartTime&endTime=yourEndTime`

### 2.2 Simplifying Requests

For user convenience, you can streamline requests by focusing on the `page` parameter alone. The API automatically manages `limit` and `skip` in the background, simplifying your queries.

**Example:**

`GET: {BASE_URL}/rest-of-your-endpoint-path?page=3`

By adhering to these guidelines, you can efficiently navigate the dataset without the need to manually handle `limit` and `skip`. In summary, you can efficiently retrieve large datasets while optimising system resources.  For additional assistance, refer to the [AirQo API Documentation](https://docs.airqo.net/airqo-rest-api-documentation/).&#x20;


---

# Agent Instructions: 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:

```
GET https://docs.airqo.net/airqo-rest-api-documentation/guidelines/pagination-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
