Building an app that interacts with different API's can be a difficult thing. They can return data in different formats, they can have different authentication mechanisms etc. That's why adding a middleware layer between the mobile app that loads and displays the data can help in a lot of ways.
Some of the most important benefits that you can get from adding a middleware layer between the app and the API's are as follows:
- data interpretation: API's can provide a lot of data, some of it raw, some of it un-necessary for the end user. The middleware can perform such aggregation tasks and make the life of the client much easier.
- throttling: sometimes you may not want clients to call a certain action many times in a short period of time. The middleware layer can help you to throttle requests on a global basis, effectively denying them access until the throttle has expired.
- adding a middleware layer gives you the option to provide data to the user from multiple API's: you have the ability to define resources that could span data from across several apis' making them available to the user through a single call and thus abstracting the internal structure of the API's to the client.
- ability to handle API integration details in a single place (authorization, authentication): the mobile app can be agnostic of any authentication and authorization details regarding the API's
- ability to switch to a new API without affecting the end user: a lot of things can change during the lifecycle of a product, API's can become deprecated, new datasource might be available. The middleware layer gives you the ability to properly decouple the mobile app from the API's from which it consumes data. Replacing an API or adding a new one can be done without affecting the client.