API Endpoint
GET /dns
Extracts the hostname from the provided URL and returns all available DNS records.Any http or https URL. The hostname will be extracted and looked up.
Example Request
Success Response
The extracted hostname that was looked up
DNS records grouped by type. Only record types that exist for the hostname are included.
IPv4 address records
IPv6 address records
Canonical name records
Mail exchange records
Name server records
Text records
Start of authority records
Certification authority authorization records
The domain name for this record
The DNS record type (A, AAAA, CNAME, etc.)
Time to live in seconds
The record data (IP address, hostname, etc.)
Error Response
Error Codes
400— Missing or invalidurlparameter (not http/https)502— DNS lookup failed (DoH timeout or error)
Supported Record Types
The API queries for the following DNS record types:- A — IPv4 addresses
- AAAA — IPv6 addresses
- CNAME — Canonical names
- MX — Mail exchange servers
- NS — Name servers
- TXT — Text records
- SOA — Start of authority
- CAA — Certificate authority authorization
Deployment
Deploy
Follow the deployment wizard to deploy the Worker to your Cloudflare account. No additional configuration or bindings required.
Local Development
Implementation Details
- Uses Cloudflare’s public DNS over HTTPS (DoH) API
- Queries all record types in parallel for fast responses
- Stateless — no database or KV storage required
- Timeout protection on DoH requests
Cloudflare Features Used
- Workers — Edge compute runtime
- Fetch API — HTTP requests to Cloudflare DoH
- Edge Networking — Low-latency DNS lookups