Pull Stock Balance via API

Is it possible to GET request Stock Balance via api?

You will have to create a whitelisted method which returns the data from execute method in stock_balance.py

Is there an example of this?

your_app/api.py

def get_stock_balance_report(args):
    from erpnext.stock.report.stock_balance.stock_balance import execute
    return execute(args)

You can now GET request on hostname.com/api/method/your_app.api.get_stock_balance_report

1 Like

@paul-100,

You can also get the actual_qty and projected_qty using get_bin_details method.
https://erpnext.org/docs/current/api/stock/erpnext.stock.get_item_details#erpnext.stock.get_item_details.get_bin_details

Although it will return stock balance for only single item, to fetch the stock balance for all items you will need to write the custom method as suggested by @netchampfaris

thanks i will try that

its not the best method i have tried Bin with the for loop even Stock Ledger Entry

I generally use erpnext.stock.utils.get_latest_stock_qty which is already a whitelist method.

url : http://0.0.0.0:8000
method: POST
parameter:
pass this parameter in body

cmd:frappe.desk.query_report.run
filters:{“from_date”:“2017-04-01”,“to_date”:“2017-08-24”}
report_name:Stock Balance