Pagination

Paginating through a collection with JavaScript SDK is by far the easiest way. Limiting <Link to JS SDK limit function>; next page<Link to JS SDK getNextPage function> and previous<Link to JS SDK getPrevPage function> page and to checking if more pages<Link to JS SDK hasNextPage function> or previous<Link to JS SDK hasPrevPage function> pages exists can all be done.

However, requests are made when paginating directly by adding the page query variables page[size]=x, where x is a positive integer. It is also recommended that page[v]=2 is also passed to ensure you are using the most up-to-date pagination Datastore provides.

To make a pagination request using CURL:

curl \
    -X GET \
    -H "Content-Type: application/json" \
    --silent \
    -fS https://my-data-service.datastore.squiz.cloud/my-first-collection?page[size]=10&page[v]=2

The resulting paginated response looks like this:

{
    "data": [
        {
            "documentid": 1
        },
        {
            "documentid": 2
        },
        ...
        {
            "documentid": 10
        }
    ],
    "links": {
        "prev": null,
        "next": "/my-first-collection?page[size]=10&page[v]=2&page[after]=10"
    }
}

Pagination query parameters

[[%autowidth.stretch]]

Parameter Description

page[size]

The page size to be returned

page[v]

Pagination version to be used, default 1, recommended setting to 2 for enhanced pagination

page[after]

Token for the document to show pages after on subsequent requests. When null, there is no page after the current results

page[before]

Token for the document to show pages before on subsequent requests. When null, there is no page before the current results