Authentication
You must obtain an access token before accessing the API. The token is used in the
Authorization header for all subsequent requests.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
token | string | Yes | Your site webapi token |
Important: Never store the
token on the client side (JavaScript, mobile app).
Perform token retrieval on the server side only.
PHP
<?php
$baseUrl = 'https://example.com/api/v1/';
$apiKey = ''; // You need to obtain a token from the admin for the API Key.
$result = '';
function apiRequest($method, $url, $apiKey, $data = null)
{
$ch = curl_init();
$headers = [
'X-API-Key: ' . trim($apiKey),
'Accept: application/json',
];
if ($data !== null) {
$headers[] = 'Content-Type: application/json';
}
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_SSL_VERIFYPEER => false,
]);
if ($data !== null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data, JSON_UNESCAPED_UNICODE));
}
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
return [
'http_code' => $httpCode,
'curl_error' => $error,
'response' => json_decode($response, true) ?: $response,
];
}
// Get Products
$result = apiRequest('GET', $baseUrl . '/products?page=1&limit=20', $apiKey);
// Get Product Detail
$result = $result = apiRequest('GET', $baseUrl . '/products/' . (int) $productID, $apiKey);
// Get Catetetories
$result = apiRequest('GET', $baseUrl . '/categories', $apiKey);
// Get Brands
$result = apiRequest('GET', $baseUrl . '/brands', $apiKey);
// Get Orders
$result = apiRequest('GET', $baseUrl . '/orders?page=0&size=20', $apiKey);
// Get Order Detail
$result = apiRequest('GET', $baseUrl . '/orders/' . (int)$orderID, $apiKey);
Sample Response (JSON)
(
[http_code] => 200
[curl_error] =>
[response] => Array
(
[success] => 1
[data] => Array
(
[id] => 1
[name] => SolNutrof Total 30 Kapsül
[slug] => solnutrof-total-30-kapsul
[url] => http://localhost/frisay/vitamin-takviye/solnutrof-total-30-kapsul-1
[price] => 899
[old_price] => 1099
[stock] => 120
[in_stock] => 1
[active] => 1
[barcode] => 8690000000011
[stock_code] => SOLNUTROF30
[id_category] => 3
[category_name] => Vitamin & Takviye
[id_brand] => 1
[brand_name] => Nutrof
[image_url] => http://localhost/frisay/templates/default/img/products/125.jpg
[short_description] => Göz sağlığı için gelişmiş formül.
[description] => Test product desc
[description_html] => <p>Test product <b>desc</b></p>
[meta_title] =>
[meta_description] =>
[vat] => 20
[doviz] => try
[doviz_price] => 899
[doviz_old_price] => 1099
[cargo_day] => 2
[label] => 3 Al 2 Öde
[product_video] =>
[desi] => 1
[images] => Array
(
[0] => http://localhost/frisay/templates/default/img/products/125.jpg
)
)
)
)