Sign inSign up

hometinker12/api-to-dns

By hometinker12

•Updated 13 days ago

FastAPI DNS REST API endpoint and admin UI for Azure, Cloudflare, Microsoft DNS, and BIND/TSIG.

Image
Networking
API management
Developer tools
1

1.4K

hometinker12/api-to-dns repository overview

⁠api-to-dns

Dockerized FastAPI service to manage DNS records through a protected admin web UI and secure API key authentication.

⁠Supported providers

  • Azure DNS
  • Cloudflare DNS (API v4)
  • Microsoft DNS (WinRM)
  • BIND / RFC 2136 dynamic updates with TSIG

⁠Features

  • Admin UI with username/password login
  • API keys with per-zone access control
  • Encrypted-at-rest provider credentials
  • REST /dns-record with GET, POST, PUT, PATCH, DELETE
  • Activity logging and email alerting
  • Optional HTTPS (uploaded cert, self-signed, or Let's Encrypt)

⁠Quick start

docker 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).

⁠API usage

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.

MethodBehavior
GETLook up records at a name
POSTCreate (409 if the type already exists)
PUTFull replace (404 if missing)
PATCHPartial update of ttl and/or values
DELETERemove (404 if missing)
⁠Create (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"]
  }'
⁠Replace (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"]
  }'
⁠Partial update (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 (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"
⁠Lookup (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"]}
  ]
}
⁠Validate an API key
curl -sS "http://localhost:8001/keycheck" \
  -H "X-API-Key: YOUR_API_KEY"

⁠Source

GitHub: https://github.com/hometinker12/api-to-dns⁠

Tag summary

Content type

Image

Digest

sha256:f7cb0c1b8…

Size

80.3 MB

Last updated

13 days ago

docker pull hometinker12/api-to-dns