Prices API
General Information
This new web service lets you download your specific purchase prices and the recommended sales prices of our products.
Each customer account is linked to one specific pricelist. We use this link to provide your specific purchase prices.
JSON/REST
The data is provided through one endpoint: get_prices
This webservice is very similar to the other web services in our API's. Therefore:
-
Method to be used is POST
-
Encoding is UTF-8
-
The API must be called with the https prefix
In order to use this system, valid credentials are required. If you do not have one yet, please request an account.
If you wish to test your code, you can do so with a tool like Postman.
Integration
Endpoint Settings
Environment
| Server
| Database
|
TEST | https://apitest.stanleystella.com | mig_api |
PROD | https://api.stanleystella.com | production_api |
Note : the test endpoint is deemed to be used with eligible partners when we develop new features with our API. You should connect to our prod environment.
Get JSON
Service | URL
|
Get Prices | /webrequest/products/get_prices |
JSON format as input
Submit this JSON message as input. There are no filters possible on this call.
{JSON format as output
"jsonrpc":"2.0",
"method":"call",
"params":{
"db_name":"production_api",
"password":"YOUR_PASSWORD",
"user":"YOUR_LOGIN"
},
"id":0
}
The following JSON is the output of the call.
{
"jsonrpc": "2.0",
"id": 0,
"result": "[
{
\"B2BSKUREF\": \"STSW131C002XS\",
\"PurchasePriceList\": \"K100 (EUR)\",
\"PurchasePrice\": 14.5,
\"RecommendedSalesPriceLT10pcs\": 27.55,
\"RecommendedSalesPriceGT10pcs\": 27.55,
\"RecommendedSalesPriceGT50pcs\": 26.1,
\"RecommendedSalesPriceGT100pcs\": 24.65,
\"RecommendedSalesPriceGT250pcs\": 23.2,
\"RecommnededSalesPriceGT500pcs\": 21.75,
\"RecommendedSalesPriceGT1000pcs\": 20.75
},
...
]"
}
PHP code example with curl
Here is an example of PHP code used to call the Colours JSON/REST service. This code is given as illustration.
$url = "https://api.stanleystella.com/webrequest/products/get_prices";
$jsonData = array(
'jsonrpc' => '2.0',
'method' => 'call',
'params' => array(
'db_name' => "production_api",
'password' => "YOUR_PASSWORD",
'user' => "YOUR_LOGIN",
),
'id' => 0
);
$ch = curl_init($url);
$jsonDataEncoded = json_encode($jsonData);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($ch);
$jsonDataDecoded = json_decode($result)->result;
curl_close($ch);
Download prices in CSV file
If you prefer to work with a CSV file, here is a PHP code that will let you download products data and prices and combine them in a useful CSV file.
<?php ini_set("memory_limit","256M"); ini_set("max_execution_time",9000); ini_set('default_charset', 'utf-8'); header('Content-Type: text'); $allproducts = getAllSTSTProducts(); $allprices = getPurchasePrices(); $fp = fopen('pricelist_output.csv', 'w'); $r = array(); $r["B2BSKUREF"] = "B2BSKUREF"; $r["StyleCode"] = "Style code"; $r["StyleName"] = "Style"; $r["ColorCode"] = "Color code"; $r["ColorName"] = "Color"; $r["SizeCode"] = "Size code"; $r["SizeName"] = "Size"; $r["PurchasePrice"] = "PurchasePrice"; $r["RecommendedSalesPriceGT10pcs"] = "RecommendedSalesPriceGT10pcs"; $r["RecommendedSalesPriceGT50pcs"] = "RecommendedSalesPriceGT50pcs"; $r["RecommendedSalesPriceGT100pcs"] = "RecommendedSalesPriceGT100pcs"; $r["RecommendedSalesPriceGT250pcs"] = "RecommendedSalesPriceGT250pcs"; $r["RecommendedSalesPriceGT500pcs"] = "RecommendedSalesPriceGT500pcs"; $r["RecommendedSalesPriceGT1000pcs"] = "RecommendedSalesPriceGT1000pcs"; fputcsv($fp, $r, ";"); foreach ($allprices as $sku) { $r = array(); $r["B2BSKUREF"] = $sku->B2BSKUREF; $key = array_search($sku->B2BSKUREF, array_column($allproducts, 'B2BSKUREF')); $r["StyleCode"] = $allproducts[$key]["StyleCode"]; $r["StyleName"] = $allproducts[$key]["StyleName"]; $r["ColorCode"] = $allproducts[$key]["ColorCode"]; $r["ColorName"] = $allproducts[$key]["Color"]; $r["SizeCode"] = $allproducts[$key]["SizeCodeNavision"]; $r["SizeName"] = $allproducts[$key]["SizeCode"]; $r["PurchasePrice"] = $sku->PurchasePrice; $r["RecommendedSalesPriceGT10pcs"] = $sku->RecommendedSalesPriceGT10pcs; $r["RecommendedSalesPriceGT50pcs"] = $sku->RecommendedSalesPriceGT50pcs; $r["RecommendedSalesPriceGT100pcs"] = $sku->RecommendedSalesPriceGT100pcs; $r["RecommendedSalesPriceGT250pcs"] = $sku->RecommendedSalesPriceGT250pcs; $r["RecommendedSalesPriceGT500pcs"] = $sku->RecommendedSalesPriceGT500pcs; $r["RecommendedSalesPriceGT1000pcs"] = $sku->RecommendedSalesPriceGT1000pcs; fputcsv($fp, $r, ";"); } fclose($fp); function getAllSTSTProducts() { $url = "https://api.stanleystella.com/webrequest/products/get_json"; $jsonData = array( 'jsonrpc' => '2.0', 'method' => 'call', 'params' => array( 'db_name' => "production_api", 'password' => YOUR_PASSWORD, 'user' => YOUR_LOGIN, "LanguageCode" => "en_US" ), 'id' => 0 ); $ch = curl_init($url); $jsonDataEncoded = json_encode($jsonData); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); $result = curl_exec($ch); $jsonDataDecoded = json_decode(json_decode($result)->result, true); curl_close($ch); return $jsonDataDecoded; } function getPurchasePrices() { $url = "https://api.stanleystella.com/webrequest/products/get_prices"; $jsonData = array( 'jsonrpc' => '2.0', 'method' => 'call', 'params' => array( 'db_name' => "production_api", 'password' => YOUR_PASSWORD, 'user' => YOUR_LOGIN ) ); $ch = curl_init($url); $jsonDataEncoded = json_encode($jsonData); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); $result = curl_exec($ch); $r = json_decode($result); curl_close($ch); return $r->result; }