Sofort-Partnerschaft, Sofort-Integration

Integrieren Sie 2496 Produkte ganz einfach in Ihre eigene Website!

Sofort per API in Ihre Website integrieren

API-Dokumentation
# Produkte & Bestand abrufen
curl "https://www.playsultan.com/api/v1/products?currency=EUR&lang=en&in_stock=1&per_page=50" \
  -H "Authorization: Bearer pb_live_xxxxxxxxxxxxxxxx"

# Mit Live-Preisen auf Ihrer Website listen
# { "ok": true, "data": [ { "id": 445, "name": "PlayStation $1 USD PSN United States",
#   "price": 0.82, "currency": "EUR", "price_try": 44.25, "stock": 42, "in_stock": true } ],
#   "meta": { "page": 1, "total": 2104, "has_more": true } }
<?php
// Katalog synchronisieren
$key = 'pb_live_xxxxxxxxxxxxxxxx';
$page = 1;

do {
  $url = 'https://www.playsultan.com/api/v1/products?currency=EUR&per_page=200&page=' . $page;
  $res = file_get_contents($url, false, stream_context_create([
    'http' => ['header' => "Authorization: Bearer $key\r\n"],
  ]));
  $body = json_decode($res, true);

  foreach ($body['data'] as $product) {
    // in Ihre eigene Datenbank schreiben
  }

  $page++;
} while (!empty($body['meta']['has_more']));
// Katalog synchronisieren
const key = 'pb_live_xxxxxxxxxxxxxxxx';
let page = 1, hasMore = true;

while (hasMore) {
  const res = await fetch(
    `https://www.playsultan.com/api/v1/products?currency=EUR&per_page=200&page=${page}`,
    { headers: { Authorization: `Bearer ${key}` } }
  );
  const { data, meta } = await res.json();

  for (const product of data) {
    // in Ihre eigene Datenbank schreiben
  }

  hasMore = meta.has_more;
  page++;
}