Better way to get queues by user

Hey everyone.

I'm new here so nice to meet you all, I hope we can help each other.

My problem is: I'm trying to find a way to get live data about which queues are associated to each user, via API.

I tried to first get all users with the User API ( /api/v2/users ) and then, for each user, get the queues associated with them, with the Get queues for user API ( /api/v2/users/{userId}/queues), but there are like 200 users in the platform and for each user, from 4 to 9 queues associated. The result is the script takes 7 minutes to refresh.

Am I doing something wrong on my approach or something else?

Appreciate the help in advance.

Deivid Araujo

7m seems like a long time, that should only be 201 api calls which should be doable in under a min

You can do it in reverse by querying for the list of queues /api/v2/routing/queues and then get the users

/api/v2/routing/queues/{queueId}/users

2 Likes

I would highly recommend using notifications for this so your application can be kept up to date in real-time. You can subscribe to the topic v2.routing.queues.{id}.users to be notified when a queue's membership changes. If you need user presence for another reason or you need to subscribe per user and not per queue, you can use v2.users.{id}.activity, which contains the user's queue membership. You'll need to initialize your application's state using the API, but using notifications will be much less cumbersome for your app after the initial data load.

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.