Paginating API content
In the previous two sections, we were able to filter and sort API data, but we did not have control over how many records were being retrieved. In some situations, where we have a large number of records, we will want to introduce a boundary or limit to the number of records being retrieved by a single API call. Luckily, Strapi has us covered as well for such situations: it provides a pagination
API parameter that we can use to limit or paginate the API results.
Important Note
Similar to the filters
API parameter, the pagination
API parameter can only be used with the find
endpoint.
The pagination metadata is included in the API response under the meta
object. By default, Strapi returns 25 records per page. To change this value, we can use the pagination[pageSize]
parameter, which will allow us to control how many records we want to retrieve per page.
To better illustrate this, let's assume we have the following requirement:
As an API user...