What is best way to pass pagination info to RestController?

519 Views Asked by At

Almost each major cloud storage service provider like Google, Box, OneDrive use request parameters to convey pagination info to web services and update response object to further communicate next page info to the client.

Despite of having standard HTTP Headers like Range and Link and custom headers people tend to use query parameters to convey such info.

Using such standard headers to convey pagination info between client and server keeps the standard response unique as we don't need to pass such info via response attributes.

So, what is the best practice to implement pagination in REST APIs? With HTTP Headers or with Query Parameters???

1

There are 1 best solutions below

3
Eric Stein On

According to the http specs:

Beyond that, using query parameters for pagination (preferably offset/limit) is a standard. If you have a good reason to buck the standard, that's fine. The downside is now everybody who is using your API has to learn your way of doing things in addition to the way everybody else does things. This lowers adoption and increases support calls.