Search

getProductStock

Retrieve your ERPLY inventory — quantities on hand, reserved amounts, Reorder Points and Restock Levels, FIFO costs, and most recent purchase prices.

By default, API returns all products that have a non-zero inventory quantity in the warehouse you specified. In other words, items with a zero inventory quantity are skipped.

However, if you use input parameters “changedSince” (all quantities that have changed since last synchronization), or “getProductsWithReorderPointDefined” / “getProductsWithRestockLevelDefined”, API will also return items with zero inventory quantity.

To retrieve only a list of reserved inventory quantities, see getReservedStock.

If parameter warehouseID is not set, then API call will return the combined information of all warehouses.

Input parameters

Parameter nameDescriptionPossible valueRequired
warehouseIDWhen using old inventory system, then warehouseID is a required parameter.Integer
productIDRetrieve one specific product.Integer
productIDsRetrieve specific products. Multiple product IDs, separated by commas, such as: 1,2,3,4,5String
groupIDRetrieve products in this specific product group. (See getProductGroups.)Integer
groupIDWithSubgroupsRetrieve products in this product group, or in any of its sub-groups, sub-subgroups etc.Integer
supplierIDRetrieve products of this supplier. (See getSuppliers.)Integer
brandIDRetrieve products of this brand. (See getBrands.)Integer
priorityGroupIDRetrieve products in this priority group. (See getProductPriorityGroups.)Integer
categoryIDRetrieve products in this specific category. (See getProductCategories.)Integer
categoryIDWithSubcategoriesRetrieve products in this category, or in any of its sub-categories, sub-sub-categories etc.Integer
parentProductIDRetrieve variations of this matrix product.Integer
statusFilter products by status: ACTIVE, NO_LONGER_ORDERED, NOT_FOR_SALE, ACTIVE_AND_NOT_FOR_SALE, ARCHIVED, or ALL_EXCEPT_ARCHIVED.

The last one returns all non-archived items (ie. items that are active, not for sale or no longer ordered).

IF you are building a Stock Replenishment Report, ACTIVE_AND_NOT_FOR_SALE is the recommended option. It returns all orderable items, skipping archived products and those marked as "not ordered any more".
String
excludeOfflineWarehousesIf set to 1, then offline warehouses are not included in the result.

This parameter should be used, when warehouseID is not set.
Integer
getReorderPointsIf set to 1, API also returns Reorder Points and Restock Levels for each item.

When set to 1, then warehouseID is required
Integer
getAmountReservedIf set to 1, API also returns reserved amounts.Integer
getSuggestedPurchasePriceIf set to 1, API also returns suggested cost for each item.

For a definition of "suggested cost", see the description of the "suggestedPurchasePrice" field below.

When set to 1, then warehouseID is required
Integer
getAveragePricesIf set to 1, API also returns average purchase price and average cost.

When set to 1, then warehouseID is required
Integer
getFirstPurchaseDateIf set to 1, API also returns first purchase date.ISO date (yyyy-mm-dd)
getLastPurchaseDateIf set to 1, API also returns most recent purchase date.ISO date (yyyy-mm-dd)
getLastSoldDateIf set to 1, API also returns most recent sale date.ISO date (yyyy-mm-dd)
getProductsWithReorderPointDefinedIf set to 1, API returns only products with Reorder Point defined.

When set to 1, then warehouseID is required
Integer
getProductsWithRestockLevelDefinedIf set to 1, API returns only products with Restock Level defined.

When set to 1, then warehouseID is required
Integer
dateRetrieve inventory quantities on given date. Either date or changedSince can be set, but not both at the same time.ISO date (yyyy-mm-dd)
changedSinceGet only items for which the amount on hand has recently changedUnix timestamp

Response

Field nameTypeDescription
productIDIntegerProduct ID.
amountInStockDecimalTotal amount on hand.

This includes the amounts that are reserved to specific customers: via Sales Orders, for example. If you want to get only available inventory, subtract amountReserved from amountInStock.
amountReservedDecimalReserved amount (eg. pending Sales Orders).

To retrieve this field, set getAmountReserved = 1.
suggestedPurchasePriceDecimal

"Suggested cost" for the item. If you add this product to a Purchase Order, Erply will populate the "Price" field with this value.

The value is derived as follows:

  1. If the product has a supplier, and there is a "supplier price list" for that supplier, the product's price in supplier's price list is returned.
  2. Otherwise, the price on most recent purchase invoice (regardless of supplier or location) is returned.
  3. If there have not been any purchase invoices containing that product, cost from product card is returned.
  4. If no cost defined on product card, the product's cost from the most recent Inventory Registration (regardless of location) is returned.

To retrieve this field, set getSuggestedPurchasePrice = 1.

averagePurchasePriceDecimalWeighted average purchase price, for the batches that are currently in stock. To retrieve this field, set getAveragePrices = 1.
averageCostDecimalWeighted average cost, for the batches that are currently in stock.

Cost = purchase price + freight costs. If you multiply this field by amountInStock, you will get the total current value of your inventory.

Whenever you sell from inventory, ERPLY will naturally calculate cost for the specific sold items, not use this average value. Each sold item has its own cost, since it is drawn from a specific batch (according to FIFO). If you are interested in the cost of the sold item, you can use API calls:
  • getProductCostForSpecificAmount — if you need to know the cost before you create the sales document.
  • getCostOfGoodsSold — if the sale has already taken place. Returns all sold items and their costs in a specified time period.
  • getSalesDocuments — returns the total cost of all items on the invoice (field "cost"), if you specify input parameter getCOGS = 1.

To retrieve this field, set getAveragePrices = 1.
firstPurchaseDateFirst purchase date. To retrieve this field, set getFirstPurchaseDate = 1.ISO date (yyyy-mm-dd)
lastPurchaseDateMost recent purchase date. To retrieve this field, set getLastPurchaseDate = 1.ISO date (yyyy-mm-dd)
lastSoldDateMost recent sale date. To retrieve this field, set getLastSoldDate = 1.ISO date (yyyy-mm-dd)
reorderPointIntegerReorder point. (If amount on hand drops below that point, the item should be re-stocked.)
restockLevelIntegerRestock level. (Suggested amount to have on hand. The item is usually re-stocked up to this quantity.)

This API call may return a lot of data (tens of thousands of records) and the output is non-pageable. If you have a large database, API may be unable to serve the request — you will get an error code or empty output. However, there is an alternative way: you may request output in CSV format.

To retrive output as CSV, specify responseType = "CSV". API will respond you in JSON, providing a link to a CSV file::
{
"status":
{
"request":"getProductStock",
"requestUnixTime":1371221184,
"responseStatus":"ok",
"errorCode":0,
"generationTime":0.10201191902161,
"recordsTotal":1,
"recordsInResponse":1
},
"records":
[
{"reportLink":"http:\/\/sample.erply.com\/link\/to\/file.csv"}
]
}


The CSV file is in "latin1" encoding. Field separator is comma. All fields, including decimal fields, are quoted.