Документація
API довідник
Автентифікація
Усі API-запити потребують заголовка X-API-Key. Отримайте ключ у Dashboard → API Key.
curl -H "X-API-Key: YOUR_KEY" https://seconddns.com/api/zonesЛіміти запитів
Запити з API-ключем: 300 зап/хв. Перевищення ліміту повертає 429 Too Many Requests.
Ендпоінти
GET
/api/zonesСписок зон
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Додати зону
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}Отримати зону за іменем
Response 200:
{ "id": "cm2xk7...", "name": "example.com", ... }PATCH
/api/zones/{id}Оновити master IP
Content-Type: application/json
{ "masterIp": "5.6.7.8" }
Response 200:
{ "id": "cm2xk7...", "masterIp": "5.6.7.8", "status": "pending", ... }DELETE
/api/zones/{id}Видалити зону
Response 200:
{ "success": true }GET
/api/health/zonesСтан зон (усі зони)
Response 200 (JSON):
{
"summary": { "total": 5, "synced": 4, "stale": 1, ... },
"zones": [ ... ]
}
Response 200 (?format=nagios):
OK - all 5 zones syncedGET
/api/health/zones/{name}Стан зони (одна зона)
GET /api/health/zones/example.com GET /api/health/zones/example.com?format=nagios
Відповіді з помилками
401Unauthorized — missing or invalid API key
404Not found — zone doesn't exist
422Validation error — invalid input
429Too many requests — rate limit exceeded
Приклади коду
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"