Zum Inhalt gehen
stayclean
Dokumentationsnavigation
API docsSDKs und HTTP-Clients

Grundlegende Anleitungen

SDKs und HTTP-Clients

Den passenden HTTP-Client für Ihre Umgebung verwenden.

Die Beispiele verwenden cURL, JavaScript fetch, PHP cURL und die Python-Standardbibliothek. Ein offizielles StayClean-SDK ist nicht erforderlich. Bewahren Sie Zugangsdaten auf Ihrem Server auf und verwalten Sie Fehler und Zeitlimits im HTTP-Client. Beispiele werden in dieser Dokumentation nicht ausgeführt.

Anfragebeispiel

cURL

curl --request 'GET' 'https://api.stayclean.io/api/v1/interventions?page=1&limit=25&sort=desc' \
  --header 'Authorization: Basic YOUR_API_TOKEN' \
  --header 'Accept: application/json'

JavaScript

const response = await fetch("https://api.stayclean.io/api/v1/interventions?page=1&limit=25&sort=desc", {
    "method": "GET",
    "headers": {
        "Authorization": "Basic YOUR_API_TOKEN",
        "Accept": "application/json"
    }
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();

PHP

<?php
$curl = curl_init('https://api.stayclean.io/api/v1/interventions?page=1&limit=25&sort=desc');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => array (
  0 => 'Authorization: Basic YOUR_API_TOKEN',
  1 => 'Accept: application/json',
),
]);
$response = curl_exec($curl);
if ($response === false) throw new RuntimeException(curl_error($curl));
curl_close($curl);
$data = json_decode($response, true, 512, JSON_THROW_ON_ERROR);

PYTHON

import json
from urllib.request import Request, urlopen

headers = {
    "Authorization": "Basic YOUR_API_TOKEN",
    "Accept": "application/json"
}
data = None
request = Request("https://api.stayclean.io/api/v1/interventions?page=1&limit=25&sort=desc", data=data, headers=headers, method="GET")
with urlopen(request) as response:
    result = json.load(response)
Referenz erkunden