# Check stock

The **Check stock API endpoint** receives an SKU parameter for a particular product. The SKU can be found in the Shopify variant `sku` attribute.

In return, DotApparel will respond with a list of inventory locations, identified by their Apparel21 store ID, and the current stock level for each location. This data should be matched with the enriched store data stored elsewhere, and displayed to the customer.

### 1. Make a request <a href="#id-2.-make-a-request" id="id-2.-make-a-request"></a>

Make a <mark style="color:blue;">`GET`</mark> request to `/apps/dotapparel/api-checkStock?sku=` from the frontend of your Shopify store. This uses the [Shopify app proxy](https://shopify.dev/apps/online-store/app-proxies) to pass the request through to the DotApparel backend for calculation.

For example, if the Shopify sku is `9328088450762`, you can make a <mark style="color:blue;">`GET`</mark> request to `/apps/dotapparel/api-checkStock?sku=9328088450762`

{% hint style="info" %}
The proxy URL path <mark style="color:blue;">`/apps/dotapparel`</mark> could be different depending on the specific setup of the Shopify app proxy. It is important to take into account that certain earlier versions of DotApparel might require using an alternative URL path, <mark style="color:blue;">`/apps/dotapparel21`</mark>. In this case, the example request URL will be <mark style="color:blue;">`/apps/dotapparel21/api-checkStock?sku=9328088450762`</mark>
{% endhint %}

### 2. Parse the response <a href="#id-3.-parse-the-response" id="id-3.-parse-the-response"></a>

The response will look like the example below.

Each entry in the `data` array corresponds to a store in which that product is stocked. If a store is missing, it means that the item is not currently stocked at that location.

The `storeId` and `storeNumber` attributes are taken directly from Apparel21. The `storeId` is a unique ID that Apparel21 assigns to the store, which makes be different between Apparel21 instances. The `storeNumber` attribute is manually entered by your administrator when setting up stores. Therefore, we recommend using `storeNumber` to identify stores.

```javascript
// GET /apps/dotapparel/api-checkStock?sku=9328088450762

// Or GET /apps/dotapparel21/api-checkStock?sku=9328088450762

{
  "data": [
    {
      "type": "inventoryLevel",
      "id": "5226-9328088450762",
      "attributes": {
        "sku": "9328088450762",
        "storeName": "High Street",
        "storeId": 5226,
        "storeNumber": 204,
        "freeStock": 1
      }
    }
  ]
}
```
