Shoptrader API docs
Customers
Retrieve, add, delete and edit customer records
Requests
Type | Call | Description |
---|---|---|
GET | /api/v2/customers/{customerId} |
Fetches a specific customer uit |
POST | /api/v2/customers |
Adds a new customer |
PATCH | /api/v2/customers/{customerId} |
Alters an existing customer |
DELETE | /api/v2/customers/{customerId} |
Removes a customer |
PHP Examples
Endpoint
GET /api/v2/customers/{customerId}
<?php
$strApiBaseUrl = 'uwdomein.uwdomeinextentie'; // base URL
$customerId = '1'; // customer id - E.g. '13'
$token = '8f00f89310945a0ca35666c8c9ced2e314e37aa6c32e900932e19902b42208767'; // your API token
$strUrl = 'http://'.$strApiBaseUrl.'/api/v2/customers/'.$customerId.'?token='.$token;
$objCurl = curl_init();
curl_setopt($objCurl, CURLOPT_URL, $strUrl);
curl_setopt($objCurl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($objCurl, CURLOPT_TIMEOUT, 60);
curl_setopt($objCurl, CURLOPT_USERAGENT, 'Shoptrader');
// 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
}
?>
Success response (JSON)
{ "customerId": "1", "gender": "", "firstName": "Shoptrader", "lastName": "Support", "dob": "0000-00-00", "emailAddress": "support@shoptrader.nl", "addressBookIds": "1,9,13", "defaultBillingAddressId": "1", "defaultDeliveryAddressId": "1", "phoneNumber": "020 624 24 39", "faxNumber": "", "bankAccountNumber": "", "password": "c800d49a305ce5f848ed7628042a02cd:48", "subscribedToNewsletter": "0", "guestAccount": "0", "approved": "1", "discountGroupId": "1", "discountGroupName": "default", "groupDiscount": "0.00", "numberOfLogins": "88", "lastLoginDate": "2018-12-14 09:11:48", "dateCreated": "2014-09-04 15:06:43", "lastModified": "2018-07-06 14:15:11" }
Endpoint
POST /api/v2/customers
field | required | description |
---|---|---|
emailAddress string |
X | E-mail address doubles as username |
password string |
If left empty, a guest account is created. | |
firstName string |
X | |
lastName string |
X | |
gender character |
X | 'm' or 'f' Required if configured as such in Configuratie Algemeen (backoffice) |
phoneNumber string |
||
faxNumber string |
||
bankAccountNumber string |
||
discountGroupId string |
Only applicable when using the add-on KLANTENGROEPEN. Ignored otherwise. |
<?php
$strApiBaseUrl = 'uwdomein.uwdomeinextentie'; // base URL
$token = '8f00f89310945a0ca35666c8c9ced2e314e37aa6c32e900932e19902b42208767'; // your API token
$strUrl = 'http://'.$strApiBaseUrl.'/api/v2/customers/?token='.$token;
$parameters = array(
"emailAddress" => "test@shoptrader.nl",
"password" => "TestPSW",
"firstName" => "TestLastname",
"lastName" => "TestLastname",
"gender" => "m",
"phoneNumber" => "06256565626",
"faxNumber" => "",
"bankAccountNumner" => "",
"discountGroupId" => "1"
);
$objCurl = curl_init();
curl_setopt($objCurl, CURLOPT_URL, $strUrl);
curl_setopt($objCurl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($objCurl, CURLOPT_TIMEOUT, 60);
curl_setopt($objCurl, CURLOPT_USERAGENT, 'Shoptrader');
curl_setopt($objCurl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($objCurl, CURLOPT_POSTFIELDS, json_encode($parameters));
curl_setopt($objCurl, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
// 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
}
?>
Success response (JSON)
{ "customerId": "4", "gender": "m", "firstName": "TestFirstname", "lastName": "TestLastname", "dob": "0000-00-00", "emailAddress": "test-api@shoptrader.nl", "addressBookIds": "5", "defaultBillingAddressId": "0", "defaultDeliveryAddressId": "0", "phoneNumber": "06256565626", "faxNumber": "", "bankAccountNumber": "", "password": "6f5eee17e054a1231f90cc80ef32513a:e4", "subscribedToNewsletter": "0", "guestAccount": "0", "approved": "1", "discountGroupId": "0", "discountGroupName": "", "groupDiscount": "0.00", "numberOfLogins": "0", "lastLoginDate": null, "dateCreated": "2019-02-04 13:01:22", "lastModified": "2019-02-04 13:01:22" }