Ürünleri Listele
Sayfalanmış ürün listesini döndürür. Sayfa numaralandırması 1 tabanlıdır (siparişlerden farklı olarak).
Query Parametreleri
| Parametre | Tip | Zorunlu | Açıklama |
|---|---|---|---|
page | integer | Hayır | Sayfa numarası (varsayılan: 1) |
limit | integer | Hayır | Sayfa başına kayıt (varsayılan: 30, en fazla: 100) |
q | string | Hayır | Ad, stok kodu veya barkod ile arama |
category | integer | Hayır | Kategori ID'sine göre filtrele |
brand | integer | Hayır | Marka ID'sine göre filtrele |
active | integer | Hayır | 1 aktif, 0 pasif, -1 tümü (varsayılan) |
lang | string | Hayır | Dil kodu (ör. tr, en) |
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 . '/products?page=1&limit=20&q=vitamin&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/products?page=1&limit=20&q=vitamin&active=1"
Örnek Yanıt (JSON)
{
"success": true,
"lang": "tr",
"data": [
{
"id": 5,
"name": "Multivitamin Complex 60 Tablet",
"slug": "multivitamin-complex-60",
"url": "https://example.com/multivitamin-complex-60-5",
"price": 329,
"old_price": 399,
"stock": 200,
"in_stock": true,
"active": 1,
"barcode": "8690000000059",
"stock_code": "DEMO-MULTI60",
"id_category": 3,
"category_name": "Vitamin & Takviye",
"id_brand": 3,
"brand_name": "FShop Demo",
"image_url": "https://example.com/img/products/5.jpg",
"has_variations": false
}
],
"meta": {
"total": 1,
"page": 1,
"limit": 20,
"pages": 1
}
}