DNS Lookup Template
- Go
A domain’s DNS records: where it points, who handles its mail, and more.
A Go app that looks up DNS records. Enter a domain and see its IPv4 and IPv6 addresses and mail servers, and on paid plans its aliases, name servers, TXT and SOA records. It uses only the Go standard library. Use it to check a customer’s DNS before verifying their domain, or look records up from the command line.

What it does
- Every record type
- A, AAAA and MX on every plan; CNAME, NS, TXT and SOA on paid plans. Empty types are skipped.
- No dependencies
- Plain net/http and encoding/json, so there is nothing to install beyond Go.
- A web app and a CLI
- go run ./cmd/dev serves the page and its function; go run ./cmd/dnslookup works in the terminal.
- Keeps your key private
- The page calls a server route that holds the key, checks the input and limits each visitor to 10 lookups a minute.
- Deploys as a Go function
- Vercel runs api/lookup.go as a function and serves the page from its CDN.
How it works
The Vercel function: it checks the domain and calls DNS Lookup.
func Handler(w http.ResponseWriter, r *http.Request) {
if _, err := apiverve.APIKey(); err != nil {
fail(w, err)
return
}
if apiverve.RateLimited(clientIP(r)) {
fail(w, &apiverve.Error{Message: "Too many requests. Wait a minute and try again.", Status: http.StatusTooManyRequests})
return
}
domain := apiverve.CleanDomain(r.URL.Query().Get("domain"))
if domain == "" {
fail(w, &apiverve.Error{Message: "Enter a domain, like example.com.", Status: http.StatusBadRequest})
return
}
var data json.RawMessage
if err := apiverve.Call("dnslookup", url.Values{"domain": {domain}}, &data); err != nil {
fail(w, err)
return
}
w.Header().Set("Content-Type", "application/json")
w.Write(data)
}Deploy it
- Get a free API key
The free plan includes 200 credits a month, no card needed. Create your key.
- Deploy it
Click Deploy to Vercel. Vercel copies the repo to your GitHub account and asks for
APIVERVE_API_KEY: paste your key there. - Open your app
Vercel builds it and gives you a live URL, usually in about a minute. Every push to the repo redeploys it.
Try the DNS Lookup API — the call this template makes
No key required to try it. Get a key to use it in your app.
{
"status": "ok",
"error": null,
"data": {
"domain": "myspace.com",
"records": {
"A": [
"34.111.176.156"
],
"AAAA": null,
"CNAME": null,
"MX": [
{
"exchange": "us-smtp-inbound-1.mimecast.com",
"priority": 10
},
{
"exchange": "us-smtp-inbound-2.mimecast.com",
"priority": 10
}
],
"NS": [
"ns-cloud-a4.googledomains.com",
"ns-cloud-a1.googledomains.com",
"ns-cloud-a2.googledomains.com",
"ns-cloud-a3.googledomains.com"
],
"PTR": null,
"SRV": null,
"SOA": {
"nsname": "ns-cloud-a1.googledomains.com",
"hostmaster": "cloud-dns-hostmaster.google.com",
"serial": 2,
"refresh": 21600,
"retry": 3600,
"expire": 259200,
"minttl": 300
},
"TXT": [
"cr40m536tje9on1slld9bi81bg",
"qpdYoeakhlmAxsnmxgAVFmJgUSibqb/y+Eu6GGn8pdmLf+mFGIB3jhRAxIC5KObsPMES9MW2c+oOrpOo/lCQVw==",
"oZ19a+EOIwWVDPJ7POj14UAGBfzk9xcJMmsTUAMUy7H82sDuVCxvw9rZqdg3znFrdTH04+49zd1djhEAt0ooiA==",
"MS=ms89904786",
"google-site-verification=eu-3gW1JePvsGRRCaEvH17YUOTFJNofm4lnz2Pk0LTc",
"google-site-verification=q0iWqpcfOBclAJaCeWh83v62QQ4uCgbWObQ08p37qgU",
"al4upe6q5cl13sg4srvfivflvg",
"v=spf1 mx ip4:63.208.226.34 ip4:204.16.32.0/22 ip4:67.134.143.0/24 ip4:216.205.243.0/24 ip4:34.85.156.5/32 ip4:35.245.108.108/32 ip4:34.86.129.193/32 ip4:34.86.134.94/32 ip4:34.85.222.234/32 ip4:34.86.176.234/32 ip4:34.86.125.212/32 ip4:34.85.224.60/32 ip4:34.86.160.49/32 ip4:35.245.64.166/32 ip4:35.188.226.11/32 ip4:34.86.208.228/32 ip4:34.85.216.144/32 ip4:35.221.22.153/32 ip4:34.86.137.108/32 ip4:34.86.51.35/32 ip4:34.150.221.40/32 ip4:34.85.216.70/32 ip4:34.86.37.191/32 ip4:34.85.214.215/32 ip4:35.236.234.82/32 ip4:34.86.161.241/32 ip4:216.32.181.16 ip4:216.178.32.0/20 ip4:168.235.224.0/24 include:_netblocks.mimecast.com -all",
"cj65vjpq0s1v9u7vfo020c6rel"
],
"CAA": null
},
"summary": {
"hasIPv6": false,
"hasMailServers": true,
"hasSPF": true
}
}
}