Hi,
I need to call 15 different APIs and process the data and consequently show it on the screen to the user.
Of course, I won't always call all 15 APIs at once. It depends on what the user selects on the screen, in the DropdownTag field.
I found a way to do it:
Create the Cosume Rest of these APIs and create a Server Action for each API. In other words, I would have at least 15 Server Action.
And on the front end, I would create a Data Action by calling 15 Server Action.
Remembering that I will not always call all the APIs at the same time. Therefore, I will have a switch.Below is an illustrative image of what I think about creating.
I would like to know if this is the best way or if there is a better way to perform.
Thanks !
Hi Adriano,
I guess that’s the most direct and simple way to do it.
Just some recommendations, I would isolate this layer of IS, and if this APIs are from different third parties or have different business ownerships, then I would also isolate each API in different modules. On top of this IS layer, I would build an orchestrator layer, a BL layer to abstract the logic of calling the services, consider creating this orchestrator as a service action, to promote loosely coupled from your consumer layer (End-user layers or API exposure).
Regarding your approach, remember that this is a synchronous way of doing this, so if this service takes too long to response, the user will need to way for it, or if you have to call several services, I need to do it, one by one.
Do you have any idea about the volume data returned by these services and the volume requests expected?
Are you considering in the future, the possibility of calling several services simultaneously?
Do you think that the user might need to search data from several services, until he finds what he is looking for?
Is your flow sequence dependent or you can allow the user to proceed and present him this data in a further step of your flow?
I guess the volume of calls, amount of data, the location of this APIs, are very important keys to decide if you have to create a more or less robust solution, to guarantee performance and accessibility. If you expect very low volume of calls and amount of data, then probably keeping this simple and direct is the best answer, but if you are expecting millions of records or millions of calls to be made, maybe you have to explore a more scalable approach.
Hope this helps somehow :)
Cheers, have fun coding. JAS.
yes, i think the spider web is unavoidable. I did the same like that in some project.
regards
If you have a set of variables that are used in one or more business rules to determine which API to call, you cannot use a For Each or a Switch. A For Each is only used to iterate over a List with data, and a Switch is only used to select a single program flow. In your case, it seems you need a number of Ifs instead, each If implementing a business rule, and when True, execute one or more APIs.