Quick check on the correct way to handle pagination with the Analytics API. I’m building a script to pull out interaction data for the last 24 hours, but the paging object in the response is confusing me.
I’m using the Python SDK (genesyscloud.analytics.api.AnalyticsApi). Here’s the call:
from genesyscloud.analytics import AnalyticsApi
from genesyscloud.analytics.models import AnalyticsQueryInteractionDetailsRequest
analytics_api = AnalyticsApi()
request = AnalyticsQueryInteractionDetailsRequest(
query={
"date_from": "2024-05-20T00:00:00.000Z",
"date_to": "2024-05-21T00:00:00.000Z",
"size": 2000
}
)
response = analytics_api.post_analytics_interactions_details_query(request)
The response comes back with:
{
"pageSize": 2000,
"pageNumber": 1,
"pageCount": 5,
"total": 10000
}
I assumed setting size to 2000 would give me all records in one go if there were fewer than 2000. But here, pageCount is 5. Does that mean I need to loop through all pages even though I set a large size? Or is size just a limit per page, and I still have to manually increment pageNumber?
Also, when I try to get the next page by setting pageNumber to 2 in a new request, I get a 400 Bad Request saying the query is invalid. Am I missing a required field for subsequent pages? The docs aren’t super clear on whether pageNumber is handled automatically or if I need to manage it myself.
Any pointers on how to correctly iterate through all pages without hitting rate limits or getting invalid query errors? I’ve been stuck on this for a while now.