Getting stock item's with rest API

Hi,

I want to GET sales item’s Quantity with there Batches via Rest API, i can’t find DocType

Thanks

Try something like this on your terminal:

BASE_URL="https://erp.my_company.com"
TOKEN=$(echo -n "MY_API_KEY:MY_API_SECRET" | base64 -w 0)
ITEM_CODE="12345"
WAREHOUSE="My Warehouse"

curl --location --request GET "$BASE_URL/api/method/erpnext.stock.utils.get_stock_balance" \
    --data-urlencode "item_code=$ITEM_CODE" \
    --data-urlencode "warehouse=$WAREHOUSE" \
    --header "Authorization: Basic $TOKEN"

This should return something like

{"message":150.0}

Edit: updated to include @revant_one’s solution.

1 Like
echo -n "apfjxkic-omyuobwd339805ak:60a06cd2ddfad610b9490d359d605407" | base64 -w 0
2 Likes

Thanks,

This helps me :slight_smile:

api/method/erpnext.stock.doctype.batch.batch.get_batch_qty?batch=[(batch]&warehouse=[warehouse]

You’re welcome, @AbdullahHasan. Please remember to mark my comment as the solution, if possible. :slight_smile: