I have an API design question. If I have a resource with nested resources and half the time I need to fetch the parent along with the nested resources from the client, should I use one call to fetch these resources or would it be better (in terms of design) to fetch them in separate calls?
For example, most of the time I need to fetch a Group
with its Employees
. Would it be better to fetch them in one call or use two different calls (one for Group
and another for Employees
?
Also, would it be considered a bad practice to conditionally fetch the nested entities from one call with a conditional parameter?
Example:/group?withEmployees=true
(fetch group with employees)