Based on the scripts in your homelab, here are the Unifi API examples you're looking for. The code uses the **Network Integration API** (`/proxy/network/integration/v1/...`) and the **Static DNS API** (`/proxy/network/v2/api/...`). ### 1. Authentication Both scripts use a Bearer-style header `X-API-Key`. * **Source:** `active/device_unifi/update_dns.py` & `active/aws_route53/unifi_to_aws.py` ```python headers = { "Accept": "application/json", "X-API-Key": os.environ.get("API_KEY") } ``` ### 2. List All Sites Used to find the `site_id` required for other calls. * **Endpoint:** `GET /proxy/network/integration/v1/sites` * **Source:** `active/device_unifi/update_dns.py` ```python # Example from update_dns.py response = requests.get( f"{UNIFI_API_ENDPOINT}/proxy/network/integration/v1/sites", headers={"X-API-Key": UNIFI_API_KEY}, verify=False ) sites = response.json().get("data") ``` ### 3. Fetch Static DNS Devices Returns a list of devices with hostnames and IPs. * **Endpoint:** `GET /proxy/network/v2/api/site/default/static-dns/devices` * **Source:** `active/aws_route53/unifi_to_aws.py` ```python # Example from unifi_to_aws.py devices_url = "https://10.1.0.1/proxy/network/v2/api/site/default/static-dns/devices" devices_data = requests.get(devices_url, headers=headers, verify=False).json() # Result format: [{"hostname": "...", "ip_address": "..."}, ...] ``` ### 4. Fetch DNS Policies Returns DNS records (policies) for a specific site. * **Endpoint:** `GET /proxy/network/integration/v1/sites/{site_id}/dns/policies` * **Source:** `active/device_unifi/update_dns.py` & `active/aws_route53/unifi_to_aws.py` ```python # Example from unifi_to_aws.py site_id = "88f7af54-98f8-306a-a1c7-c9349722b1f6" policies_url = f"https://10.1.0.1/proxy/network/integration/v1/sites/{site_id}/dns/policies" policies_data = requests.get(policies_url, headers=headers, verify=False).json() # Result format: {"data": [{"domain": "...", "ipv4Address": "..."}, ...]} ``` ### 5. DNS Record Structure If you are creating or updating records (like in `unifi_to_aws.py`), the expected payload structure is: ```json { "Action": "UPSERT", "ResourceRecordSet": { "Name": "mydevice.reeselink.com", "Type": "A", "TTL": 60, "ResourceRecords": [ {"Value": "192.168.1.50"} ] } } ```