we are having a search/list-resource:
http://xxxx/users/?page=1
Internally the page-size is static and returns 20 items. The user can move forward by increasing the page number. But to be more flexible we are now thinking also to expose the size of a page:
http://xxxx/users/?page=1&size=20
As such this is flexible as the client can now decide network-calls vs. size of response, when searching. Of course this has the drawback that the server could be hit hard either by accident or maliciosly on purpose:
http://xxxx/users/?page=1&size=1000000
For robustness the solution could be to configure an upper limit of page size (e.g. 100) and when it is exceeded either represent an error response or a HTTP redirect to the URL with highest possible page-size parameter.
What do you think?
The Offset method is the most common way to paginate resources (with an offset on query), but it's less efficient than the Search-after method.
PageSize : represents the number of records that are displayed when a page loads. PageSizes : represents the different page sizes that the user can select.
Pagination can be implemented using one or both of two query parameters: limit to define the number of items returned in the response, and. marker to specify the ID of the last seen item.
API pagination is essential if you're dealing with a lot of data and endpoints. Pagination automatically implies adding order to the query result. The object ID is the default result, but results can be ordered in other ways as well.
Personally, I would simply document a maximum page size, and anything larger than that is simply treated as the maximum.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With