Paginating collections

Pagination allows you to display a large number of records in a more manageable way. To enable pagination, you need to define two parameters in your query: Limit and Skip. By defining these parameters, you can break down a large dataset into smaller parts that can be displayed on separate pages. Please find more details below.

{
  Posts ( limit : 15, skip: 0 ) {
        items {
            _id,
            title
        },
        total
    }
}

In the above example, a client retrieves content items by repeating the same request, changing the skip query parameter as follows:

Page 1: skip=0, limit=15
Page 2: skip=15, limit=15
Page 3: skip=30, limit=15
etc.

Limit

The Limit parameter sets a maximum number of results to return per query. It breaks down the entire results into portions. By default, API returns 10 items per call.

Note

The Limit value should be an integer and defined within a range from 0 to 100. If a value is set to higher than 100, the API will return 100 items.

Skip

The Skip parameter sets an offset, i.e., how many items to omit before returning the results.

Returned data

The data returned from a collection contains the meta-data field total and the requested items in the items field. The total field contains the total number of content items in that collection.

Please note, adding the total field requires processing costs, and in large datasets this can slow down the query significantly.

Tip

When paging through larger result sets, you can use the sort argument to maintain a predictable order. For example, using sort=-created_on will order results by the time the resource was created. Read more in Sorting collections.