Analytics API paging object behavior with pageSize and pageCount

Trying to figure out the correct way to handle pagination with the Analytics API. Specifically looking at the GET /api/v2/analytics/interactions/voice/summary endpoint. The docs mention a paging object with pageSize, pageNumber, and pageCount. I’ve been using pageSize=100 and incrementing pageNumber manually in a loop. It works for the first few pages. Then it stops returning data. Not getting a 404 or 500. Just an empty list of data points. Here is the request structure I am using.

GET /api/v2/analytics/interactions/voice/summary?dateFrom=2023-10-01T00:00:00.000Z&dateTo=2023-10-01T23:59:59.999Z&pageSize=100&pageNumber=1

The response header shows x-page-count: 5. So I loop from 1 to 5. Page 1 returns 100 items. Page 2 returns 100 items. Page 3 returns 0 items. Page 4 returns 0 items. Page 5 returns 0 items. This seems wrong. If pageCount is 5, shouldn’t there be data on all pages? Or does pageCount mean something else? Maybe total pages available regardless of current filter? I tried changing pageSize to 10. Same issue. Page 1 has data. Page 2 is empty.

I also checked the response body. It includes a paging object.

{
 "data": [],
 "paging": {
 "pageSize": 10,
 "pageNumber": 2,
 "pageCount": 5
 }
}

The pageCount stays at 5 even when data is empty. This suggests my understanding of how the API calculates pages is off. Is pageCount a static estimate? Or is it based on the maximum possible results? I need to know when to stop looping. Checking for empty data array works but feels hacky. Is there a specific flag or status code that indicates no more data? I’ve tried setting pageNumber to pageCount + 1 just to see. Still gets 200 OK with empty data. This makes it hard to write a clean loop in the script using the REST Proxy. How do others handle this? Is there a better pattern?