Hey folks,
I’m building a daily job to pull WEM adherence data and dump it into our S3 bucket for some reporting. I’m using the Genesys Cloud Python SDK to fetch the analytics and boto3 to handle the S3 upload. The logic seems sound for small windows, but when I try to pull a full day’s worth of data, the script hangs or throws a connection error.
Here is the core function I’m using to get the data:
def get_adherence_data(client, start_time, end_time):
try:
# Using the WEM analytics endpoint
analytics_response = client.analytics.get_analytics_wem_adherence(
start_time=start_time,
end_time=end_time,
group_by='user',
expand='wrapupcode,reason' # Trying to get detailed breakdown
)
return analytics_response.body
except Exception as e:
print(f"Error fetching data: {e}")
return None
The issue seems to be that get_analytics_wem_adherence returns a limited set of records or times out if the start_time and end_time span more than a few hours. I can’t find pagination parameters in the SDK method for this specific endpoint like I do for standard API calls.
Is there a recommended way to chunk these requests in Python without hitting rate limits? Or am I missing a parameter that allows larger exports? The docs are a bit vague on the exact payload limits for WEM endpoints.
Also, when I do get a response, the JSON structure is nested deeply. I’m currently flattening it manually before sending to S3, which feels inefficient. Is there a better pattern for handling this volume of data in the SDK?