duffelhq / duffel-api-javascript

JavaScript client library for the Duffel API

Home Page:https://duffel.com/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rate Limiting

kevin-induro opened this issue · comments

The API documents a really useful method of tracking rate limiting. Are there any plans to incorporate that in the library? It would be nice if the library could track that internally, but I see a bunch of potholes with that method. At the very least, it would be great to expose the values of those headers in the response.

commented

Hi @kevin-induro, thank you for the feedback :) I'd be curious to learn more about your setup and your need for that bit of data -- what are you doing that requires you to handle a large batch of requests?

With that said, there are no plans currently expose the headers through our SDK -- but, I did share your feedback with our product team and they've made note of it. Since the rate limit doesn't change, have you considered for your requests to stay within an acceptable rate by introducing some wait times or doing the work in batches?

Yep, that's the workaround we have today. The API noted that these parameters could change, so I thought it safest to abide by the headers rather than rely on the rate limit mentioned. Also, I actually couldn't find the quantity. The frequency was clearly per sixty seconds, but my guess is a quantity of 60 requests in that time period, but only because that was the number in the example.

It's not that we're hitting the rate limit yet in production, but we can see when it could happen and can force it in development/testing. We have a service providing aggregated quotes for groups of people from various locations. For example, if I'm tracking a hundred people, that can hit the limit.

commented

Very good points @kevin-induro, thank you for taking the time to share that. You are right, the rate limit is not documented and that response header is the most reliable way get that information. Starting on version 1.17.0 (checkout changes here), you'll be able to get headers with every success and error returns from client calls.

We have a service providing aggregated quotes for groups of people from various locations

Very interesting use case! I'm curious to learn more. If you or your team need any more help or guidance to keep the momentum on moving forward with your integration please don't hesitate to reach out!

That sounds great! That's amazing turnaround you have there.

I'll certainly keep reaching out in mind.