Hello all,
I am in the midst of developing a RESTful API, and I wish to implement a response length limit (similar to “Paging” practice often used in web frontends) e.g. the API will only return up to 5000 “resources” at a time and it is up to the requestor to ask for a different range if they need more results. I have experienced this with other APIs, such as Amazon S3, so I don’t believe it is an uncommon practice. This will help prevent the API, or whatever is using the API from running out of memory when they unexpectedly get a large request or response.
My question is whether there is a general “standard” (or at least popular implementation) for the “protocol” / behavior online that people are using and I can read. E.g. should my API return with a new header when the response has been limited, or the header always exists and is flipped to true when I reach my limit? Should the user send a page
=2 variable or an offset=5000
in their requests when they want to get more results. Do I need to return the total number of possible results in my response or is that not required (likely to save me from running unnecessary full table scans).
Any tips or personal anecdotes in this area is appreciated.