DEV Community

Nitesh Sawant
Nitesh Sawant

Posted on

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

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

Top comments (3)

Collapse
 
luscala profile image
Luca Scala

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.

Collapse
 
ns23 profile image
Nitesh Sawant

Adding GraphQL layer seems to be a good apporach :)

Collapse
 
shaijut profile image
Shaiju T

Nice Question, Check below post.

softwareengineering.stackexchange....

Hope this helps.