Minimum delay between calls to API?

webhooks

#1

Hi

I have an issue with performing API calls in quick succession.

Whenever I

POST account_activity/webhooks
and immediately afterwards
POST account_activity/webhooks/:webhook_id/subscriptions

the second POST results in an error, whereas if I wait 3 seconds before the second POST it all works fine.

Is there an official minimum delay between API calls that needs to be respected?

Thanks


#2

Long delayed response here.

Here is a Node script that makes these calls consecutively. It’s important to wait for the first request to complete before continuing when using an asynchronous language like javascript. Perhaps this is the issue being encountered.


#3

Hi Jon

thank you for your reply. I do indeed make sure that a request is completed before the next one is started. I suspect it’s an issue related to the eventual consistency of Twitter’s storage. If this is the case, it might be worthwhile trying to avoid this problem, maybe by routing subsequent webhook-related requests to the same node (just guessing…).


#4

It is possible that it could be a delay in data replication, but 3 seconds sounds excessive. We haven’t had this issue reported by others, but I’ll keep an eye out for it. May I ask what region of the world you are in? It would help identify the data center you would be hitting.


#5

3 seconds is my “safe” request delay: last time I tried it was for sure larger than 1 sec.
Due to the request limits I could not perform many tests and I decided to play it safe with a long delay.