# GET stock quantity for given stock ID in API

**URL:** <https://community.breww.com/t/get-stock-quantity-for-given-stock-id-in-api/5544>\
**Category:** Help & advice\
**Created:** [5 February 2025 20:11 UTC](https://community.breww.com/t/get-stock-quantity-for-given-stock-id-in-api/5544 "2025-02-05T20:11:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael-podevin](https://community.breww.com/user_avatar/community.breww.com/michael-podevin/32/1975_2.png) [@michael-podevin](https://community.breww.com/u/michael-podevin)\
**Post date:** [5 February 2025 20:11 UTC](https://community.breww.com/t/get-stock-quantity-for-given-stock-id-in-api/5544/1 "2025-02-05T20:11:38Z")

</div>

I would like to simply get the current quantity of a stock item through the API but it’s unclear what these parameters are and where to find them for example for a stock item called “cans” with a url id of **201408**

these are the GET API parameters

batch\_code: string  
batch\_code\_\_contains: string  
batch\_code\_\_endswith: string  
batch\_code\_\_in: array

you can I guess peak at the JSON here: [https://breww.com/api/stock-received/](https://breww.com/api/stock-received/)

trying to follow this webpage:  
[https://breww.com/api/schema/elements/#/operations/stock\_received\_list](https://breww.com/api/schema/elements/#/operations/stock_received_list)

Thanks!

---

<div class="post-metadata">

**Author:** ![matt-cousins](https://community.breww.com/user_avatar/community.breww.com/matt-cousins/32/3876_2.png) [@matt-cousins](https://community.breww.com/u/matt-cousins)\
**Post date:** [6 February 2025 09:20 UTC](https://community.breww.com/t/get-stock-quantity-for-given-stock-id-in-api/5544/2 "2025-02-06T09:20:18Z")

</div>

The batch code is the found by going to the “Stock” tab on a stock item, see below.

 ![Screenshot 2025-02-06 at 09.10.30](https://breww-community.fra1.digitaloceanspaces.com/original/2X/b/bd0fa95cbd6e6a943bb954a54fda3f17c56b6a2e.png)

So you can query by `batch_code` to get the `current_quantity` of a **specific batch** of stock item.

However, if you want to see the total stock of all batches of a **specific stock item** , you would want to use the `stock_item` filter (and also the `is_empty` filter to remove batches with no current stock).

```auto
GET https://breww.com/api/stock-received/?stock_item=XYZ&is_empty=false

```

You’d then need to tot up the current quantity of each batch.

You can get the ID of your stock item by going to the stock item’s page in Breww and taking it from the URL like you say, or programmatically by querying the `stock_items` endpoint.

---

<div class="post-metadata">

**Author:** ![michael-podevin](https://community.breww.com/user_avatar/community.breww.com/michael-podevin/32/1975_2.png) [@michael-podevin](https://community.breww.com/u/michael-podevin)\
**Post date:** [6 February 2025 12:48 UTC](https://community.breww.com/t/get-stock-quantity-for-given-stock-id-in-api/5544/3 "2025-02-06T12:48:55Z")

</div>

Hi Matt,

Thanks so much. Is the “XYZ” below

```auto
http://breww.com/api/stock-received/?stock_item=XYZ&is_empty=false

```

formatted with the stock\_item **id** from the url?In my case this is “201408” so would this just be

```auto
http://breww.com/api/stock-received/?stock_item=201408&is_empty=false

```

?  
I get a javascript error message:

| 1:41:55 PM | Notice | Execution started |
| --- | --- | --- |
| 1:41:56 PM | Info | {stock\_item=[Select a valid choice. That choice is not one of the available choices.]} |
| 1:41:56 PM | Notice | Execution completed |

I hope this question pertains more to Breww than it does Javascript. Thanks!

---

<div class="post-metadata">

**Author:** ![matt-cousins](https://community.breww.com/user_avatar/community.breww.com/matt-cousins/32/3876_2.png) [@matt-cousins](https://community.breww.com/u/matt-cousins)\
**Post date:** [6 February 2025 13:33 UTC](https://community.breww.com/t/get-stock-quantity-for-given-stock-id-in-api/5544/4 "2025-02-06T13:33:03Z")

</div>

Ah sorry, I think that’s because it needs to be http **s** , not http. I wrote just http in my last reply, so that’s my fault! I have edited my previous answer now to avoid someone in the future using it and having the same issue.  
Let me know if you’re still having a problem.

---

<div class="post-metadata">

**Author:** ![michael-podevin](https://community.breww.com/user_avatar/community.breww.com/michael-podevin/32/1975_2.png) [@michael-podevin](https://community.breww.com/u/michael-podevin)\
**Post date:** [6 February 2025 14:28 UTC](https://community.breww.com/t/get-stock-quantity-for-given-stock-id-in-api/5544/5 "2025-02-06T14:28:54Z")

</div>

Hi Matt, I still get the same error. Thanks!

---

<div class="post-metadata">

**Author:** ![matt-cousins](https://community.breww.com/user_avatar/community.breww.com/matt-cousins/32/3876_2.png) [@matt-cousins](https://community.breww.com/u/matt-cousins)\
**Post date:** [6 February 2025 14:43 UTC](https://community.breww.com/t/get-stock-quantity-for-given-stock-id-in-api/5544/6 "2025-02-06T14:43:26Z")

</div>

Ah okay, sorry about that.

It looks like it can’t find a stock item by that id. One thing to make sure would be that you’re definitely using the API key that’s associated with the same account as the stock item. If you’ve only ever used one Breww account, then this won’t be the issue, but it would be worth double checking you’re using the right key for this account.

If that’s not the issue, please could you open a support ticket, granting access to your account, then I should be able to figure out what the issue is. If you add FAO Matt to the ticket somewhere, it will come through to me. Thanks!

---

<div class="post-metadata">

**Author:** ![michael-podevin](https://community.breww.com/user_avatar/community.breww.com/michael-podevin/32/1975_2.png) [@michael-podevin](https://community.breww.com/u/michael-podevin)\
**Post date:** [6 February 2025 15:11 UTC](https://community.breww.com/t/get-stock-quantity-for-given-stock-id-in-api/5544/7 "2025-02-06T15:11:51Z")

</div>

Hi Matt,

Both the key and the stock id have worked with other branches of the API, I’m wondering maybe that there is no documentation currently for “stock-received” the closest might be “stock-received-retrieved”, do you think this has to do with the API elements that are publicly vs internally available to you and conflicts with the key? I will open the ticket 🙂

---

<div class="post-metadata">

**Author:** ![matt-cousins](https://community.breww.com/user_avatar/community.breww.com/matt-cousins/32/3876_2.png) [@matt-cousins](https://community.breww.com/u/matt-cousins)\
**Post date:** [6 February 2025 16:20 UTC](https://community.breww.com/t/get-stock-quantity-for-given-stock-id-in-api/5544/8 "2025-02-06T16:20:19Z")

</div>

> [@michael-podevin](#):
>
> there is no documentation currently for “stock-received”

The documentation for this is under “stock-received-list”. The “retrieve” endpoints are for when you want a retrieve a single object (i.e. one batch of a stock item) and require an ID in the URL. The list endpoints are for when you want a list of objects. For stock-received this would be all batches of all stock items you have; which is why you’d add a filter for the stock item in question.

Thanks for opening the ticket, I’ll look into this for you now.
