I’m trying to fetch real-time queue stats like waiting count and available agents using the Node.js SDK, but the data is consistently lagging by about 30 seconds. I’ve ruled out caching on our end since we’re making fresh requests every 5 seconds. The endpoint I’m hitting is /api/v2/analytics/queues/realtime with the expand=agents parameter, which should theoretically give me live data. Here’s the basic call I’m using in the Express handler:
const stats = await platformClient.AnalyticsApi.getQueueRealtime(
queueId,
{ expand: ['agents'], dateFrom: new Date().toISOString() }
);
The response comes back with a 200 status, and the JSON structure looks correct, but the agentsAvailable count doesn’t match what I see in the admin console. I’ve checked the OAuth token and it’s valid, so auth isn’t the issue. I also tried adding the interval parameter set to 30s as per the docs, but that didn’t change anything. It feels like the API is pulling from a cached snapshot rather than the live state. I’m wondering if there’s a specific header or parameter I’m missing to force a live query. We’re running this in a Node 18 environment, and the SDK version is the latest stable release. I’ve also verified that the queue ID is correct and that agents are indeed logged in. The delay is causing issues with our real-time dashboard updates, so I need to figure out if this is a limitation of the API or something on my end. Any ideas on how to get truly live data? I’ve scoured the docs but haven’t found a clear answer on how to bypass the apparent caching layer. It’s frustrating because the REST API for other resources feels instant. Maybe I need to switch to a WebSocket subscription instead? I’m not sure if the Statistics API supports that. I’ll keep digging, but any pointers would be appreciated.