Shoptrader API docs

Image Description

Addresses

Retrieve, add, delete and edit address records

Requests

Type Call Omschrijving
GET
/api/v2/customers/{customerId}/addresses
Retrieves all address records attached to the given customerId
GET
/api/v2/customers/{customerId}/addresses/{addressBookId}
Retrieves a specific address record
POST
/api/v2/customers/{customerId}/addresses
Creates a new address and attaches it to the customerId
PATCH
/api/v2/customers/{customerId}/addresses/{addressBookId}
Alters an address record
DELETE
/api/v2/customers/{customerId}/addresses/{addressBookId}
Remove an address record

PHP Examples


Endpoint

GET /api/v2/customers/{customerId}/addresses/{addressBookId}


<?php

$strApiBaseUrl 
'uwdomein.uwdomeinextentie'// base URL
$customerId '13'// customer id - E.g. '13'
$addressBookId '5'// address book id - E.g. '5'
$token    '8f00f89310945a0ca35666c8c9ced2e314e37aa6c32e900932e19902b42208767'// your API token

$strUrl 'http://'.$strApiBaseUrl.'/api/v2/customers/'.$customerId.'/addresses/'.$addressBookId.'?token='.$token;

$objCurl curl_init();
curl_setopt($objCurlCURLOPT_URL$strUrl);
curl_setopt($objCurlCURLOPT_RETURNTRANSFERtrue);
curl_setopt($objCurlCURLOPT_TIMEOUT60);
curl_setopt($objCurlCURLOPT_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)

{
    "id": "2",
    "customerId": "2",
    "company": "Shoptrader BV",
    "name": "Sjakie Bonenstakie",
    "firstName": "Sjakie",
    "lastName": "Bonenstakie",
    "streetAddress": "Wilgenweg",
    "houseNumber": "26",
    "houseNumberExtension": "B",
    "zipcode": "1031HV",
    "city": "Amsterdam",
    "state": null,
    "gender": "",
    "btwNumber": "",
    "kvkNumber": "",
    "country": {
        "id": "1",
        "title": "Nederland",
        "isoCode2": "NL",
        "isoCode3": "NLD"
    },
    "zoneId": "0",
    "zoneCode": "",
    "zoneName": "",
    "addressFormatId": 1,
    "addressFormat": "Sjakie Bonenstakie
    Wilgenweg 26B
    1031HV Amsterdam
    Nederland ","
    addressSummary ":"
    Amsterdam\ / Nederland "
}
						


Endpoint

POST /api/v2/customers/{customerId}/addresses


Parameters request

field required description
company
string
X Company name
Required if configured as such in Configuratie Algemeen (backoffice)
firstName
string
X Maybe also contain initials
lastName
string
X
streetAddress
string
X if postcode add-on enabled and country equals Netherlands, this is automatically filled in.
houseNumber
integer
X
houseNumberExtension
string
zipcode
string
X
city
string
X if postcode add-on enabled and country equals Netherlands, this is automatically filled in.
state
string
X Required for addresses in the United States
country
string
X ISO-2 or ISO-3 code for country
Example: NL, NLD
gender
character
X 'm' of 'f'
Required if configured as such in Configuratie Algemeen (backoffice)
btwNumber
string
X VAT nummer
Required if configured as such in Configuratie Algemeen (backoffice)
kvkNumber
string
X Chamber of commerce number.
Required if configured as such in Configuratie Algemeen (backoffice)
<?php

$strApiBaseUrl 
'uwdomein.uwdomeinextentie'// base URL
$customerId '13'// customer id - E.g. '13'
$addressBookId '5'// address book id - E.g. '5'
$token    '8f00f89310945a0ca35666c8c9ced2e314e37aa6c32e900932e19902b42208767'// your API token

$strUrl 'http://'.$strApiBaseUrl.'/api/v2/customers/'.$customerId.'/addresses?token='.$token;

$parameters = array(
    
"company" => "Company Test",
    
"firstName" => "TestName",
    
"lastName" => "TestLastname",
    
"streetAddress" => "Wilgenweg",
    
"houseNumber" => "26",
    
"houseNumberExtension" => "B",
    
"zipcode" => "1031HV",
    
"city" => "Amsterdam",
    
"country" => "NL"
);

$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"));

// 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)

{
    "id": "13",
    "customerId": "1",
    "company": "Company Test",
    "name": "TestName TestLastname",
    "firstName": "TestName",
    "lastName": "TestLastname",
    "streetAddress": "Wilgenweg",
    "houseNumber": "26",
    "houseNumberExtension": "B",
    "zipcode": "1031HV",
    "city": "Amsterdam",
    "state": "",
    "gender": "",
    "btwNumber": "",
    "kvkNumber": "",
    "country": {
        "id": "1",
        "title": "Nederland",
        "isoCode2": "NL",
        "isoCode3": "NLD"
    },
    "zoneId": "0",
    "zoneCode": "",
    "zoneName": "",
    "addressFormatId": 1,
    "addressFormat": "TestName TestLastname
Wilgenweg 26 B
1031HV Amsterdam
Nederland", "addressSummary": "Amsterdam / Nederland" }