Pagination

Learn how to leverage pagination in list endpoints.

The Core API provides support to fetch your data in bulk on list endpoints. When using these endpoints, 10 objects per page will be returned by default.

It is possible to change this default behavior by instructing the API to return up to a maximum of 100 objects per page. You can do this be using the limit attribute as a query parameter, as such:

https://www.pelcro.com/api/v1/core/addresses?limit=100

For your convenience, all list endpoints will always return special pagination attributes, which you can leverage in your own code to implement logic such as iterating through all pages of a result set.

The links attribute

This attribute will always return a reference to the first and last pages of the result set. If the result set contains more objects, the next attribute will be populate with the URL of the next page to fetch.

{
    // ...
    "links": {
        "first": "https://www.pelcro.com/api/v1/core/addresses?page=1",
        "last": "https://www.pelcro.com/api/v1/core/addresses?page=2",
        "prev": null,
        "next": "https://www.pelcro.com/api/v1/core/addresses?page=2"
    },
    // ...
}

The meta attribute

This attribute contains various information such as the current page, the total number of pages, the number of objects per page and the total number of objects in the result set.

{
    // ...
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 2,
        "links": [
            {
                "url": null,
                "label": "« Previous",
                "active": false
            },
            {
                "url": "https://www.pelcro.com/api/v1/core/addresses?page=1",
                "label": "1",
                "active": true
            },
            {
                "url": "https://www.pelcro.com/api/v1/core/addresses?page=2",
                "label": "2",
                "active": false
            },
            {
                "url": "https://www.pelcro.com/api/v1/core/addresses?page=2",
                "label": "Next »",
                "active": false
            }
        ],
        "path": "https://www.pelcro.com/api/v1/core/addresses",
        "per_page": 10,
        "to": 10,
        "total": 20
    }
}