I am working on an application that requires some double writing. There are currently two endpoints
/account /transaction
Although /account handles general account data, /transaction handles transactions for deposits / withdrawals. The account balance is calculated based on the relevant transactions. I left them separated to get consistency in accounting when transferring value from one account to another.
My question is how to present the account balance at the /account endpoint, since it will always be calculated based on the time of the request. If the answer just contains balance as a read-only field? This smells like a bad API design, as all fields are, but this option will be writable / updated.
An alternative, in my opinion, would be to expand the endpoint to
/account/{id}/balance
returns only the balance of the corresponding account. However, this always requires a second call to get a balance in addition to the rest of the account information. Perhaps the answer could generalize how to represent aggregated values.
source share