Retrieves the entire custom category tree for the authenticated user.
This endpoint allows you to retrieve a map of your custom categories. The response will be an object where keys are the category IDs and values are the full category paths.
GET https://api.commerceclarity.com/api/v1/custom-category
CommerceClarity APIs use Bearer Token authentication to protect endpoints and ensure that only authorized clients can access the data. Each API request must include a valid access token in the HTTP header.
{
"tree": {
"1": "Category 1",
"1.1": "Category 1 > Subcategory 1.1",
"2": "Category 2"
}
}
{
"error": "User not authenticated."
}
curl -X GET "https://api.commerceclarity.com/api/v1/custom-category" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json"
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
$client = new Client();
$token = 'YOUR_API_TOKEN';
$url = 'https://api.commerceclarity.com/api/v1/custom-category';
try {
$response = $client->get($url, [
'headers' => [
'Authorization' => 'Bearer ' . $token,
'Accept' => 'application/json',
],
]);
$body = $response->getBody();
$data = json_decode($body, true);
// Process the data
} catch (RequestException $e) {
// Handle the error...
}
import requests
token = 'YOUR_API_TOKEN'
url = 'https://api.commerceclarity.com/api/v1/custom-category'
headers = {
'Authorization': f'Bearer {token}',
'Accept': 'application/json'
}
try:
response = requests.get(url, headers=headers)
response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)
data = response.json()
# Process the data
except requests.exceptions.HTTPError as errh:
print(f"Http Error: {errh}")
except requests.exceptions.ConnectionError as errc:
print(f"Error Connecting: {errc}")
except requests.exceptions.Timeout as errt:
print(f"Timeout Error: {errt}")
except requests.exceptions.RequestException as err:
print(f"Something Else: {err}")
const token = 'YOUR_API_TOKEN';
const url = 'https://api.commerceclarity.com/api/v1/custom-category';
fetch(url, {
method: 'GET',
headers: {
'Authorization': `Bearer ${token}`,
'Accept': 'application/json',
'Content-Type': 'application/json'
}
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
console.log(data);
// Process the data
})
.catch(error => {
console.error('There has been a problem with your fetch operation:', error);
// Handle the error...
});