Should an API return calculated values that the consumer can calculate themselves?
Short answer:
Yes.
Long answer:
What are the advantages for letting the client compute the missing information? Are you saving bandwidth because there is less bytes transmitted over the network? Do you have a cleaner API by not returning derived data from the core data? What's the reason to not just compute this field?
Even if you have a reason. What you are doing is increase the coupling between your server API and your clients. If, for example, you return daily_price
and number_of_days
then the client needs to compute total_price
. Always.
What if at some point this is no longer a multiplication? But some other other rules start to apply? Maybe new regulations introduced? I'm speculating here but what if taxes apply beyond a certain total amount? What if you want to apply discounts for certain total amounts? And a bunch of any other cases that changes the rules of the game?
If the rules change at some point, are you going to contact all your clients and have them change their code to now handle the new rule? This is your API, thus your responsibility. Don't put part of the responsibility for your API on your clients. Just add the derived/redundant data to your responses. You are not gaining anything if you don't.