> given that you know the number of pages after the first request, you can store that and not need to request n+1 pages. Or you can stop as soon as the number of items returned is less than the PAGE_SIZE (implying that you have reached a non-full page, the last page).

I'd be worried about the first one (it's possible but very unlikely that the # of pages can change as you're querying), but the second one sounds good.