I’m hitting a wall with the Analytics API when trying to fetch historical data for our custom agent desktop dashboard. The requirement is to pull interaction metrics for the last 90 days, but the API rejects the request with a 413 Entity Too Large status code.
I know the docs mention splitting queries, but I’m not sure how to structure the client-side logic to handle the pagination and aggregation correctly without missing data or hitting rate limits.
Here’s the basic structure I’m using with the Python SDK:
def fetch_analytics_data(start_time, end_time):
api_instance = genesyscloud.analytics.AnalyticsApi()
request_body = {
"query": {
"metrics": ["interactions.handle.time"],
"groupBy": ["wrapupcode.id"],
"filters": [
{
"type": "time",
"field": "timestamp",
"operator": "between",
"value": [start_time, end_time]
}
]
}
}
try:
response = api_instance.post_analytics_interactions_queries(
body=request_body,
async_req=False
)
return response
except ApiException as e:
print(f"Exception: {e}")
if e.status == 413:
# How do I split this range?
pass
If I split the 90-day window into three 30-day chunks, do I just aggregate the results manually in the app? Or is there a better way to chunk the time filter? The start_time and end_time are ISO 8601 strings.
Also, should I be using async_req=True to fire off the three requests in parallel, or will that cause issues with the client session? The data volume isn’t huge, just a few thousand interactions per day, but the payload size seems to be the trigger for the 413 error.
Any pointers on the cleanest way to implement this split logic?