API Dokumentation

Endpoints, Request/Response Beispiele und Snippets.

Endpoints

Übersicht der wichtigsten Endpoints.

GET /api/health
POST /api/license/validate Öffentlich
Health Check

Prüft, ob der Service online ist.

Öffentlich
Endpoint
GET /api/health
Response
{
  "ok": true,
  "service": "craftingstudiopro-web",
  "timestamp": "2025-12-19T12:34:56.789Z"
}
Beispiel (JavaScript)
const res = await fetch('/api/health');
const data = await res.json();

if (data.ok) {
  console.log('API online:', data.service, data.timestamp);
} else {
  console.log('API offline');
}
Lizenz-Key System

Validiert einen Lizenz-Key für ein bestimmtes Premium-Plugin.

Öffentlich
Endpoint
POST /api/license/validate
Request Body
{
  "licenseKey": "CSP-XXXXXXXXXXXXXXXXXXXX",
  "pluginId": "plugin-id"
}
pluginId kann die numerische Plugin-ID oder der Plugin-Slug sein.
Response (Erfolgreich)
{
  "valid": true,
  "purchase": {
    "id": "purchase-id",
    "userId": "user-id",
    "pluginId": "plugin-id",
    "createdAt": "2024-01-01T00:00:00.000Z"
  }
}
Response (Ungültig)
{
  "valid": false,
  "message": "Ungültiger Lizenz-Key"
}
Beispiel (JavaScript)
const response = await fetch('/api/license/validate', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    licenseKey: 'CSP-XXXXXXXXXXXXXXXXXXXX',
    pluginId: 'plugin-id'
  })
});

const result = await response.json();
if (result.valid) {
  console.log('Lizenz gültig:', result.purchase);
} else {
  console.log('Lizenz ungültig:', result.message);
}