Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is calling multiple APIs from a mobile app harmful?

I am developing an Android app with sails.js backend. Assume that I have 3 different APIs, namely A, B and C. These APIs only fetch data return them with minor / no computations or update values in the databases. Each of these APIs take 300-400ms respectively on live.

Currently, I am running on a micro EC2 instance of Amazon Linux, which will be scaled as more users come in.

Is it a good idea calling 3 APIs from the Android app or having a single APIs which performs the job of all 3 APIs in a single call? My idea of creating 3 different APIs is to reuse the same in my AngularJs front end.

like image 598
Jaseem Abbas Avatar asked Sep 27 '22 23:09

Jaseem Abbas


People also ask

How many API calls is too many?

But in most cases our servers will reject API requests from a particular application if the request rate exceeds 30 API requests per minute. In this case the client will get an HTTP error with status code 429 “too many requests”.

Can an application have multiple APIs?

To answer your question, yes it is normal to have several microservices (small APIs) working together in a solution.

How often should you call an API?

For fetching the performance reports of monitor groups, it is recommended to call the API on a hourly basis, as the data archiving is done only once in 60 minutes.


2 Answers

It is a good idea in terms of reusability as you're already using these APIs. But I would still go with an API that summs up the functionality of three calls with one just because mobile device don't always got a good internet connection. Using a single API call requires less traffic and decreases the loading and response time. I would recommend measuring the API call time with the android emulator using extreme connection settings (EDGE, high latency) and compare the results.

like image 161
davidgiga1993 Avatar answered Oct 11 '22 16:10

davidgiga1993


Try to use thread for each api, In android we use handler in the form of thread .You can run the api,s one by one by using handler.

like image 25
Deep Singh Avatar answered Oct 11 '22 14:10

Deep Singh