Handling pagination for /api/v2/analytics/conversations/details/query in Python SDK

We are trying to pull a complete dataset of conversation details for a specific date range using the Genesys Cloud Python SDK. The endpoint is /api/v2/analytics/conversations/details/query.

The documentation mentions both cursor-based and page-based pagination, but the behavior is a bit opaque when using the AnalyticsApi client. When we set size to the maximum allowed value of 1000, we get the first batch. The response includes a nextUri field.

Here is the snippet we are using to fetch the initial page:

from purecloud.api import analytics_api

api_instance = analytics_api.AnalyticsApi(client)
request = analytics_api.QueryConversationsRequest()
request.body = analytics_api.QueryAnalyticsRequest(
 date_from="2023-10-01T00:00:00Z",
 date_to="2023-10-01T23:59:59Z",
 size=1000
)

try:
 response = api_instance.post_analytics_conversations_details_query(request)
 print(f"First batch size: {len(response.entities)}")
 if response.next_uri:
 print(f"Next URI: {response.next_uri}")
except Exception as e:
 print(f"Exception: {e}")

The issue arises when trying to fetch the subsequent pages. We noticed that response.next_uri is sometimes None even though we haven’t retrieved all expected records. We assumed that if next_uri is present, we could use it directly, but the SDK method post_analytics_conversations_details_query expects a QueryConversationsRequest object, not a raw URI string.

We tried passing the next_uri into a new QueryAnalyticsRequest body, but that failed with a 400 Bad Request because the body structure was invalid.

Is there a recommended pattern in the Python SDK for iterating through these results? We want to avoid writing a custom HTTP client if the SDK handles the cursor logic internally. We just need to know the correct way to chain the requests without hitting rate limits or getting malformed JSON errors.

Also, we are seeing some inconsistency where next_uri contains a cursor token, but the documentation suggests page-based pagination for certain views. Which one applies to this specific endpoint? We are trying to automate this via a Terraform local-exec script that calls a Python helper, so stability is key.