• Version: 1.2.0

Pagination

Several product-related endpoints allow you to paginate results. This involves limiting the number of results returned and increasing the offset of the results array for each page. The following endpoints allow pagination:

When these endpoints or their search extensions return an array of objects, they include a pagination object. This object has the following fields:

Key Type Unique Details
total Integer No The total number of items that could be returned.
current Integer No The number of items returned as part of this call.
limit Integer No The maximum number of items allowed to be returned in this call. Set using the limit data field with the selected endpoint. Limit can be set from 1 to 100.
offset Integer No The position in the total list of items of the first item in the returned array.
from Integer No The ordinal number in the total list of items of the first item in this array.
to Integer No The ordinal number in the total list of items of the last item in this array.
offsets Multiple/Integer No Contains the offset numbers for the first, previous, next, and last items in the entire list, not just the returned array.
links Multiple No Contains endpoint calls that would return the first, previous, next, and last items in the entire list. For example, “http://api.molt.in/v1/products?offset=15&limit=15&order=id&sort=desc”.

The data fields above cannot be set directly, though you can pass some of these data fields to the acceptable endpoints, as shown below.

Paginate and Limit Results

If you want to otherwise limit or affect the list of results, you can use the following options:

Key Type Details
limit Integer The maximum number of products to return, up to 100 entries can be returned per request.
offset Integer The number of products to skip from the beginning of the list.

For example, if you want to view all products in sets of ten, you would use the following request:

curl -X GET https://api.molt.in/v1/products/search \
-H "Authorization: Bearer XXXX"
-d "limit=10"

On success, this returns a 200 OK HTML status code and the first ten products. For the next page, increase the offset by ten:

curl -X GET https://api.molt.in/v1/products/search \
-H "Authorization: Bearer XXXX"
-d "limit=10"
-d "offset=10"

For each new page, add ten to the offset. Each call will return an array in the pagination field that indicates the total and current number of products, as well as additional information:

"pagination":
{
	"total":2,
	"current":2,
	"limit":10,
	"offset":0,
	"from":1,"to":2,
	"offsets":
	{
		"first":false,
		"previous":false,
		"next":false,
		"last":false
	},
	"links":
	{
		"first":false,
		"previous":false,
		"next":false,
		"last":false
	}
}