Shoptrader API docs

Image Description

Products

Retrieve and add products

Requests

Type Call Description
GET
/api/v2/products
Retrieves a range of products.

By default the product is retrieved in the default language as setup in the store. To retrieve the product in a different language, please set the 'Accept-Language' header or add the parameter 'acceptLanguageId={languageId}' to the url.

It's also possible to make use for filters. Example: /api/v2/products?filter[search]=ean:12345

  • only_main_products: retourneer artikelen zonder de bijbehorende artikelopties
  • categoryId: retourneer alleen artikelen alleen als ze in de opgegeven categorie staan
  • recursiveCategories: indien true, dan wordt bij het gebruik van category_id ook in onderliggende categorieen gekeken.
  • stockFrom: alleen producten vanaf de opgegeven voorraad
  • stockTo: alleen producten tot en met de opgegeven voorraad
  • manufacturerId: alleen producten met de opgegeven manufacturer
  • search: alleen producten met de opgegeven ean (?filter[search]=ean:{ean}), sku (?filter[search]=sku:{sku}) of wildcard (?filter[search]=*t?st*)
  • limit: toon maximaal {limit} artikelen
  • offset: toon artikelen vanaf deze index

GET
/api/v2/products/{productId|Sku}
Retrieves a specific product
POST
/api/v2/products
Voegt een nieuw product toe

PHP Examples


Endpoint

GET /api/v2/products

<?php

$strApiBaseUrl 
'uwdomein.uwdomeinextentie'// base URL
$productId '50'// order id - E.g. '50'
$token    '8f00f89310945a0ca35666c8c9ced2e314e37aa6c32e900932e19902b42208767'// your API token

$strUrl 'http://'.$strApiBaseUrl.'/api/v2/products/'.$productId.'?token='.$token;

$objCurl curl_init();
curl_setopt($objCurlCURLOPT_URL$strUrl);
curl_setopt($objCurlCURLOPT_RETURNTRANSFERtrue);
curl_setopt($objCurlCURLOPT_TIMEOUT60);
curl_setopt($objCurlCURLOPT_USERAGENT'Shoptrader');\
curl_setopt($objCurlCURLOPT_HTTPHEADER, array("Accept-Language: nl"));

// execute cURL
$responseCurl curl_exec($objCurl);

if (
$responseCurl === FALSE) {
    echo 
"cURL Error: ".curl_error($objCurl);
} else {
    
print_r($responseCurl); // the successful response contains a JSON as shown below
}

?>
Show response

Endpoint

POST /api/v2/products

model
string
The article number
sku
string
The SKU code
ean
string
The EAN code
name
string
The product name
quantity
string
The available stock
categoryId
integer
The category where the article is placed
price
float
The price excluding VAT
purchasePrice
float
The purchase price excluding BTW
status
integer
0 = offline, 1 = online
taxRate
integer
The value for the BTW percentage that is used (E.g. "21")
image
string
The name of a product image. This image must already be present on the shop
imageAlt
string
The description for the product image shown when the image is not available
<?php

$strApiBaseUrl 
'uwdomein.uwdomeinextentie'// base URL
$token    '8f00f89310945a0ca35666c8c9ced2e314e37aa6c32e900932e19902b42208767'// your API token

$strUrl 'http://'.$strApiBaseUrl.'/api/v2/products?token='.$token;

$parameters = array(
    
"model" => "1234567",
    
"sku" => "SKU1234567",
    
"ean" => "80015354685487654554",
    
"name" => "NewProduct",
    
"quantity" => "30",
    
"categoryId" => "79",
    
"price" => "15.50",
    
"purchasePrice" => "11.00",
    
"status" => 1,
    
"taxRateVal" => 21,
    
"image" =>"",
    
"imageAlt" =>"image"
);

$objCurl curl_init();
curl_setopt($objCurlCURLOPT_URL$strUrl);
curl_setopt($objCurlCURLOPT_RETURNTRANSFERtrue);
curl_setopt($objCurlCURLOPT_TIMEOUT60);
curl_setopt($objCurlCURLOPT_USERAGENT'Shoptrader');
curl_setopt($objCurlCURLOPT_CUSTOMREQUEST'POST');
curl_setopt($objCurlCURLOPT_POSTFIELDSjson_encode($parameters));
curl_setopt($objCurlCURLOPT_HTTPHEADER, array("Content-Type: application/json""Accept-Language: nl"));

// execute cURL
$responseCurl curl_exec($objCurl);

if (
$responseCurl === FALSE) {
    echo 
"cURL Error: ".curl_error($objCurl);
} else {
    
print_r($responseCurl); // the successful response contains a JSON as shown below
}

?>
Show response