FastAPI DNS REST API endpoint and admin UI for Azure, Cloudflare, Microsoft DNS, and BIND/TSIG.
1.4K
Dockerized FastAPI service to manage DNS records through a protected admin web UI and secure API key authentication.
/dns-record with GET, POST, PUT, PATCH, DELETEdocker pull hometinker12/api-to-dns:latest
Use with the project's docker-compose.yml and .env.example. Required runtime secrets: SECRET_KEY, ENCRYPTION_KEY, ADMIN_USER, ADMIN_PASSWORD.
Default admin UI: http://localhost:8001/login (Compose maps host 8001 → container 8000).
Authenticate with X-API-Key: <key> or Authorization: Bearer <key>.
zone_name is the zone configuration name from the admin UI (for example prod-azure), not the DNS domain. Responses include dns_zone (the provider domain, for example example.com). Supported record_type values: A, AAAA, CNAME, TXT.
| Method | Behavior |
|---|---|
GET | Look up records at a name |
POST | Create (409 if the type already exists) |
PUT | Full replace (404 if missing) |
PATCH | Partial update of ttl and/or values |
DELETE | Remove (404 if missing) |
POST)curl -sS -X POST "http://localhost:8001/dns-record" \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"zone_name": "prod-azure",
"record_type": "A",
"record_name": "www",
"ttl": 300,
"values": ["192.0.2.10"]
}'
PUT)curl -sS -X PUT "http://localhost:8001/dns-record" \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"zone_name": "prod-azure",
"record_type": "A",
"record_name": "www",
"ttl": 600,
"values": ["192.0.2.20"]
}'
PATCH)# Update values only (TTL preserved)
curl -sS -X PATCH "http://localhost:8001/dns-record" \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"zone_name": "prod-azure",
"record_type": "A",
"record_name": "www",
"values": ["192.0.2.30"]
}'
# Update TTL only (values preserved)
curl -sS -X PATCH "http://localhost:8001/dns-record" \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"zone_name": "prod-azure",
"record_type": "A",
"record_name": "www",
"ttl": 600
}'
DELETE)curl -sS -X DELETE \
"http://localhost:8001/dns-record?zone_name=prod-azure&record_name=www&record_type=A" \
-H "X-API-Key: YOUR_API_KEY"
GET)curl -sS \
"http://localhost:8001/dns-record?zone_name=prod-azure&record_name=www&record_type=A" \
-H "X-API-Key: YOUR_API_KEY"
Example response when records exist:
{
"status": "success",
"zone_name": "prod-azure",
"record_name": "www",
"records": [
{"record_name": "www", "record_type": "A", "ttl": 300, "values": ["192.0.2.10"]}
]
}
curl -sS "http://localhost:8001/keycheck" \
-H "X-API-Key: YOUR_API_KEY"
Content type
Image
Digest
sha256:f7cb0c1b8…
Size
80.3 MB
Last updated
13 days ago
docker pull hometinker12/api-to-dns