I am trying to track the number of mentions a user receives overtime. I have been able to successfully query the rate limit allowed number of mentions (using pagination) for a specific user then sum them to get a total count. However, when I try to repeat this process for multiple users the first query is successful while the rest return no metadata. Each query succeeds when I call it individually, but what done in a series the first returns the number of mentions (up to the rate limit) then the rest return metadata=0 as I specified earlier. I tried waiting for some seconds before submitting another query but that does not solve my issues.

Below is the code that I use adapted from the github example. It iterates over the user ID’s and calls the endpoint with pagination.

Can I get some suggestions into what may be going on and how to fix this? I am using a Bearer token for access.

I have the feeling it could be caused by the output of your getUserID function, since your for loop relies on it, and you are experiencing an issue only when querying multiple users. Having a look at that function would probably help us understand what’s going on, and help you in return.