REST api pagination: make page size parameter (customizable externally)

we have a search / resource list:

http://xxxx/users/?page=1

Inside, the page size is static and returns 20 elements. The user can move forward by increasing the page number. But in order to be more flexible, we now also think about exhibiting page size:

http://xxxx/users/?page=1&size=20

Thus, it is flexible, as the client can now select network calls and the size of the response when searching. Of course, this has the disadvantage that the server can be attacked either randomly or maliciosly with the goal of: http://xxxx/users/?page=1&size=1000000

For reliability, the solution may consist in setting an upper limit to the page size (for example, 100), and when it is exceeded, it either represents an error response or redirects HTTP to a URL with the maximum possible page size parameter.

What do you think?

+5
3

, - , .

+8

, : , .

, , API , , , .

, .

+3

, , ? , / ? , . , , , , .

Question: When I get a URI http://xxx/user?page=1, does the answer have a link to it on the next page? Previous page? If not, then this is not really RESTful.

+1
source

All Articles