How to keep tracks of customers purchase history

Is there an API or similar tool that can provide the total cost spent by a customer on an app from the time of installation until the present date? For example, if a customer installed my app in January 2024 and has been using it since then, is there a way to retrieve the cumulative amount they have spent on the app up to the current date?