Best practice for avoiding API call limits?

I’ve got a page that you can see in action here that pulls products directly from Best Buy’s API. There is a drop down which allows the user to view a certain category and each category fires it’s own API call. The data from Best Buy refreshes every 3 hours.

This API has a limit of 50,000 calls per day and 5 per second. I haven’t run into issues yet but fear I’ll run into growth issues such as 5+ users simutaneosly loading the page.

What I’d REALLY like to accomplish is to display multiple categories at once. But, if I’m not mistaken, if I had say 10 categories display at once when the page loads, that would be 10 calls in a second, therefore getting me in trouble.

To avoid limits, it seems like the best approach is to eventually save the API data as a datatype and refresh on the backend every three hours. So what the user would be seeing is actually products from my DB. Is this the best long-term approach, especially if I wanted to display multiple API feeds at once or is there an easier solution I’m not aware of?

The way you’ve described is likely the way I would do it using backend workflows to run every 3 hours but someone else may have a better solution.

In terms of of your 10 categories display comment, that only gets you into trouble if you have to make a separate api call for each category. I am not familiar with best buy’s api documentation but I would bet that you could display multiple categories at once with one api call and then have your repeating group in bubble separate out the categories visually. If I’m wrong then I have no idea why Best buy would build their api that way.

1 Like

Yeah they have a Product API that can pull their entire catalog (or multiple categories) all at once but what you are seeing on that page is a special “Reccomendations API” they have which specifically shows you what is popular/trending in each category, so multiple catagories in the same API won’t work as far as I’m concerned, but I’ll double check!

Makes sense. If you’re trying to limit the amount of work you have to do on saving everything to the DB, you could use the backend workflow to just save the product id’s of what’s trending from the recos api and then use those product id’s to filter the full product catalog api

ooooh! That’s a very interesting approach. Going to look into that. That would certainly enable the ability to display as many trending categories as I wanted while only making a single call, however I suppose it still doesn’t elimiate the issue of 5 people loading the page at once.

Perhaps I don’t have a great understanding of API calls because I’m always reading to rely on displaying the API data as much as possible before saving it to the DB, but it seems most APIs have limits with how many times calls can happen, and 5 per second seems normal. With Amazon you have to generate around $5000/month in sales to their products for just additional 1 second, and even that they cap at 10 seconds.

Getting 5-10 people to open your site/page at the same time isn’t a crazy high number, so it seems ultimately if you have an application that scales even just a little bit in growth, saving the data to your DB, or even a 3rd party DB, is the only long-term viable option, right?

I can’t say whether it is the only long term option but from what I know I think it is (but as I said, someone else might say something different).

Yes, it is feasible to have 5 people on your site at one time but you would have to have a fair number of active users for that to happen frequently. I think the industry practice is to set up a queue that just delays the 6th person until the api can make another call.

Not sure how good your stats skills are but if you know how many daily active users you have per hour, you can do a statistical calculation to determine how likely it would be that more than 5 people show up within one second. My guess is that calculation is going to return a pretty small value.

1 Like

You could have every user input their own API key in their profile. Then use this API in calls, this would reduce the number of API calls on your own API key.