Get all item stock via REST API

Hello everyone,
I want to know if erpenext has a predefined function that allows to return the stock of all items
like erpnext.stock.utils.get_stock_balance returns the stock of a specific item and warehouse, but I want for all items.
I tried this in the server script but it doesn’t work
stock_balances = frappe.db.sql(“”"
SELECT
item_code,
warehouse,
actual_qty
FROM
tabBin
“”", as_dict=True)
i need a rep as soon as possible please

You could try this:

bins = frappe.get_all("Bin", fields=["item_code", "warehouse", "actual_qty"])

Note I haven’t tested this. You could refer to the db API docs for more info if you needed: docs

Just a note: you title your post with “via REST API”, but the code you show doesn’t look like an access attempt to a rest api.

See: REST API

thanks for your note
but i want to tell that via api (this code I write it in server script) and i the method in postman via /api/method/custom

1 Like

Thanks a lot, it works

2 Likes

Okay it turns out that Bin is a DocType not a report. So I used the normal format

api/resource/Bin