Hey folks,
I’ve got a daily cron job running in Python that pulls conversation analytics from Genesys Cloud and dumps the CSV into an S3 bucket. It’s been working fine for small date ranges, but now I’m trying to pull data for the last 30 days in one go, and the script keeps dying.
The issue seems to be with the conversation/conversations/metrics endpoint. When I pass a date_from and date_to that spans more than a week, the API just hangs or returns a 504 Gateway Timeout. I assumed the SDK would handle pagination automatically, but I’m not seeing any next_page tokens in the response object, just a truncated list of data points.
Here’s the snippet I’m using to fetch the data:
analytics = client.analytics_api
query = GetConversationQuery(date_from=last_month, date_to=today)
response = analytics.get_conversation_conversations_metrics(query=query)
I’m then iterating through response.body.data_points to write to S3 using boto3. The problem is data_points only contains data for the last 7 days, even though I requested 30. I figured I’d need to chunk the requests myself, but the docs aren’t super clear on what the max window size is for this specific endpoint.
Has anyone built a solid pagination loop for this? I tried splitting the date range into 7-day chunks and appending the results, but I’m worried about overlapping data or missing events if I’m not aligning the timestamps perfectly. Also, is there a better way to handle the rate limiting without just adding time.sleep() everywhere? My current script is hitting the limits pretty fast when I loop through multiple queues.
Any pointers on how to structure the date chunking logic would be appreciated. I’m just trying to get a reliable daily export without the script failing halfway through.