First time poster, so forgive me if I am doing this entirely wrong.
I was trying to pull down our users via https://discuss.elastic.co/admin/users/list/all.json?api_key=KEY&api_username=USER which is working fine. However I have two problems when dealing with pagination and I could do with some clarification.
https://discuss.elastic.co/admin/users/list/all.json?api_key=KEY&api_username=USER&page=0 and https://discuss.elastic.co/admin/users/list/all.json?api_key=KEY&api_username=USER&page=1 seem to return the same thing.
https://discuss.elastic.co/admin/users/list/all.json?api_key=KEY&api_username=USER&page=9999999 returns a HTTP 200, but no body, because the page count doesn’t go that high.
I don’t seem to see anything in the response body or headers to indicate what the first/next/last page is. And the docs only say it takes an integer (buts accepts negative ones too).
The page param starts at 1. If it’s less than 1, it’s assumed to be page 1. (Code here.) And you’re right that we don’t return any attribute saying how many pages there are, so I guess the best thing right now is to stop when you find a page with less than 100 results.
Just an idea for a possible feature request: Would it be reasonable to implement this the way Github builds pagination? Over there, the returned header gives you feedback about the next fetched page (“links”). Rationale for them is to serve each request on its own, without “page guessing”.