A ALEFBADeveloper Platform
Status Trust

Core Concepts

Code Examples

Use these server-side examples as starting points for ALEFBA API integrations.

Public catalog — cURL

bash
curl --request GET \
  --url "https://alefba.eu/api/v1/catalog?page=1&limit=20" \
  --header "Accept: application/json"

Protected endpoint — cURL

bash
curl --request GET \
  --url "https://alefba.eu/api/v1/products" \
  --header "Accept: application/json" \
  --header "Authorization: Bearer alefba_live_YOUR_API_KEY"

PHP with cURL

php
<?php
$apiKey = getenv("ALEFBA_API_KEY");

if (!$apiKey) {
    throw new RuntimeException("ALEFBA_API_KEY is not configured.");
}

$ch = curl_init("https://alefba.eu/api/v1/products");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 20,
    CURLOPT_HTTPHEADER => [
        "Accept: application/json",
        "Authorization: Bearer " . $apiKey,
    ],
]);

$body = curl_exec($ch);

if ($body === false) {
    throw new RuntimeException(curl_error($ch));
}

$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);

$data = json_decode($body, true, 512, JSON_THROW_ON_ERROR);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException($data["error"]["message"] ?? "ALEFBA API request failed.");
}

JavaScript / Node.js

javascript
const apiKey = process.env.ALEFBA_API_KEY;

if (!apiKey) {
  throw new Error("ALEFBA_API_KEY is not configured.");
}

const response = await fetch("https://alefba.eu/api/v1/products", {
  headers: {
    Accept: "application/json",
    Authorization: `Bearer ${apiKey}`,
  },
});

const payload = await response.json();

if (!response.ok) {
  throw new Error(payload?.error?.message ?? "ALEFBA API request failed.");
}

console.log(payload);

Safe client behavior