Colours API
General Information
You can access the list of all our colours and their attributes using our Colours JSON/REST API.
This is a useful service for example when integrating with e-commerce platforms that require to first import all options of colour variants.
JSON/REST
The data is provided through one endpoint: color
This webservice is very similar to the Products and Product Images web service. 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 |
PROD | https://api.stanleystella.com | production_api |
Get JSON
Service | URL
|
Colours | /webrequest/color/get_json |
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": "[
{
\"Code\": \"C001\",
\"Name\": \"White\",
\"SortOrder\": 1
},
{
\"Code\": \"C002\",
\"Name\": \"Black\",
\"SortOrder\": 2
},
{
\"Code\": \"C019\",
\"Name\": \"Lilac Peak\",
\"SortOrder\": 3
},
{
\"Code\": \"C018\",
\"Name\": \"Off White\",
\"SortOrder\": 5
},
...
]"
}
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/color/get_json";
$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(json_decode($result)->result, true);
curl_close($ch);