Stock API
Use the stock API to extract price and stock information related to products (or variants), or to update data (stock, current price, or old price) of existing products (or variants).
Product data extraction (or variant)
Modification of product information (or variant)
Fields available
The list below indicates all the fields available for this API, which are returned when you extract an individual list or resource, which can be modified, which are mandatory when creating a new resource or updating an existing resource.
Field | Type | Description | List | Optional |
---|---|---|---|---|
id | int | The product id | ✔ | ✔ |
sku | string | Product SKU code | ✔ | ✔ |
ean | string | Product EAN code | ✔ | ✔ |
inventory_enabled | string | Enabling the product inventory function (default off) | ✔ | ✔ |
stock | int | Quantity in stock | ✔ | ✔ |
warehouses | array | Inventory distribution by warehouses (Multi Warehouse application installed) | ✔ | |
price_net | float | Net price | ✔ | ✔ |
price_gross | float | Price with taxes included | ✔ | ✔ |
old_price_net | float | Unreduced old price of the product | ✔ | ✔ |
old_price_gross | float | Old unreduced product price (taxes included) | ✔ | ✔ |
TIP
Any field that is returned and is not documented can be ignored because it is not yet available.
Product data extraction (or variant)
It displays the data of a single record based on ID, SKU code or EAN code.
Type : Individual resource
Method : GET
Url :/api/v2/inventory/{type}/{identifier}
The http response code is 200
in case of success, the response will have the form of an individual resource related to the requested id. In the case of SKU type identifiers, their value must be encoded in the URL.
Request format
Example of a CURL request that returns an individual record:
curl --request GET \
--url 'https://shop.demo.ro/api/v2/inventory/id/10001' \
--header 'Accept: application/json' \
--header 'Content-type: application/json' \
--header 'Authorization: Basic {base64-encoded-credentials}'
Extract data based on ID
Request example
GET /api/v2/inventory/id/10001
Response example
{
"id": 10001,
"sku": "WMY71443LB2",
"ean": "8690842009112",
"inventory_enabled": "on",
"stock": 10,
"price_net": 1428.57,
"price_gross": 1700.00
}
Extract data based on SKU code
Request example
GET /api/v2/inventory/sku/TShirt.Blk.XL
Response example
{
"id": 10002,
"sku": "TShirt.Blk.XL",
"ean": null,
"inventory_enabled": "off",
"price_net": 75.63,
"price_gross": 90.00
}
Data extraction based on EAN code (Multi Warehouse application installed)
Request example
GET /api/v2/inventory/ean/7332543402632
Response example
{
"id": 10003,
"sku": "ZCG212H1WA",
"ean": "7332543402632",
"inventory_enabled": "on",
"stock": 20,
"warehouses": [
{
"id": 1,
"name": "Depozit central",
"stock": 5
},
{
"id": 2,
"name": "Depozit furnizor (Nod)",
"stock": 15
}
],
"price_net": 756.30,
"price_gross": 900.00
}
Modification of product information (or variant)
It allows updating an existing record based on ID, SKU code or EAN code.
Type : Resource update
Method : PATCH
Url :/api/v2/inventory/{type}/{identifier}
The response http code is 200
in case of success, the response will have the form of an individual resource representing the record that has just been updated. In the case of SKU type identifiers, their value must be encoded in the URL.
Request format
Example of a CURL request that updates an existing record:
curl --request PATCH \
--url 'https://shop.demo.ro/api/v2/inventory/id/10001' \
--header 'Accept: application/json' \
--header 'Content-type: application/json' \
--header 'Authorization: Basic {base64-encoded-credentials}' \
--data-raw '{
"stock": 20,
"price_net": 1344.54
}'
Update quantity and net price based on ID
Request example
PATCH /api/v2/inventory/id/10001
{
"stock": 20,
"price_net": 1344.54
}
Response example
{
"id": 10001,
"sku": "WMY71443LB2",
"ean": "8690842009112",
"inventory_enabled": "on",
"stock": 20,
"price_net": 1344.54,
"price_gross": 1600.00
}
Activation of stock function based on ID
Request example
PATCH /api/v2/inventory/id/10002
{
"inventory_enabled": "on",
"stock": 5
}
Response example
{
"id": 10002,
"sku": "TShirt.Blk.XL",
"ean": null,
"inventory_enabled": "on",
"stock": 5,
"price_net": 67.23,
"price_gross": 80.00
}
Price update with taxes included based on SKU code
Request example
PATCH /api/v2/inventory/sku/TShirt.Blk.XL
{
"price_gross": 80.00
}
Response example
{
"id": 10002,
"sku": "TShirt.Blk.XL",
"ean": null,
"inventory_enabled": "off",
"price_net": 67.23,
"price_gross": 80.00
}
Stock increment based on SKU code
Request example
PATCH /api/v2/inventory/sku/TShirt.Blk.XL
{
"inventory_enabled": "on",
"stock": {
"adjust_by": 3
}
}
Response example
{
"id": 10002,
"sku": "TShirt.Blk.XL",
"ean": null,
"inventory_enabled": "on",
"stock": 8,
"price_net": 67.23,
"price_gross": 80.00
}
Warehouse stock quantity update based on EAN code (Multi Warehouse application installed)
Request example
PATCH /api/v2/inventory/ean/7332543402632
{
"warehouses": [
{
"name": "Depozit central",
"stock": 10
},
{
"name": "Depozit furnizor (Nod)",
"stock": 15
}
]
}
Response example
{
"id": 10003,
"sku": "ZCG212H1WA",
"ean": "7332543402632",
"inventory_enabled": "on",
"stock": 25,
"warehouses": [
{
"id": 1,
"stock": 10,
"name": "Depozit central"
},
{
"id": 2,
"stock": 15,
"name": "Depozit furnizor (Nod)"
}
],
"price_net": 756.30,
"price_gross": 900.00
}
TIP
If the Multiple Warehouse application is installed, stock alteration cannot be done directly using the field `stock` but only using the `warehouses` field.