Stock Balance in ERPNext via API

How can I get single API that include all stock movements with quantity on hand already calculated? Stock Ledger include all the transaction however I don’t know how to calculate the balance when there is stock count. Currently am using date meaning I only check for other transaction greater than or equal to my count date. This is not very efficient and does not work all the time.