Analytics API pagination loop breaking early with pageSize 1000

Hey everyone.

I’m trying to pull a full history of adherence data from the Genesys Cloud Analytics API for our WEM reports. We need everything for the last 30 days, so I’m hitting /api/v2/analytics/wfm/schedules/details with a date range. The goal is to iterate through all pages until I have the complete dataset.

I’m using the standard paging object parameters: pageSize, pageNumber, and checking pageCount. My understanding is that if I set pageSize to 1000, the API should return up to 1000 records per request, and I can loop through pageNumber until I hit the pageCount returned in the response.

Here is the simplified Python loop I’ve written:

def fetch_adherence_data(start_date, end_date):
 all_data = []
 page_num = 1
 max_pages = 1 # Initial placeholder
 
 while page_num <= max_pages:
 response = analytics_api.get_wfm_schedule_details(
 start_date=start_date,
 end_date=end_date,
 page_size=1000,
 page_number=page_num
 )
 
 # Extract data
 all_data.extend(response.entities)
 
 # Update page count for loop condition
 max_pages = response.paging.page_count
 page_num += 1
 
 print(f"Fetched page {page_num - 1} of {max_pages}")

 return all_data

The issue is that the loop stops after page 2, even though I know there are more than 2000 records in that date range. The response for page 2 returns a pageCount of 2. If I manually change the pageNumber in Postman to 3, I still get data back, but the API keeps telling me pageCount is 2.

Is pageCount static for the entire query, or does it change? I feel like I’m missing something about how the paging object works here. The docs mention pageSize can be up to 1000, but maybe there’s a hard cap on total records returned per request that I’m hitting without realizing it. Any ideas on how to structure this loop correctly so I don’t miss data?