Learn Courses My Dashboard

Maximum API calls combining with the number of users

May I be too novice at swift right now, or is just an issue some of you encountered and maybe you can provide me with some help.

I extract data directly from Alpha Vantage API, parse the json, put it into an struct and so on. Everything works fine. I also put this method in the app background so the app is updating from time to time.

BUT…

Maximum API calls is 1200/per minute (if you pay), and its the maximum. Lets say 2000 people installed my app. At every 1 hour in the background of the app fires the API method. But there are 2000 devices, each of them representing an API call, so nothing will work.

I was thinking that the best solution will be to import all the JSON data to a server at every hour, and the user devices just retrieve the data from there. I use Firebase and there I can upload JSON manually from my laptop…What if I want to retrieve that data at every 5 minutes, I wont stay all day and night at every 5 min to download and paste manually json data in Firebase real time database…

So, do you have any solution for this issue? How I can import json data dynamically into Firebase or, if it isnt possible in Firebase, in whatever other database? Or is not necessary and even though there are 2000 devicies, there is ocuring just one call and is sent automatically to all devices in background?

Thank you! Any answer I reckon it will be helpfull for me at this point.

Don’t use your own API key. Each user should sign up for their own key (they’re free) and then enter it into your app to be stored in UserDefault or the keychain or wherever. Then you use that API key to make the requests.

That’s usually the way things like that are done.

1 Like

I would have never thank about that. Thank you sir!:slight_smile:

That’s interesting, like if I had an app that uses Twitter, and I develop using my API key from their website, how do users sign up for their own API keys?

1 Like

I thank about an solution later, in my opinion I really think it is OK.

I create a second app connected to the same database at Firebase. And when I want to update data I just fire that app, or I simply let my mac on and it fires continuously repeating actions at some time.

So, instead of:
→ Each device of every user calling Api methods which will be a lot above 1200 calls per minute if there are lots of users.
→ I call the API methods from the another app (like maximum 5 times a day) , put the result in data base, while the main app just retrieves data from there when needed