iglooX DocsDevelopers

Guide

Pagination

Paginated endpoints return a limited set of results at a time. Use the pagination parameters to retrieve the remaining results.

The iglooX API supports "page based" and "cursor based" pagination.

Page Based

The initial request to a paginated endpoint is the same as any other - no specific parameters are required. The client can optionally request a specific number of results via the per_page parameter. If per_page is not supplied a default value generally-suitable for the endpoint's use-case will be used.

Below is an example of a paginated response.

GET /some-paginated-endpoint?per_page=2

{
  "data": [
    {
      "uuid": "d7d54e6d-6c9e-4518-af2c-a4dedbe03b1d",
      "name": "User A"
    },
    {
      "uuid": "eb6b1840-a577-4594-b401-5d061a224a2d",
      "name": "User B"
    }
  ],
  "meta": {
    "current_page": 1,
    "last_page": 10,
    "first_item_on_current_page": 1,
    "last_item_on_current_page": 2,
    "per_page": 2,
    "total_results": 19
  }
}

In the above example two results have been returned in the data property and various page-related information is returned in meta.

Below is an example of a paginated response when a page and per_page is supplied.

GET /some-paginated-endpoint?page=10&per_page=2

{
  "data": [
    {
      "uuid": "98afa7b4-e55a-452a-8976-966c2464b640",
      "name": "User C"
    }
  ],
  "meta": {
    "current_page": 10,
    "last_page": 10,
    "first_item_on_current_page": 19,
    "last_item_on_current_page": 19,
    "per_page": 2,
    "total_results": 19
  }
}

Explanation of meta properties

Property Description
meta.current_page The current page number (will match page in the request if it is supplied)
meta.last_page The last available page of results
meta.first_item_on_current_page The position of the first result in the current page relative to the total number of possible results
meta.last_item_on_current_page The position of the last result in the current page relative to the total number of possible results
meta.per_page The number of results that will be returned per page (will match per_page in the request if it is supplied)
meta.total_results The total number of results across all pages

Cursor Based

The initial request to a paginated endpoint is the same as any other - no specific parameters are required. The client can optionally request a specific number of results via the cursor_limit parameter. If cursor_limit is not supplied a default value generally-suitable for the endpoint's use-case will be used.

Below is an example of a paginated response.

GET /some-paginated-endpoint?cursor_limit=2

{
  "data": [
    {
      "uuid": "d7d54e6d-6c9e-4518-af2c-a4dedbe03b1d",
      "name": "User A"
    },
    {
      "uuid": "eb6b1840-a577-4594-b401-5d061a224a2d",
      "name": "User B"
    }
  ],
  "meta": {
    "next_cursor": "eyJ1dWlkIjoiOThhZmE3YjQtZTU1YS00NTJhLTg5NzYtOTY2YzI0NjRiNjQwIn0"
  }
}

The response contains two records in data. A non-null meta.next_cursor means more results are available. To retrieve the next page, repeat the request with cursor set to that value. Treat the cursor as an opaque string: pass it back unchanged rather than constructing or interpreting it.

Below is an example of a paginated response when a cursor is supplied.

GET /some-paginated-endpoint?cursor_limit=2&cursor=eyJ1dWlkIjoiOThhZmE3YjQtZTU1YS00NTJhLTg5NzYtOTY2YzI0NjRiNjQwIn0

{
  "data": [
    {
      "uuid": "98afa7b4-e55a-452a-8976-966c2464b640",
      "name": "User C"
    }
  ],
  "meta": {
    "next_cursor": null
  }
}

In the above example, one record was retrieved (even though 2 records were requested, only one record exists). meta.next_cursor is now set to null, indicating that there are no further records to retrieve.

Search documentation

Search across this documentation site.