Should maxResults allow for 0 value?

Not applicable

Hello,


We are designing an API that will support pagination. In order to cap the number of results that come back, we allow 3rd parties to pass in a maxResults query parameter.

The majority of public APIs that I've researched allow for maxResults = 0 to (something), inclusive. But I can't see why 0 would ever be an acceptable value? Does anyone have insight into this? Why would anyone ever need to call an endpoint and not get any results back?

One counter argument that I've heard is that maybe you just want to count the totalResults value. But you could do that with maxResults = 1.

Thanks,

Alex

0 1 100
1 REPLY 1

Good question. Here's my view: I suppose if you want to count the total results but do not want to incur the network cost of sending back any of the results, then it makes sense to allow a request with maxResults=0.

If a request with maxResults=1 sends back one result, and that one result is large, then it may be "expensive" and undesirable to send it back, if the client only wants a simple count.