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/
trying to follow this webpage:
https://breww.com/api/schema/elements/#/operations/stock_received_list
Thanks!
The batch code is the found by going to the “Stock” tab on a stock item, see below.
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).
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.
Hi Matt,
Thanks so much. Is the “XYZ” below
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
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!
Ah sorry, I think that’s because it needs to be https, 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.
Hi Matt, I still get the same error. Thanks!
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!
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 
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.