Pulling conversation details for a quarterly report and the volume is massive. I’m using the /api/v2/analytics/conversations/details/query endpoint via Python requests.
The docs mention pageSize and pageNumber, but I noticed the response object sometimes contains a nextPageToken depending on the data size. I assumed this was standard cursor-based pagination for performance, but when I try to use that token in the subsequent GET request, the API throws a 400 Bad Request saying the token is invalid or unexpected.
Here’s the basic loop I’ve got:
params = {
"dateFrom": "2023-10-01T00:00:00.000Z",
"dateTo": "2023-10-31T23:59:59.999Z",
"pageSize": 1000,
"pageNumber": 1
}
while True:
resp = requests.get(url, params=params, headers=headers)
data = resp.json()
# process data...
if "nextPageToken" in data:
params["pageNumber"] = None # trying to switch to cursor?
params["nextPageToken"] = data["nextPageToken"]
else:
break
Is this endpoint strictly page-based? If so, why does it return a token? I’m getting rate-limited quickly if I just increment pageNumber blindly because the API seems to lag on large datasets. Any chance I’m misinterpreting the response structure or is there a specific header I need to send for the cursor to work? The SDK docs are a bit vague on the exact mechanics here.