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 you need to get total stock across all warehouses, then use API call syncTotalProductStock.

Input parameters

Parameter name Description Possible value Required
warehouseID  When using old inventory system, then warehouseID is a required parameter.

If this parameter is omitted, then the total stock will be returned. Don't omit the warehouseID when syncing stock amounts, use API call syncTotalProductStock instead. 
Integer    
productID  Retrieve one specific product.  Integer    
productIDs  Retrieve specific products. Multiple product IDs, separated by commas, such as: 1,2,3,4,5  String    
groupID  Retrieve products in this specific product group. (See getProductGroups.)  Integer    
groupIDWithSubgroups  Retrieve products in this product group, or in any of its sub-groups, sub-subgroups etc.  Integer    
supplierID  Retrieve products of this supplier. (See getSuppliers.)  Integer    
brandID  Retrieve products of this brand. (See getBrands.)  Integer    
priorityGroupID  Retrieve products in this priority group. (See getProductPriorityGroups.)  Integer    
categoryID  Retrieve products in this specific category. (See getProductCategories.)  Integer    
categoryIDWithSubcategories  Retrieve products in this category, or in any of its sub-categories, sub-sub-categories etc.  Integer    
parentProductID  Retrieve variations of this matrix product.  Integer    
status  Filter 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    
excludeOfflineWarehouses  If set to 1, then offline warehouses are not included in the result.

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

When set to 1, then warehouseID is required 
Integer    
getAmountReserved  If set to 1, API also returns reserved amounts.  Integer    
getSuggestedPurchasePrice  If 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    
getAveragePrices  If set to 1, API also returns average purchase price and average cost.

When set to 1, then warehouseID is required 
Integer    
getFirstPurchaseDate  If set to 1, API also returns first purchase date.  ISO date (yyyy-mm-dd)    
getLastPurchaseDate  If set to 1, API also returns most recent purchase date.  ISO date (yyyy-mm-dd)    
getLastSoldDate  If set to 1, API also returns most recent sale date.  ISO date (yyyy-mm-dd)    
getProductsWithReorderPointDefined  If set to 1, API returns only products with Reorder Point defined.

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

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

Response

Field name Type Description
productID  Integer  Product ID.  
amountInStock  Decimal  Total 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.  
amountReserved  Decimal  Reserved amount (eg. pending Sales Orders).

To retrieve this field, set getAmountReserved = 1.  
suggestedPurchasePrice  Decimal 

"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.

 
averagePurchasePrice  Decimal  Weighted average purchase price, for the batches that are currently in stock. To retrieve this field, set getAveragePrices = 1.  
averageCost  Decimal  Weighted 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.  
firstPurchaseDate  First purchase date. To retrieve this field, set getFirstPurchaseDate = 1 ISO date (yyyy-mm-dd)  
lastPurchaseDate  Most recent purchase date. To retrieve this field, set getLastPurchaseDate = 1 ISO date (yyyy-mm-dd)  
lastSoldDate  Most recent sale date. To retrieve this field, set getLastSoldDate = 1 ISO date (yyyy-mm-dd)  
reorderPoint  Integer  Reorder point. (If amount on hand drops below that point, the item should be re-stocked.)  
restockLevel  Integer  Restock 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.