API V1 is no longer in active development. If you are starting a new integration, it is recommended you use API V2

Stock Levels

The Lead Commerce Stock Level API allows you to view, and make adjustments to inventory:

Views

Views allow you to display data about your Stock Levels.

With the Stock Level API, you can filter your result set to get a particular result set you are looking for. You can use any of the filters in any particular combination.

Filters

Key Data Type Required Example Notes
id Integer No 5 The ID of the Product
location String No B54 The location of the item you are looking for
warehouse Integer No 1 The ID of the warehouse
timestamp_start Integer No 1406239561 UNIX timestamp of the latest time of the sku was adjusted.
timestamp_end Integer No 1412200562 UNIX timestamp of the latest time of the sku was adjusted.

The sample code below demonstrates how to request a view in XML:

Example:

<?php  
header("Content-type: text/xml;");  
$credentials = array('identifier' => 'LC350000000',  
                     'key' => 'dynKSr4I7y2K3RrPRsFYFJr03IXUbv');  
$curl = curl_init();  
curl_setopt($curl,CURLOPT_POSTFIELDS, http_build_query($credentials));  
curl_setopt($curl,CURLOPT_POST, 1);  
curl_setopt($curl, CURLOPT_URL, 'http://leadcommercestore.web/api/v1/StockLevels.xml');  
curl_exec($curl);  
curl_close($curl);  
?>

Example Output:

<?xml version="1.0" encoding="UTF-8"?>
<message client="192.168.100.128" time="1412207991">
   <response>
      <code>200</code>
      <data>
         <item>
            <sku>1-0011</sku>
            <product_name>Basic T-Shirt</product_name>
            <in_stock>12</in_stock>
            <available>12</available>
            <committed>0</committed>
            <inbound>0</inbound>
            <backordered>0</backordered>
            <transfer>0</transfer>
            <stock_levels>
               <stock_level>
                  <warehouse>1</warehouse>
                  <in_stock>12</in_stock>
                  <available>12</available>
                  <committed>0</committed>
                  <inbound>0</inbound>
                  <backordered>0</backordered>
                  <transfer>0</transfer>
                  <min_warning>0</min_warning>
                  <location>B45</location>
                  <status>Active</status>
               </stock_level>
            </stock_levels>
            <adjustments>
               <adjustment>
                  <adjustment_type>+</adjustment_type>
                  <amount>2</amount>
                  <inventory_block>0</inventory_block>
                  <adjustment_reason>1</adjustment_reason>
                  <warehouse>1</warehouse>
                  <note />
                  <adjustment_added>10/1/2014 7:14PM</adjustment_added>
               </adjustment>
               <adjustment>
                  <adjustment_type>+</adjustment_type>
                  <amount>10</amount>
                  <inventory_block>0</inventory_block>
                  <adjustment_reason>2</adjustment_reason>
                  <warehouse>1</warehouse>
                  <note />
                  <adjustment_added>10/1/2014 7:19PM</adjustment_added>
               </adjustment>
            </adjustments>
         </item>
      </data>
   </response>
</message>

Adjustment

Create allows you to adjust inventory by doing an inventory adjustment as if you went through the Lead Commerce Back Office.

Example:

$insert = array("id" => "1-0009",
		"amount" =>10,
                "warehouse"=>1,
                "reason" =>2);
$fields = array('identifier' => 'LC350000000',
                'key' => 'dynKSr4I7y2K3RrPRsFYFJr03IXUbv',
                'inserts' => array($insert));
$curl = curl_init();
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_URL, 'http://www.leadcommercestore.com/api/v1/StockLevels/adjustment.xml');
curl_exec($curl);
curl_close($curl);
?>

Data Points

Key Data Type Required Example Notes
amount Integer Yes   5 This can be a positive or a negative number. This will add or remove units from inventory
warehouse Integer Yes 1 The ID of the warehouse you are adjusting
reason Integer Yes 2
    1 Adding more units discovered after receiving
    2 Adjusting for miscounted units
    3 Removing damaged/unsellable units
    4 Initial Inventory Adjustment
    5 Other

Start your free, no-risk trial today.