# Retrieve stock and price of an item

**URL:** <https://developer.squareup.com/forums/t/retrieve-stock-and-price-of-an-item/8756>\
**Category:** Questions\
**Tags:** inventory-api, catalog-api\
**Created:** [March 3, 2023, 8:53pm UTC](https://developer.squareup.com/forums/t/retrieve-stock-and-price-of-an-item/8756 "2023-03-03T20:53:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![axme](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@axme](https://developer.squareup.com/forums/u/axme)\
**Post date:** [March 3, 2023, 8:53pm UTC](https://developer.squareup.com/forums/t/retrieve-stock-and-price-of-an-item/8756/1 "2023-03-03T20:53:16Z")

</div>

Hello,

I have a system where a user places an order for one item (e.g. coffee).  
Once they place an order I want to show them some other things they can add to their order like pastries, sandwiches,…

What would be the process to retrieve the items available at the location where they placed their order?  
Is the below correct or is there a better/more efficient way to do this?

Here’s what I understand, but I’d appreciate your feedback:

1. I need to select which item IDs I want to retrieve: [/v2/inventory/counts/batch-retrieve](https://developer.squareup.com/reference/square/catalog/batch-retrieve-catalog-objects) → this gives me the price of those items.

2. Then I retrieve the inventory to see if these items are available at the specified location [/v2/inventory/counts/batch-retrieve](https://developer.squareup.com/reference/square/inventory/batch-retrieve-inventory-counts)

3. Once a user clicked on an item, I then [update the order](https://developer.squareup.com/reference/square_2023-01-19/orders/update-order) to add that item and increase the version of that order with +1 → This allows me to send the new item ordered quickly to the store and as the user selects more items, the order gets updated. Is this best practice or should I wait a few seconds, then send that order to the shop?

Thank you very much 🙂

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [March 3, 2023, 9:09pm UTC](https://developer.squareup.com/forums/t/retrieve-stock-and-price-of-an-item/8756/2 "2023-03-03T21:09:20Z")

</div>

Yes, that’s the way to bring in items. Also you can call [ListCatalog](https://developer.squareup.com/reference/square/catalog-api/list-catalog) with the parameter set to `ITEMS` which will return the items from the seller. That way you won’t have to manage or store the `catalog_object_ids`. 🙂

---

<div class="post-metadata">

**Author:** ![axme](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@axme](https://developer.squareup.com/forums/u/axme)\
**Post date:** [May 12, 2023, 9:10pm UTC](https://developer.squareup.com/forums/t/retrieve-stock-and-price-of-an-item/8756/3 "2023-05-12T21:10:26Z")

</div>

Hi @Bryan-Square 🙂

I’m using the [Batch retrieve catalog objects](https://developer.squareup.com/explorer/square/catalog-api/batch-retrieve-catalog-objects) and get this flow for one item:

1. I get this

```auto
{
      "type": "ITEM",
      "id": "LECXFQVZNYRDKHHVFJW6JM5Z",
      "updated_at": "2023-04-15T12:02:02.421Z",
      "created_at": "2020-12-08T00:10:07.813Z",
      "version": 1681560122421,
      "is_deleted": false,
      "present_at_all_locations": false,
      "present_at_location_ids": [
        "L39XB0RHPF2V2",
        "L6ZN306P4SCQN",
        "L9TJVT3GX4345",
        "LANJ0SS9RADJG",
        "LRG6B9M9H9B8T",
        "LX985242330VF"
      ],
      "item_data": {
        "name": "Chocolate Croissant",
        "description": "Croissant rolled around dark chocolate.\n**Contains: Wheat, milk, egg, soy.",
        "is_taxable": true,
        "visibility": "PRIVATE",
        "category_id": "TI7K5O5MTSKHTO57VMV5LTWK",
        "tax_ids": [
          "LLYAYTAKDTC4KOJLQB7UPLXK",
          "XK5BQPHV2VMCZZEXCXTN3YOD",
          "ABZRNMSICBEM3Y2KMRT6TPTH",
          "SZ44VR4TQW4W7KDO5EFQ3TE2",
          "2QGBXQ3E7MEDTM3EQGQN74ET"
        ],
        "variations": [
          {
            "type": "ITEM_VARIATION",
            "id": "HQBSTODZLSVRAWCJ7YOEFKA5",
            "updated_at": "2023-04-15T12:02:02.421Z",
            "created_at": "2020-12-08T00:10:07.813Z",
            "version": 1681560122421,
            "is_deleted": false,
            "present_at_all_locations": false,
            "present_at_location_ids": [
              "LANJ0SS9RADJG",
              "L9TJVT3GX4345",
              "LX985242330VF",
              "L6ZN306P4SCQN",
              "L39XB0RHPF2V2",
              "LRG6B9M9H9B8T"
            ],
            "item_variation_data": {
              "item_id": "LECXFQVZNYRDKHHVFJW6JM5Z",
              "name": "",
              "ordinal": 1,
              "pricing_type": "FIXED_PRICING",
              "price_money": {
                "amount": 410,
                "currency": "USD"
              },
              "sellable": true,
              "stockable": true
            }
          }
        ],
        "product_type": "REGULAR",
        "skip_modifier_screen": true,
        "ecom_available": false,
        "ecom_visibility": "UNINDEXED",
        "image_ids": [
          "5SDXF66VCH6OBRAVGQGAOMFD"
        ],
        "pickup_fulfillment_preferences_id": "fprefs_127dix14aj4vy7qqx5kp4oit1",
        "description_html": "<p>Croissant rolled around dark chocolate.</p><p>**Contains: Wheat, milk, egg, soy.</p>",
        "description_plaintext": "Croissant rolled around dark chocolate.\n**Contains: Wheat, milk, egg, soy."
      }
    },

```

1. then I call [Batch retrieve inventory counts](https://developer.squareup.com/explorer/square/inventory-api/batch-retrieve-inventory-counts)  
and if I type the ITEM id i get this error:

```auto
{
  "errors": [
    {
      "category": "INVALID_REQUEST_ERROR",
      "code": "INVALID_VALUE",
      "detail": "Variation with ID=LECXFQVZNYRDKHHVFJW6JM5Z must have type ITEM_VARIATION, got ITEM.",
      "field": "type"
    }
  ]
}

```

1. So I type the ITEM\_VARIATION and get a 200, but it’s empty. How can I know how many units there are in stock if the result of the API call is empty?

 ![Screenshot 2023-05-12 at 5.09.14 PM](https://global.discourse-cdn.com/square/original/2X/c/cf112df4b4b5a5f7828f246714b33f081740a651.png)

thank you

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [May 12, 2023, 9:18pm UTC](https://developer.squareup.com/forums/t/retrieve-stock-and-price-of-an-item/8756/4 "2023-05-12T21:18:09Z")

</div>

You’ll need to use the `item_variation_id` when calling the Inventory API. If you use `HQBSTODZLSVRAWCJ7YOEFKA5` it’ll work. 🙂

---

<div class="post-metadata">

**Author:** ![axme](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@axme](https://developer.squareup.com/forums/u/axme)\
**Post date:** [May 14, 2023, 11:00pm UTC](https://developer.squareup.com/forums/t/retrieve-stock-and-price-of-an-item/8756/5 "2023-05-14T23:00:11Z")

</div>

I don’t find the variable item\_variation\_id when calling [Batch retrieve catalog objects](https://developer.squareup.com/explorer/square/catalog-api/batch-retrieve-catalog-objects) or when calling [List Catalog](https://developer.squareup.com/explorer/square/catalog-api/list-catalog).

And when I use HQBSTODZLSVRAWCJ7YOEFKA5 it also returns an empty result. Am I using the right API call?

 ![Screenshot 2023-05-14 at 6.59.00 PM](https://global.discourse-cdn.com/square/original/2X/9/915e9a87cc9319054e6d716dd4209bdb027b9eb9.jpeg)

Request

```auto
curl https://connect.squareup.com/v2/inventory/counts/batch-retrieve \
  -X POST \
  -H 'Square-Version: 2023-04-19' \
  -H 'Authorization: Bearer REMOVED' \
  -H 'Content-Type: application/json' \
  -d '{
    "catalog_object_ids": [
      "HQBSTODZLSVRAWCJ7YOEFKA5"
    ],
    "location_ids": [
      "LANJ0SS9RADJG"
    ],
    "states": [
      "IN_STOCK"
    ],
    "updated_after": "2023-05-11T01:14:36.022Z"
  }'

```

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [May 15, 2023, 4:49pm UTC](https://developer.squareup.com/forums/t/retrieve-stock-and-price-of-an-item/8756/6 "2023-05-15T16:49:31Z")

</div>

Looking at that item I’m not seeing any inventory which would explain why the results are empty. 🙂
