we are calling shopify API from several scripts. S...
# suitescript
k
we are calling shopify API from several scripts. Shopify uses a leaky Bucket algorithm to limit the number of calls, All our scripts are referencing the same 'API' function, How can I share the limits accross all the scripts? e.g. 'create items' scripts will make calls in the same time as 'send inventory' script. I need a way to centralize / store / share the calls limits.
r
Have a centralized server, hit all your apis to that server. And that server will hit other platforms. If you are also hitting concurrency limit in your Netsuite as well. You can make other api hit your centralized server and from that server you can hit your Netsuite restlets.. In your centralized server you can implement queues and other things. Although it might be a big task for your business use case and someone might have a better solution..
k
thank you @raghav, I know for the centralized server, but we are trying to achieve this with a 100% netsuite solution
b
i would advise a different approach, make your scripts actually pay attention to the points you have available from the response, make them wait the required time for the bucket to fill when the points are low
k
The points are not error proof, if we send 2 calls at the same time, and the available point is 1, then 1 call will errors
b
choose a better lower limit
if you have 3 scripts making calls, then make 3 the point where you start waiting
if thats too hard, then just always wait
you arent taking advantage of the bucket's capacity, but you wont get errors
k
We have tried to always wait, but with thousands of items, the scripts take too long
b
if you have a queue of thousands of items, you will always be waiting anyways
the bucket is helpful for temporary bursts of activity, not long queues
k
I think you are right @battk we will read the response.headers and deduce few points