Search
K

Pagination Guide

Pagination is a crucial aspect of efficiently navigating through large datasets using our API. This guide will help you understand how to utilise pagination effectively.

Query Parameters

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

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"
}

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:
The BASE_URL: https://api.airqo.net/api/{VERSION_NUMBER}

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:
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

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.