This guide describes how to use pagination and filters in your requests to customize your results.
The pagination component
Sometimes, API calls return a large number of results. Our pagination component, allows you to easily handle results. Modzy has pagination available for all collection routes.
Modzy provides the option to manage results by adding the pagination component to the URL of a request and setting the values accordingly.
By default, the component is built to provide 10 records per page, starting at page 1. But you can adjust this preset.
Set a limit
To set a limit of records per page, use the per-page parameter with a value that matches the number of records you need.
Sample request
GET /api/accounting/users?per-page=5 HTTP/1.1
Parameter | Type | Description |
---|---|---|
per-page | number | The number of records returned per page. Defaults to 10. |
See another page
To see another page, perform a new call adding the page parameter with a value that matches the page number you want to see.
Sample request
GET /api/accounting/users?page=2&per-page=5 HTTP/1.1
Parameter | Type | Description |
---|---|---|
page | number | The page number to be returned. Defaults to 0. |
Sort-by
Modzy has an option to order and sort records. If you want to see the results in a specific way, you can add the sort-by
and direction
parameters to the header, and set them accordingly.
When more than one sort parameter is provided, the pagination component initially sorts by the first parameter, next by the second parameter, and so on. Parameter values are available for list routes and described on each route's topic.
Separate query values with a ,
to sort-by multiple values.
Sort-by
GET /api/models/all/versions/all?sort-by=processing.minimumParallelCapacity,processing.maximumParallelCapacity HTTP/1.1
Direction
Orders the records in ascending ASC
or descending DESC
order. It defaults to ASC
.