Menu Close
Examples

Westcan Product API Documentation

Westcan’s Product API is granted on a by-approval basis to Westcan Dealers or Affiliates who wish to integrate our product library. The API uses authentication headers which use your key and secret, and must be called via HTTPS.

The following includes base call examples using PHP (CURL) or jQuery / Ajax..:

PHP/CURL Example:
function product_api($query){

$key = 'PROVIDEDKEY';
$secret = 'PROVIDEDSECRET';
$url = 'APIURLHERE';

$endpoint = $url.'?'
.http_build_query($query);
$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => $endpoint,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Basic ". base64_encode($key.":".$secret),
"cache-control: no-cache"
),
));
$response = curl_exec($curl);

$err = curl_error($curl);
curl_close($curl);

if ($err) {
return "cURL Error #:" . $err;
} else {
return $response;
}
}
JavaScript ( jQuery / Ajax ) Example
function product_api(params){

var key = 'PROVIDEDKEY';
var secret = 'PROVIDEDSECRET';
var url = 'APIURL';

var query = $.param( params );
geturl = url+'?'+query;

$.ajax
({
type: "GET",
url: geturl,
dataType: 'json',
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Basic " + btoa(key + ":" + secret)); },
async: false,
data: '{}',
success: function (data){
//if data.status = success do something
//if data.status = error do something else
},
error: function() {
//if fatal error do something
}
});

}
Query by Product Number
var params = { sku: 16-3605 }
$query = array('sku'=>'16-3605');
Expected Result..:
Content/Type "JSON"
{
"status":"success",
"message": "products returned",
"results":[]
}

{
"status":"error",
"message": "error message"
}
Query By Product Category
var params = { cat_id : 634, page : 1 };
$query = array('cat_id'=>634, 'page'=>'1');
Expected Result..:
Content/Type "JSON"
{
   "status": "success",
   "message": "product returned",
   "results": {
      "partnumber": "10-1007",
      "name": "Solid Behind 2nd Row Partition 07+ Sprinter High Roof",
      "description": "Westcan Manufacturing's fixed safety partitions give you the best of both worlds with being solid and secure.All safety partitions are constructed using aluminum and are manufactured using CNC technology to ensure the best and most efficient product. Westcan’s second row safety partition sits 45-3\/4” back from the B-Pillar in the Sprinter. This protects occupants sitting in the second row of seats or can act as an additional cargo partition. Choose a Westcan safety partition and feel safe when you're on the job. All installation mounting brackets, hardware and instructions are included.",
      "url": "https:\/\/dealers.westcanmanufacturing.com\/product\/solid-behind-2nd-row-partition-07-sprinter-high-roof\/",
      "msrp": "894.3",
      "images": [
          "https:\/\/dealers.westcanmanufacturing.com\/wp-content\/uploads\/2021\/02\/10-1007_i_800x600.jpg"
         ],
      "shipsize": "79 × 4 × 35 in",
      "productsize": "",
      "insidedimensions": "",
      "weight": "84",
      "installtime": "",
      "includes": "",
      "recommended": [],
      "category": [
         "Fixed Safety Partitions",
         "Safety Partitions",
         "Van"
      ],
      "fits": null,
      "sku": "10-1007"
   }
}