I am building a web application that makes use of multiple API's (Google Maps, Weather APIs, and more). I am using Python + Flask on the backend, and Javascript (probably with React, I have not decided yet) on Front end.
The application will take the results of these various API query's and then give the user a simple, summarized result, which involves a fair amount of calculations and conditional logic based on the API response.
What the best practice to do this?
If I do all the API calls on the client side, and I deal with calculations and such there too, that feels cumbersome.
If I do it all on the backend, the calls are not asyncronous and so I am worried the calls might take a while. Though in my use case a 2-3 second wait is probably acceptable as long as there is a "Loading" message. This is what I currently have (halfway through writing all the API calls and the needed calculations)
I could also do the API calls on the client, pass it to the server for calculations, and then sent the results back to the front end. Not sure if that's a practical solution or if it would really solve anything.
Best Answer
You should be using a server to manage and call external APIs then combine the responses as necessary and return them to the client.
The general goal should be to minimize the number of requests and amount of data transferred. Third party requests should also be minimized unless they can reduce the amount of data transferred or provide similar benefit (ie CDNs).