GET https://example.com/api/v1/categories

Kategorileri Listele

Mağaza kategorilerini döndürür. Ürün oluşturmadan önce (ID çözümlemek veya adları doğrulamak için) kullanışlıdır.

Query Parametreleri

ParametreTipZorunluAçıklama
pageintegerHayır0 tabanlı sayfa (varsayılan: 0)
size / limitintegerHayırSayfa boyutu (varsayılan: 100, en fazla: 500)
activeintegerHayır1 yalnızca aktif (varsayılan), 0 pasif
PHP
<?php

$baseUrl = 'https://example.com/api/v1';
$apiKey  = 'YOUR_API_KEY';

function apiRequest(string $method, string $url, string $apiKey, ?array $data = null): array
{
    $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 => true,
    ]);
    if ($data !== null) {
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data, JSON_UNESCAPED_UNICODE));
    }
    $response = curl_exec($ch);
    $httpCode = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $error = curl_error($ch);
    curl_close($ch);
    $decoded = json_decode((string) $response, true);
    return [
        'http_code' => $httpCode,
        'curl_error' => $error,
        'response' => is_array($decoded) ? $decoded : $response,
    ];
}

$result = apiRequest('GET', $baseUrl . '/categories?page=0&size=100&active=1', $apiKey);
print_r($result);
cURL
curl -s -H "X-API-Key: YOUR_API_KEY" \
  -H "Accept: application/json" \
  "https://example.com/api/v1/categories?page=0&size=100&active=1"
Örnek Yanıt (JSON)
{
  "totalElements": 4,
  "content": [
    {
      "id": 3,
      "name": "Vitamin & Takviye",
      "slug": "vitamin-takviye",
      "parentId": 1,
      "parentName": "Sağlık",
      "active": true
    }
  ]
}