Skip to content

Pagination

Onur Akpolat edited this page Oct 18, 2016 · 1 revision

Requests that return multiple items will be paginated to 25 items by default.

Cursor-based Pagination

We offer a cursor-based pagination which is the most efficient method of paging. A cursor refers to a random string of characters which marks a specific item in a list of data.

Response

When reading an edge that supports cursor pagination, you will see the following JSON response:

{
  "paging": {
    "cursors": {
      "after": "NTM3ODc4YjdmMzhkNTZiYTZlMDVhNzE=",
      "before": "NTE3MTY3MDkzODc1OTk4NzU="
    },
    "previous": "https://api.tapglue.com/me/feed?limit=25&before=NTE3MTY3MDkzODc1OTk4NzU",
    "next": "https://api.tapglue.com/me/feed?limit=25&after=NTM3ODc4YjdmMzhkNTZiYTZlMDVhNzE="
  }
}

Parameters

A cursor-paginated edge supports the following parameters:

Parameter Description
before Specifies the ID which will be used as a pivot in order to get the items before it. The item matching the ID specified under before will not be returned in the response. This is mutually exclusive with after.
after Specifies the ID which will be used as a pivot in order to get the items after it. The item matching the ID specified under after will not be returned in the response. This is mutually exclusive with before.
limit The maximum number of collection items to return for a single request. Minimum value is 1. Default is 25.
next The API endpoint that will return the next page of data. If not included, this is the last page of data.
previous The API endpoint that will return the previous page of data.

Constraints

If both before and after are specified then the request will produce a 409 Conflict return code for the request.

If neither before and after are not specified then the request will return the latest items in the response, according to the limit parameter.

If limit parameter is not specified for a request then the default value will be used. Currently the default value is 25 but this value might change in the future. Clients should be advised to handle this situation on their end either by explicitly specifying the limit parameter or nor relying on the limit default value. In many cases requesting a certain number of items might not completely satisfiable due to lack of new data present in the system or a total number that's not perfectly divisible by the number specified by limit.

Clone this wiki locally