I am using an API that allows our app to make 600 calls to it per a minute. An import will allow a user to make as many calls to the API necessary to import all of their contacts. This is being tested with databases of up to 25,000 contacts. With each return from the API I am provided an HTTP header "X-Rate-Limit-Remaining" that tells me the amount of API calls left for that minute.
I am needing assistance developing an algorithm that will take into account the amount of contacts a user has and if needed, the amount of calls they have left for the minute. With this we would need configured how much time must be provided between calls to insure we do not go over our 600 calls/min. The API has provided an extremely farfetched example in python (I am using PHP) that would not be of much use in production.
Any help with this issue would be so appreciated!