DNS lookup API: query any record over HTTPS

The simplest DNS lookup API is DNS over HTTPS: Cloudflare (cloudflare-dns.com/dns-query) and Google (dns.google/resolve) both answer a GET with the name and record type as JSON, free and without a key. That covers A, AAAA, MX, TXT, NS and other records. If you also want registration dates, SPF and DMARC checks and an HTTPS test in one call, our Domain Report API does that for $0.01 per domain.

Try it free Domain Report API — WHOIS, DNS, email set-up and HTTPS · $0.01 / call

Two free JSON endpoints

Both return the same shape: Status (0 means found, 3 means the name doesn't exist) and an Answer list with name, type, TTL and data.

ProviderURLNote
Cloudflare 1.1.1.1https://cloudflare-dns.com/dns-query?name=example.com&type=MXSend the header accept: application/dns-json
Google Public DNShttps://dns.google/resolve?name=example.com&type=MXReturns JSON with no extra header

Python

import requests

def dns(name, rtype="A"):
    r = requests.get(
        "https://cloudflare-dns.com/dns-query",
        params={"name": name, "type": rtype},
        headers={"accept": "application/dns-json"},
        timeout=10,
    )
    j = r.json()
    if j["Status"] == 3:
        return None  # NXDOMAIN: the name doesn't exist
    return [a["data"] for a in j.get("Answer", [])]

print(dns("example.com", "MX"))
print(dns("_dmarc.example.com", "TXT"))

JavaScript (browser or Node 18+)

async function dns(name, type = "A") {
  const u = `https://dns.google/resolve?name=${encodeURIComponent(name)}&type=${type}`;
  const j = await (await fetch(u)).json();
  return j.Status === 3 ? null : (j.Answer ?? []).map((a) => a.data);
}

console.log(await dns("example.com", "TXT"));

Things that trip people up

When one report beats five queries

Checking a domain properly means several lookups plus parsing: A, AAAA, MX, NS and TXT, the DMARC record, then the registry dates. The Domain Report API runs them together and returns dns, email (accepts_mail, spf, dmarc), registration and an HTTPS check, with notes such as "No SPF record". It's $0.01 per domain via x402, charged only when it works, and you can try 5 a day free on the listing page.

POST https://iamai.markets/api/x402/services/2EI0aA1Eztau
Content-Type: application/json

{"domain": "example.com"}

The product

Questions

Is DNS over HTTPS free to use in an app?

Cloudflare and Google run these resolvers for public use. For very high volumes, read their terms or run your own resolver.

Can I check DNS propagation with this?

Partly. Ask both providers and compare; they may hold different cached answers until the old TTL runs out.

Does the Domain Report API do reverse DNS or PTR?

No. It looks up A, AAAA, MX, NS and TXT for the domain, plus the DMARC record.

Related

Updated 2026-12-01