# Stock

The stocks are fetched from the brand through integration, utilizing SKUs, locations, and stock providers. The stock object contains details about the quantity of reserved stocks for a specific SKU in the corresponding location. These reserved stocks are allocated for orders that have not yet been sent to the ERP or transitioned to the "Preparing" status.

### List Stock​ <a href="#list-stock" id="list-stock"></a>

This method is used to get a list of stock objects.

`GET` **List-Stock**

**Path:** `/api/v1/stocks/`

**Parameters​**

The following parameters can be used to get a list of stock objects.

| Parameter  | Data Type | In     | Description                                |
| ---------- | --------- | ------ | ------------------------------------------ |
| api\_token | string    | header | The API key of the customer account        |
| limit      | integer   | query  | The amount of line items returned per page |
| page       | string    | query  | The number of page returned                |

**Example Request​**

```
import requests

url = "http://localhost:8000/api/v1/stocks/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload={}
headers = {
 'Accept': 'application/json',
 'Authorization': 'Token {}'.format(api_token)
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```

**Example Response (200 OK)​**

The response includes the following parameters.

| Parameter       | Data Type | Description                        |
| --------------- | --------- | ---------------------------------- |
| id              | integer   | The primary key of the stock       |
| sku             | string    | The SKU of the product             |
| provider        | string    | The name of the provider           |
| location        | integer   | The stock location ID              |
| stock           | integer   | The number of existing stocks      |
| period          | date      | The stock period                   |
| unittype        | string    | The type of the stock unit         |
| stock\_type     | string    | The type of the stock              |
| reserved\_stock | integer   | Reserved stock count               |
| created\_date   | date      | The creation date                  |
| modified\_date  | date      | The last modified date             |
| is\_active      | boolean   | The activation status of the stock |

```
{
   "count": 3,
   "next": null,
   "previous": null,
   "results": [
       {
           "id": 2,
           "created_date": "2023-05-10T13:37:18.209869+03:00",
           "modified_date": "2023-05-10T13:37:18.210018+03:00",
           "period": null,
           "stock_type": "standard",
           "unit_type": "qty",
           "provider": "shop_provider",
           "location": "110",
           "stock": 5,
           "is_active": true,
           "sku": "555AB1300456213002",
           "reserved_stock": 0
       },
       {
           "id": 4,
           "created_date": "2023-05-10T15:14:40.733472+03:00",
           "modified_date": "2023-05-10T15:14:40.733504+03:00",
           "period": null,
           "stock_type": "standard",
           "unit_type": "qty",
           "provider": "shop_provider",
           "location": "110",
           "stock": 5,
           "is_active": true,
           "sku": "555AB1300456213003",
           "reserved_stock": 0
       },
       {
           "id": 6,
           "created_date": "2023-05-10T15:15:03.254957+03:00",
           "modified_date": "2023-05-10T15:15:03.254980+03:00",
           "period": null,
           "stock_type": "standard",
           "unit_type": "qty",
           "provider": "shop_provider",
           "location": "110",
           "stock": 5,
           "is_active": true,
           "sku": "555AB1300456213004",
           "reserved_stock": 0
       }
   ]
}
```

### Create Stock​ <a href="#create-stock" id="create-stock"></a>

This method is used to create a stock object with the request body.

`POST` **Create-Stock**

**Path:** `/api/v1/stocks/`

**Parameters​**

The following parameters can be used to create a stock object.

| Parameter  | Data Type | In     | Required | Description                                       |
| ---------- | --------- | ------ | :------: | ------------------------------------------------- |
| api\_token | string    | header |     ✓    | The API key of the customer account               |
| sku        | string    | body   |     ✓    | The SKU of the product                            |
| provider   | string    | body   |     ✓    | The name of the provider                          |
| location   | string    | body   |     ✓    | The stock location                                |
| stock      | integer   | body   |     ✓    | The number of the existing stock for this product |

**Example Request​**

```
import requests
import json

url = "https://{whippy_api_url}/api/v1/stocks/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = json.dumps({
 "period": None,
 "stock_type": "standard",
 "unit_type": "qty",
 "provider": "shop_provider",
 "location": "110",
 "stock": 5,
 "is_active": True,
 "sku": "555AB1300456213004",
 "reserved_stock": 0
})
headers = {
 'Content-Type': 'application/json',
 'Authorization': 'Token {}'.format(api_token)
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

**Example Response (201 Created)​**

The response includes the following parameters.

| Parameter       | Data Type | Description                        |
| --------------- | --------- | ---------------------------------- |
| id              | integer   | The primary key of the stock       |
| sku             | string    | The SKU of the product             |
| provider        | string    | The name of the provider           |
| location        | integer   | The stock location ID              |
| stock           | integer   | The number of existing stocks      |
| period          | date      | The stock period                   |
| unittype        | string    | The type of the stock unit         |
| stock\_type     | string    | The type of the stock              |
| reserved\_stock | integer   | Reserved stock count               |
| created\_date   | date      | The creation date                  |
| modified\_date  | date      | The last modified date             |
| is\_active      | boolean   | The activation status of the stock |

```
{
   "id": 6,
   "created_date": "2023-05-10T15:15:03.254957+03:00",
   "modified_date": "2023-05-10T15:15:03.254980+03:00",
   "period": null,
   "stock_type": "standard",
   "unit_type": "qty",
   "provider": "shop_provider",
   "location": "110",
   "stock": 5,
   "is_active": true,
   "sku": "555AB1300456213004",
   "reserved_stock": 0
}
```

**Example Response (400 Bad Request)​**

```
{
   "stock_exists_error": "Stock already exists."
}
—-------
{
   "provider": [
       "This field is required."
   ],
   "location": [
       "This field is required."
   ],
   "stock": [
       "This field is required."
   ],
   "sku": [
       "This field is required."
   ]
}
---
{
   "invalid_location": "Location does not belong to provider."
}
```

### Search Stocks​ <a href="#search-stocks" id="search-stocks"></a>

This method is used to search stock objects with the specified filters.

`GET` **Search-Stocks**

**Path:** `/api/v1/stocks/?sku=&lt;string>&stock__gt=&lt;number>&stock__gte=&lt;number>&stock__lt=&lt;number>&stock__lte=&lt;number>&stock=&lt;number>&reserved_stock__gt=&lt;number>&reserved_stock__gte=&lt;number>&reserved_stock__lt=&lt;number>&reserved_stock__lte=&lt;number>&reserved_stock=&lt;number>&created_date__gt=&lt;string>&created_date__gte=&lt;string>&created_date__lt=&lt;string>&created_date__lte=&lt;string>&created_date=&lt;string>&modified_date__gt=&lt;string>&modified_date__gte=&lt;string>&modified_date__lt=&lt;string>&modified_date__lte=&lt;string>&modified_date=&lt;string>&is_active=&lt;string>&location=&lt;string>&provider=&lt;string>&location_name=&lt;string>&provider_name=&lt;string>&period=&lt;string>&unit_type=&lt;string>&stock_type=&lt;string>&sort=&lt;string>&page=&lt;integer>&limit=&lt;integer>`

**Filters​**

The following parameters can be used to filter GET request results.

| Parameter            | Data Type | In     | Description                         |
| -------------------- | --------- | ------ | ----------------------------------- |
| api\_token           | string    | header | The API key of the customer account |
| location             | string    | query  | The code of the stock location      |
| location\_name       | string    | query  | The name of the stock location      |
| provider             | string    | query  | The stock provider ID               |
| provider\_name       | string    | query  | The name of the provider            |
| is\_active           | boolean   | query  | The activation status of the stock  |
| created\_date        | date      | query  | The creation date                   |
| modified\_date       | date      | query  | The last modified date              |
| modified\_date\_\_gt | date      | query  | After that date                     |
| unit\_type           | string    | query  | "quantity", "kilogram"              |
| stock\_type          | string    | query  | "standard", "scheduled"             |
| stock\_\_gt          | integer   | query  | Minimum stock count                 |

The following filters can be applied via the request URL.

```
"filters": {
       "sku": {
           "type": "CharFilter",
           "lookup_types": [
               "exact"
           ]
       },
       "stock": {
           "type": "NumberFilter",
           "lookup_types": [
               "gt",
               "gte",
               "lt",
               "lte",
               "exact"
           ]
       },
       "reserved_stock": {
           "type": "NumberFilter",
           "lookup_types": [
               "gt",
               "gte",
               "lt",
               "lte",
               "exact"
           ]
       },
       "created_date": {
           "type": "IsoDateTimeFilter",
           "lookup_types": [
               "gt",
               "gte",
               "lt",
               "lte",
               "exact"
           ]
       },
       "modified_date": {
           "type": "IsoDateTimeFilter",
           "lookup_types": [
               "gt",
               "gte",
               "lt",
               "lte",
               "exact"
           ]
       },
       "is_active": {
           "type": "BooleanFilter",
           "lookup_types": [
               "exact"
           ]
       },
       "period": {
           "type": "IsoDateTimeFilter",
           "lookup_types": [
               "startswith__gte",
               "startswith__lte",
               "endswith__gte",
               "endswith__lte"
           ]
       },
       "location": {
           "type": "CharFilter",
           "lookup_types": [
               "exact"
           ]
       },
       "provider": {
           "type": "CharFilter",
           "lookup_types": [
               "exact"
           ]
       },
       "location_name": {
           "type": "CharFilter",
           "lookup_types": [
               "icontains"
           ]
       },
       "provider_name": {
           "type": "CharFilter",
           "lookup_types": [
               "icontains"
           ]
       },
       "unit_type": {
           "type": "ChoiceFilter",
           "lookup_types": [
               "exact"
           ]
       },
       "stock_type": {
           "type": "ChoiceFilter",
           "lookup_types": [
               "exact"
           ]
       }
   }
```

**Example Request​**

```
import requests

url = "https://{whippy_api_url}/api/v1/stocks/?sku=<string>&stock__gt=<number>&stock__gte=<number>&stock__lt=<number>&stock__lte=<number>&stock=<number>&reserved_stock__gt=<number>&reserved_stock__gte=<number>&reserved_stock__lt=<number>&reserved_stock__lte=<number>&reserved_stock=<number>&created_date__gt=<string>&created_date__gte=<string>&created_date__lt=<string>&created_date__lte=<string>&created_date=<string>&modified_date__gt=<string>&modified_date__gte=<string>&modified_date__lt=<string>&modified_date__lte=<string>&modified_date=<string>&is_active=<string>&location=<string>&provider=<string>&location_name=<string>&provider_name=<string>&period=<string>&unit_type=<string>&stock_type=<string>&sort=<string>&page=<integer>&limit=<integer>"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload={}
headers = {
 'Accept': 'application/json',
 'Authorization': 'Token {}'.format(api_token),
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```

**Example Response (200 OK)​**

The response includes the following parameters.

| Parameter       | Data Type | Description                        |
| --------------- | --------- | ---------------------------------- |
| id              | integer   | The primary key of the stock       |
| sku             | string    | The SKU of the product             |
| provider        | string    | The name of the provider           |
| location        | integer   | The stock location ID              |
| stock           | integer   | The number of existing stocks      |
| period          | date      | The stock period                   |
| unittype        | string    | The type of the stock unit         |
| stock\_type     | string    | The type of the stock              |
| reserved\_stock | integer   | Reserved stock count               |
| created\_date   | date      | The creation date                  |
| modified\_date  | date      | The last modified date             |
| is\_active      | boolean   | The activation status of the stock |

```
{
   "count": 3,
   "next": null,
   "previous": null,
   "results": [
       {
           "id": 2,
           "created_date": "2023-05-10T13:37:18.209869+03:00",
           "modified_date": "2023-05-10T13:37:18.210018+03:00",
           "period": null,
           "stock_type": "standard",
           "unit_type": "qty",
           "provider": "shop_provider",
           "location": "110",
           "stock": 5,
           "is_active": true,
           "sku": "555AB1300456213002",
           "reserved_stock": 0
       },
       {
           "id": 4,
           "created_date": "2023-05-10T15:14:40.733472+03:00",
           "modified_date": "2023-05-10T15:14:40.733504+03:00",
           "period": null,
           "stock_type": "standard",
           "unit_type": "qty",
           "provider": "shop_provider",
           "location": "110",
           "stock": 5,
           "is_active": true,
           "sku": "555AB1300456213003",
           "reserved_stock": 0
       },
       {
           "id": 6,
           "created_date": "2023-05-10T15:15:03.254957+03:00",
           "modified_date": "2023-05-10T15:15:03.254980+03:00",
           "period": null,
           "stock_type": "standard",
           "unit_type": "qty",
           "provider": "shop_provider",
           "location": "110",
           "stock": 5,
           "is_active": true,
           "sku": "555AB1300456213004",
           "reserved_stock": 0
       }
   ]
}
```

### Increase Reserved Stock​ <a href="#increase-reserved-stock" id="increase-reserved-stock"></a>

This method is used to increase the reserved stock for the specified SKU, location and provider.

`POST` **Increase-Reserved-Stock**

**Path:** `/api/v1/stocks/increase_reserved_stock/`

**Parameters​**

The following parameters can be used to increase reserved stock.

| Parameter  | Data Type | In     | Required | Description                         |
| ---------- | --------- | ------ | :------: | ----------------------------------- |
| api\_token | string    | header |     ✓    | The API key of the customer account |
| sku        | string    | query  |     ✓    | The SKU of the product              |
| location   | string    | query  |     ✓    | The ID of the location              |
| provider   | string    | query  |          | The ID of the provider              |
| date       | date      | query  |          | The creation date of the stock      |

**Example Request​**

```
import requests
import json

url = "https://{whippy_api_url}/api/v1/stocks/increase_reserved_stock/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = json.dumps({
 "sku": "555AB1300456213004",
 "location": "110"
})
headers = {
 'Content-Type': 'application/json',
 'Authorization': 'Token {}'.format(api_token)
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

**Example Response (201 Created)​**

The response includes the following parameters.

| Parameter       | Data Type | Description                        |
| --------------- | --------- | ---------------------------------- |
| id              | integer   | The primary key of the stock       |
| sku             | string    | The SKU of the product             |
| provider        | string    | The name of the provider           |
| location        | integer   | The stock location ID              |
| stock           | integer   | The number of existing stocks      |
| period          | date      | The stock period                   |
| unittype        | string    | The type of the stock unit         |
| stock\_type     | string    | The type of the stock              |
| reserved\_stock | integer   | Reserved stock count               |
| created\_date   | date      | The creation date                  |
| modified\_date  | date      | The last modified date             |
| is\_active      | boolean   | The activation status of the stock |

```
{
   "id": 6,
   "created_date": "2023-05-10T15:15:03.254957+03:00",
   "modified_date": "2023-05-10T17:16:02.653646+03:00",
   "period": null,
   "stock_type": "standard",
   "unit_type": "qty",
   "provider": "shop_provider",
   "location": "110",
   "stock": 5,
   "is_active": true,
   "sku": "555AB1300456213004",
   "reserved_stock": 1
}
```

**Example Response (400 Bad Request - 208 Already Reported)​**

```
HTTP 400
{
   "sku": [
       "This field is required."
   ],
   "location": [
       "This field is required."
   ]
}

HTTP 208
{
   "message": "Already reported"
}
```

### Decrease Reserved Stock​ <a href="#decrease-reserved-stock" id="decrease-reserved-stock"></a>

This method is used to decrease the reserved stock for the specified SKU, location and provider.

`POST` **Decrease-Reserved-Stock**

**Path:** `/api/v1/stocks/decrease_reserved_stock/`

**Parameters​**

The following parameters can be used to decrease reserved stock.

| Parameter  | Data Type | In     | Required | Description                         |
| ---------- | --------- | ------ | :------: | ----------------------------------- |
| api\_token | string    | header |     ✓    | The API key of the customer account |
| sku        | string    | query  |     ✓    | The SKU of the product              |
| location   | string    | query  |     ✓    | The ID of the location              |
| provider   | string    | query  |          | The ID of the provider              |
| date       | date      | query  |          | The creation date of the stock      |

**Example Request​**

```
import requests
import json

url = "https://{whippy_api_url}/api/v1/stocks/decrease_reserved_stock/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = json.dumps({
 "sku": "555AB1300456213004",
 "location": "110"
})
headers = {
 'Content-Type': 'application/json',
 'Authorization': 'Token {}'.format(api_token)
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

**Example Response (201 Created)​**

The response includes the following parameters.

| Parameter       | Data Type | Description                           |
| --------------- | --------- | ------------------------------------- |
| id              | integer   | The primary key of the stock location |
| sku             | string    | The SKU of the product                |
| provider        | string    | The name of the provider              |
| location        | integer   | The stock location ID                 |
| stock           | integer   | The number of existing stocks         |
| period          | date      | The stock period                      |
| unittype        | string    | The type of the stock unit            |
| stock\_type     | string    | The type of the stock                 |
| reserved\_stock | integer   | Reserved stock count                  |
| created\_date   | date      | The creation date                     |
| modified\_date  | date      | The last modified date                |
| is\_active      | boolean   | The activation status of the stock    |

```
{
   "id": 6,
   "created_date": "2023-05-10T15:15:03.254957+03:00",
   "modified_date": "2023-05-10T17:55:05.904288+03:00",
   "period": null,
   "stock_type": "standard",
   "unit_type": "qty",
   "provider": "shop_provider",
   "location": "110",
   "stock": 3,
   "is_active": true,
   "sku": "555AB1300456213004",
   "reserved_stock": 10
}
```

**Example Response (400 Bad Request - 208 Already Reported)​**

```
HTTP 400
{
   "sku": [
       "This field is required."
   ],
   "location": [
       "This field is required."
   ]
}

HTTP 208
{
   "message": "Already reported"
}
```

### Stock Query​ <a href="#stock-query" id="stock-query"></a>

This method is used to query stock.

`GET` **Stock-Query**

**Path:** `/api/v1/stocks/stock_query/`

**Parameters​**

The following parameters can be used to query stock.

| Parameter  | Data Type | In     | Required | Description                         |
| ---------- | --------- | ------ | :------: | ----------------------------------- |
| api\_token | string    | header |     ✓    | The API key of the customer account |
| sku        | string    | query  |     ✓    | The SKU of the product              |

**Example Request​**

```
import requests
import json

url = "https://{whippy_api_url}/api/v1/stocks/stock_query/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = json.dumps({
 'sku': '500'
})

headers = {
 'Accept': 'application/json',
 'Authorization': 'Token {}'.format(api_token),
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```

**Example Response (200 OK)​**

The response includes the following parameters.

| Parameter           | Data Type | Description                      |
| ------------------- | --------- | -------------------------------- |
| sku                 | string    | The SKU of the product           |
| retail\_store\_code | string    | The code of the retail store     |
| retail\_store\_name | string    | The name of the retail store     |
| stock               | integer   | The number of the existing stock |

```
{ 
"Store_checkResult": [ 
  { 
   "sku": "500", 
   "retail_store_code": "110", 
   "retail_store_name": "110", 
   "stock": 5 
  }, 
  { 
   "sku": "500", 
   "retail_store_code": "112", 
   "retail_store_name": "112", 
   "stock": 5 
  }, 
  { 
   "sku": "500", 
   "retail_store_code": "115", 
   "retail_store_name": "115", 
   "stock": 5 
  }, 
  { 
   "sku": "500", 
   "retail_store_code": "117", 
   "retail_store_name": "117", 
   "stock": 5 
  }, 
  { 
   "sku": "500", 
   "retail_store_code": "119", 
   "retail_store_name": "119", 
   "stock": 5 
  } 
 ] 
}
```

### Multi Stock Query​ <a href="#multi-stock-query" id="multi-stock-query"></a>

This method is used to query multiple stock.

`GET` **Multi-Stock-Query**

**Path:** `/api/v1/stocks/multi_stock_query/`

**Parameters​**

The following parameters can be used to query multiple stock.

| Parameter  | Data Type | In     | Required | Description                         |
| ---------- | --------- | ------ | :------: | ----------------------------------- |
| api\_token | string    | header |     ✓    | The API key of the customer account |
| sku        | string    | query  |     ✓    | The SKU of the product              |

**Example Request​**

```
import requests
import json

url = "https://{whippy_api_url}/api/v1/stocks/multi_stock_query/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = json.dumps({
 'sku': ['500','505']
})

headers = {
 'Accept': 'application/json',
 'Authorization': 'Token {}'.format(api_token),
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

import requests
import json

url = "https://{whippy_api_url}/api/v1/stocks/multi_stock_query/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = json.dumps({
 'sku': ['500','505']
})

headers = {
 'Accept': 'application/json',
 'Authorization': 'Token {}'.format(api_token),
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```

**Example Response (200 OK)​**

The response includes the following parameters.

| Parameter           | Data Type | Description                      |
| ------------------- | --------- | -------------------------------- |
| sku                 | string    | The SKU of the product           |
| retail\_store\_code | string    | The code of the retail store     |
| retail\_store\_name | string    | The name of the retail store     |
| stock               | integer   | The number of the existing stock |

```
{ 
  "Store_checkResult": { 
    "500": [ 
      { 
        "sku": "500", 
        "retail_store_code": "110", 
        "retail_store_name": "110", 
        "stock": 5 
      }, 
      { 
        "sku": "500", 
        "retail_store_code": "112", 
        "retail_store_name": "112", 
        "stock": 5 
      }, 
      { 
        "sku": "500", 
        "retail_store_code": "117", 
        "retail_store_name": "117", 
        "stock": 5 
      } 
    ], 
  "505": [ 
      { 
        "sku": "505", 
        "retail_store_code": "110", 
        "retail_store_name": "110", 
        "stock": 3 
      }, 
      { 
        "sku": "505", 
        "retail_store_code": "112", 
        "retail_store_name": "112", 
        "stock": 3 
      }, 
      { 
        "sku": "505", 
        "retail_store_code": "115", 
        "retail_store_name": "115", 
        "stock": 3 
      } 
}  ] 
} 
```

### Multi Salable Stock Query​ <a href="#multi-salable-stock-query" id="multi-salable-stock-query"></a>

This method is used to query multiple salable stock.

`GET` **Multi-Salable Stock-Query**

**Path:** `/api/v1/stocks/multi_salable_stock_query/`

**Parameters​**

The following parameters can be used to query multiple salable stock.

| Parameter  | Data Type | In     | Required | Description                         |
| ---------- | --------- | ------ | :------: | ----------------------------------- |
| api\_token | string    | header |     ✓    | The API key of the customer account |
| sku        | string    | query  |     ✓    | The SKU of the product              |

**Example Request​**

```
import requests
import json

url = "https://{whippy_api_url}/api/v1/stocks/multi_salable_stock_query/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = json.dumps({
 'sku': ['500','505']
})

headers = {
 'Accept': 'application/json',
 'Authorization': 'Token {}'.format(api_token),
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```

**Example Response (200 OK)​**

The response includes the following parameters.

| Parameter           | Data Type | Description                      |
| ------------------- | --------- | -------------------------------- |
| sku                 | string    | The SKU of the product           |
| retail\_store\_code | string    | The code of the retail store     |
| retail\_store\_name | string    | The name of the retail store     |
| stock               | integer   | The number of the existing stock |

```
{ 
  "Store_checkResult": { 
    "500": [ 
      { 
        "sku": "500", 
        "retail_store_code": "110", 
        "retail_store_name": "110", 
        "stock": 5 
      }, 
      { 
        "sku": "500", 
        "retail_store_code": "112", 
        "retail_store_name": "112", 
        "stock": 5 
      }, 
      { 
        "sku": "500", 
        "retail_store_code": "117", 
        "retail_store_name": "117", 
        "stock": 5 
      } 
    ], 
    "505": [ 
      { 
        "sku": "505", 
        "retail_store_code": "110", 
        "retail_store_name": "110", 
        "stock": 3 
      }, 
      { 
        "sku": "505", 
        "retail_store_code": "112", 
        "retail_store_name": "112", 
        "stock": 3 
      }, 
      { 
        "sku": "505", 
        "retail_store_code": "115", 
        "retail_store_name": "115", 
        "stock": 3 
      } 
    ] 
  } 
}
```

### Salable Stock Query​ <a href="#salable-stock-query" id="salable-stock-query"></a>

This method is used to query salable stock.

`GET` **Salable Stock-Query**

**Path:** `api/v1/stocks/salable_stock_query/`

**Parameters​**

The following parameters can be used to query salable stock.

| Parameter  | Data Type | In     | Required | Description                         |
| ---------- | --------- | ------ | :------: | ----------------------------------- |
| api\_token | string    | header |     ✓    | The API key of the customer account |
| sku        | string    | query  |     ✓    | The SKU of the product              |

**Example Request​**

```
import requests
import json

url = "https://{whippy_api_url}/api/v1/stocks/salable_stock_query/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = json.dumps({
 'sku': '500'
})

headers = {
 'Accept': 'application/json',
 'Authorization': 'Token {}'.format(api_token),
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```

**Example Response (200 OK)​**

The response includes the following parameters.

| Parameter           | Data Type | Description                      |
| ------------------- | --------- | -------------------------------- |
| sku                 | string    | The SKU of the product           |
| retail\_store\_code | string    | The code of the retail store     |
| retail\_store\_name | string    | The name of the retail store     |
| stock               | integer   | The number of the existing stock |

```
{ 
  "Store_checkResult": [ 
    { 
      "sku": "500", 
      "retail_store_code": "110", 
      "retail_store_name": "110", 
      "stock": 5 
    }, 
    { 
      "sku": "500", 
      "retail_store_code": "112", 
      "retail_store_name": "112", 
      "stock": 5 
    }, 
    { 
      "sku": "500", 
      "retail_store_code": "115", 
      "retail_store_name": "115", 
      "stock": 5 
    }, 
    { 
      "sku": "500", 
      "retail_store_code": "117", 
      "retail_store_name": "117", 
      "stock": 5 
    }, 
    { 
      "sku": "500", 
      "retail_store_code": "119", 
      "retail_store_name": "119", 
      "stock": 5 
    } 
  ] 
}
```

### Insert/Update Single/Multiple Stock​ <a href="#insertupdate-singlemultiple-stock" id="insertupdate-singlemultiple-stock"></a>

This method is used to upsert single or multiple stock.

`POST` **Single-or-Multiple-Stock-Upsert**

**Path:** `/api/v1/stocks/insert_or_update_stock/`

**Parameters​**

The following parameters can be used to upsert single or multiple stock.

| Parameter  | Data Type | In     | Required | Description                                       |
| ---------- | --------- | ------ | :------: | ------------------------------------------------- |
| api\_token | string    | header |     ✓    | The API key of the customer account               |
| sku        | string    | body   |     ✓    | The SKU of the product                            |
| provider   | string    | body   |     ✓    | The name of the provider                          |
| location   | string    | body   |     ✓    | The stock location                                |
| stock      | integer   | body   |     ✓    | The number of the existing stock for this product |

**Example Request​**

```
import requests
import json

url = "https://{whippy_api_url}/api/v1/stocks/insert_or_update_stock/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = json.dumps([
{
    "provider": "shop_provider",
    "location": "stock_loc_1",
    "stock": 5,
    "sku": "500"
},
{
    "provider": "shop_provider",
    "location": "stock_loc_1",
    "stock": 5,
    "sku": "520"
},
{
    "provider": "shop_provider",
    "location": "stock_loc_1",
    "stock": 5,
    "sku": "540"
},
{
    "provider": "shop_provider",
    "location": "stock_loc_1",
    "stock": 5,
    "sku": "560"
])

headers = {
 'Accept': 'application/json',
 'Authorization': 'Token {}'.format(api_token),
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```

**Example Response (200 OK)​**&#x20;

```
{ 
    "Store_checkResult": {} 
}
```

### List Active Stock​ <a href="#list-active-stock" id="list-active-stock"></a>

This methods are used to get a list of single or multiple active stock.

#### List Single Active Stock​ <a href="#list-single-active-stock" id="list-single-active-stock"></a>

This methods are used to get a list of single active stock.

`GET` **List-Single-Active-Stock**

**Path:** `/api/v1/active-stocks/{stocklist_id}/`

**Parameters​**

The following parameters can be used to get a list of single active stock.

| Parameter       | Data Type | In          | Required | Description                                                                    |
| --------------- | --------- | ----------- | :------: | ------------------------------------------------------------------------------ |
| api\_token      | string    | header      |     ✓    | The API key of the customer account                                            |
| {stocklist\_id} | string    | query       |     ✓    | The ID of the stock list (also referred to as the stock list code in Omnitron) |
| sku             | string    | query param |     ✓    | The SKU of the product                                                         |

**Example Request​**

```
import requests
import json

url = "https://{whippy_api_url}/api/v1/active-stocks/{stocklist_id}/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = json.dumps({
 "sku": "500"
})

headers = {
 'Accept': 'application/json',
 'Authorization': 'Token {}'.format(api_token),
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

**Example Response (200 OK)​**

The response includes the following parameters.

| Parameter | Data Type | Description                      |
| --------- | --------- | -------------------------------- |
| sku       | string    | The SKU of the product           |
| stock     | integer   | The number of the existing stock |

```
{ 
    "next": "https://{whippy_api_url}/api/v1/active-stocks/1/?page=2",
    "previous": null, 
    "results": [ 
        { 
            "sku": "100", 
            "stock": 5, 
            "extra_field": {
                "locations": null
            }
        }, 
        { 
            "sku": "300", 
            "stock": 5,
            "extra_field": {
                "locations": null
            }
        }, 
        { 
            "sku": "500", 
            "stock": 5,
            "extra_field": {
                "locations": null
            } 
         } 
    ] 
}
```

#### List Multiple Active Stock​ <a href="#list-multiple-active-stock" id="list-multiple-active-stock"></a>

This methods are used to get a list of multiple active stock.

`POST` **List-Multiple-Active-Stock**

**Path:** `/api/v1/stocks/{stocklist_id}/`

**Parameters​**

The following parameters can be used to get a list of multiple active stock.

| Parameter       | Data Type | In     | Required | Description                                                                    |
| --------------- | --------- | ------ | :------: | ------------------------------------------------------------------------------ |
| api\_token      | string    | header |     ✓    | The API key of the customer account                                            |
| {stocklist\_id} | string    | query  |     ✓    | The ID of the stock list (also referred to as the stock list code in Omnitron) |

**Example Request​**

```
import requests
import json

url = "https://{whippy_api_url}/api/v1/active-stocks/{stocklist_id}/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
 'Accept': 'application/json',
 'Authorization': 'Token {}'.format(api_token),
}

response = requests.request("POST", url, headers=headers)

print(response.text)
```

**Example Response (200 OK)​**

The response includes the following parameters.

| Parameter | Data Type | Description                      |
| --------- | --------- | -------------------------------- |
| sku       | string    | The SKU of the product           |
| stock     | integer   | The number of the existing stock |

```
{ 
    "next": "https://{whippy_api_url}/api/v1/active-stocks/1/?page=2",
    "previous": null, 
    "results": [ 
        { 
            "sku": "100", 
            "stock": 5, 
        }, 
        { 
            "sku": "300", 
            "stock": 5, 
        }, 
        { 
            "sku": "500", 
            "stock": 5, 
         } 
    ] 
}
```
