I need to build a profit/loss graph for a mobile app. The api from which I can get the historical price data only allows me to retrieve 1 item at a time. If the user has 500 items that would create an api failure since I can only make 50 req./min.

What is the best way to calculate this? Let's say the user buys:

  1. Bitcoin on 2018
  2. Ethereum on 2020

Solutions I thought about

Solution 1:

  • On the very first time the user refreshes the data, save when and it was saved and up to which historical date.
  • Do as many requests as coin the user have (problem here)
  • Calculate offline the profit loss based on the dates.
  • If the user comes back 5 days later, only pull those 5 days from the historical api and merge it with the previous ones.

The problem here is that I'm making too many api requests. Imagine the user has 1000+ coins.

Also calculating the profit/loss by hour might be a problem.

Solution 2:

Create a server side job and every day get the historical data, but this might be a little overboard since there are also multiple currencies, I was hoping to find an easier/less expensive solution.

Tech using

For the infrastructure I'm using AWS -> DynamoDB with DataStore + AppSync

What is the best way to accomplish this given many users and many coins per user, taking into consideration I can make 1 api request per coin and up to 50 request per min.?


  • Could you please clarify: when you say 500 coins, do you mean 500 hundred coins of a few cryptocurrencies (e.g. bitcoin, ethereum, theter), or are you referring to 500 different currencies? Can you confirm that the limitation of the API is 1 crypto currency (and all coins within the same currency have equal value on the same day)?
    – Christophe
    Mar 13, 2022 at 9:55
  • @Christophe It’s the first one you mentioned. 500 coins (bitcoin, etherium, theter…) yes, the api is from CoinGecko, historical data limits 1 coin per request, probably because it would be too big if you include more. So the request for 1 can include the historical price in hours or days up to x days or the max amount of days since the coin started. If you want I can provide the url of the api, it’s public. I didn’t understand your last question , for example if I select the currency usd all coins will have the same days and currency.
    – Arturo
    Mar 13, 2022 at 16:03

1 Answer 1


If you can do only 50 requests per minute you'll never be able to provide individual charts per user if you use up your precious API requests to serve one user request.

Your only chance is to gather historical price data and keep it in your own system, using your 50 requests per minute in a daemon process to update your data. User requests can then be served completely from your own data.

  • No no, it’s 50 request per min per ip address.So if 500 users have different ip then each can make 50 request per min
    – Arturo
    Mar 13, 2022 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.