Dokumentation

API-Referenz

Authentifizierung

Alle API-Anfragen erfordern einen X-API-Key-Header. Holen Sie Ihren Schlüssel unter Dashboard → API Key.

curl -H "X-API-Key: YOUR_KEY" https://seconddns.com/api/zones

Rate Limits

API-Key-Anfragen: 300 Anf./Min. Bei Überschreitung wird 429 Too Many Requests zurückgegeben.

Endpunkte

GET/api/zones

Zonen auflisten

Response 200:
[
  {
    "id": "cm2xk7...",
    "name": "example.com",
    "masterIp": "1.2.3.4",
    "status": "active",
    "serial": 2024041502,
    "recordCount": 12,
    "healthStatus": "synced",
    "masterSerial": "2024041502",
    "ourSerial": "2024041502"
  }
]
POST/api/zones

Zone hinzufügen

Content-Type: application/json

{ "name": "example.com", "masterIp": "1.2.3.4" }

Response 201:
{ "id": "cm2xk7...", "name": "example.com", "status": "pending", ... }
GET/api/zones/by-name/{name}

Zone nach Name abrufen

Response 200:
{ "id": "cm2xk7...", "name": "example.com", ... }
PATCH/api/zones/{id}

Master-IP aktualisieren

Content-Type: application/json

{ "masterIp": "5.6.7.8" }

Response 200:
{ "id": "cm2xk7...", "masterIp": "5.6.7.8", "status": "pending", ... }
DELETE/api/zones/{id}

Zone löschen

Response 200:
{ "success": true }
GET/api/health/zones

Zonenstatus (alle Zonen)

Response 200 (JSON):
{
  "summary": { "total": 5, "synced": 4, "stale": 1, ... },
  "zones": [ ... ]
}

Response 200 (?format=nagios):
OK - all 5 zones synced
GET/api/health/zones/{name}

Zonenstatus (einzelne Zone)

GET /api/health/zones/example.com
GET /api/health/zones/example.com?format=nagios

Fehlerantworten

401Unauthorized — missing or invalid API key
404Not found — zone doesn't exist
422Validation error — invalid input
429Too many requests — rate limit exceeded

Codebeispiele

Python

import requests

API = "https://seconddns.com/api"
KEY = "your-api-key"
HEADERS = {"X-API-Key": KEY}

# List zones
zones = requests.get(f"{API}/zones", headers=HEADERS).json()

# Add zone
requests.post(f"{API}/zones", headers={**HEADERS, "Content-Type": "application/json"},
              json={"name": "example.com", "masterIp": "1.2.3.4"})

# Check health
health = requests.get(f"{API}/health/zones", headers=HEADERS).json()
print(f"Synced: {health['summary']['synced']}, Stale: {health['summary']['stale']}")

Bash / curl

API_KEY="your-api-key"

# List zones
curl -H "X-API-Key: $API_KEY" https://seconddns.com/api/zones

# Add zone
curl -X POST -H "X-API-Key: $API_KEY" -H "Content-Type: application/json" \
  -d '{"name":"example.com","masterIp":"1.2.3.4"}' \
  https://seconddns.com/api/zones

# Health check (Nagios format)
curl -H "X-API-Key: $API_KEY" "https://seconddns.com/api/health/zones?format=nagios"