Pagination

Some resources support GET methods to retrieve a list of resources. The response may be returned in one or more pages depending on the number of objects to be returned. For some resources, you can use the limit and offset parameters to control the response pagination.

Parameters

Parameter

Description

Default

limit

A limit on the length of the page. You can set the maximum number of objects to be returned per page between 1 and 1000.

100

offset

A cursor for use in pagination. The response will skip the number of matching objects (or rows) specified using the offset parameter and return the page of objects starting with the next object (or row) in the list. The offset must be a positive number divisible by the page limit.

0

Response

A paginated response includes the meta property in the JSON-encoded object returned. For a paginated response, the meta property has the following attributes:

Property

Description

rowsPerPage

The number of objects (or rows) per page.

totalPages

The total number of pages in the list.

totalRows

The total number of objects (or rows) in the list.

links

An array of objects containing direct links to other pages and their relation to the page returned:

  • first — the URL for the first page. Not included if the page returned is the first page.

  • prev — the URL for the previous page. Not included if the page returned is the first page.

  • self — the URL for the current page (the page requested).

  • next — the URL for the next page. Not included if the page returned is the last page.

  • last — the URL for the last page. Not included if the page returned is the last page.

Example

The following example skips the first 90 objects and returns a page of 10 objects starting from the 91th object in the list of results.

            GET /rest/v1/receipts?limit=10&offset=90 HTTP/1.1 

          

The response includes the meta attribute with information about the page ( rowsPerPage — the number of objects per page), the list (totalPages and totalRows — the total number of pages and objects in the list, respectively), and direct links to the first, previous, next and last page, as well as the requested page.

            {
   "message" : "success",
   "data" : [
      {...}
   ],
   "meta" : { "rowsPerPage": 10,
      "totalPages": 85,
      "totalRows": 841,
      "links": [
         {
            "rel": "first",
            "href": "https://company-id.app.openair.com/rest/v1/receipts?limit=10"
         },
         {
            "rel": "prev",
            "href": "https://company-id.app.openair.com/rest/v1/receipts?limit=10&offset=80"
         },
         {
            "rel": "self",
            "href": "https://company-id.app.openair.com/rest/v1/receipts?limit=10&offset=90"
         },
         {
            "rel": "next",
            "href": "https://company-id.app.openair.com/rest/v1/receipts?limit=10&offset=20"
         },
         {
            "rel": "last",
            "href": "https://company-id.app.openair.com/rest/v1/receipts?limit=10&offset=840"
         }
      ]
   }
}