Skip to content

Explanation

If you check all the sections in which we have used pagination, in all the responses, you will find that there are three objects key i.e. data, links, and meta. In this section, we will explain all the three keys.

Let's take an example of the categories section, we have some response in which we got these three keys.

json
{
    "data": [{...},{...},...,{...}],
    "links": {...},
    "meta": {...}
}

1. Data Object data

In the data object key, you will find the collection of many objects which represent the UnoPim store's categories.

In the links object, you will find four more object keys, which will be used according to pagination,

json
"links": {
    "first": "https://example.com/api/categories?limit=5&pagination=342234&page=1",
    "last": "https://example.com/api/categories?limit=5&pagination=342234&page=2",
    "prev": null,
    "next": "https://example.com/api/categories?limit=5&pagination=342234&page=2"
}
NameInfo
firstDisplay the first url link of the called API with filter variable.
lastDisplay the last url link of the called API with filter variable.
prevDisplay the previous url of the current called API url.
nextDisplay the next url of the current called API url. If no next url available then it will contain the null value.

3. Meta Object meta

meta object will only used with pagination. Under meta object, you will find seven object keys,

json
"meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 2,
    "path": "https://example.com/api/categories",
    "per_page": "5",
    "to": 5,
    "total": 10
}
NameInfo
current_pageDisplay the current page number.
fromDisplay the first count of the returned data object based on the provided page and limit filters.
last_pageDisplay the last page number.
pathDisplay the current api url without input parameters.
per_pageDisplay the total of records in a single page.
toDisplay the last count of the returned data object based on the provided page and limit filters.
totalDisplay the total number of records in the store.

Released under the MIT License.