Stock Balance through API

Hello Everyone,
Can you recommend the best way to get Stock Balance via the API

Currently, am using Stock Ledger but I don’t want to get the entire list then sum i want to know if there is DocType in the API i can grab this information from.

you should make your custom python file and us below code you will get balance qty for particular item and warehouse.

def getStockBalance(item_code, warehouse):
	balance_qty = frappe.db.sql("""select qty_after_transaction from `tabStock Ledger Entry`
		where item_code=%s and warehouse=%s and is_cancelled='No'
		order by posting_date desc, posting_time desc, name desc
		limit 1""",(item_code,warehouse))

	return balance_qty[0][0] if balance_qty else 0.0

Thanks you.