loading...

Is it a good practice to get all the data in Single call, when designing REST API for mobile App ?

ns23 profile image Nitesh Sawant ・1 min read

Hi Everyone ,

I have a question regarding designing the REST API for mobile application.

Assuming I am designing a REST API for dashboard screen in mobile app.which fetches data from multiple tables in the database.

In this case, what is the ideal approach?

  1. One rest API to fetch all the data at once.
  2. Multiple rest API that fetches data from each database table.which may involve the second API to be called after the success of the first API.

Considering clean code practices like

  1. Separation of code concerns
  2. CPU usage/ and User experience on the app

Please share your experience on what should be the approach in such cases.

Thank you

Discussion

pic
Editor guide
 

It depends on your architecture. Having a single call means spending propagation time once: it will affect your loading times for sure. If there are several micro services you could provide a GraphQL layer to address that. Otherwise, if there is only one service you can add a new endpoint to provide all data needed.

 

Adding GraphQL layer seems to be a good apporach :)

 

Nice Question, Check below post.

softwareengineering.stackexchange....

Hope this helps.