DNS Lookup API
Query A, AAAA, MX, TXT, NS, CNAME, SOA, CAA, SRV and more for any domain, or reverse-lookup an IP (PTR), via DNS over HTTPS. Clean JSON output.
The DNS Lookup API resolves the records of a domain and returns them as tidy JSON. By default it queries A, AAAA, MX, TXT, NS and CNAME in parallel; choose your own set with type (comma separated) from A, AAAA, CNAME, MX, TXT, NS, SOA, PTR, SRV, NAPTR, DS, DNSKEY, HTTPS and CAA.
Records are normalised for you: MX records come as {priority, exchange}, TXT strings are unquoted and joined, trailing dots are removed, and every record carries its TTL. The overall response status is the DNS RCODE (NOERROR, NXDOMAIN, SERVFAIL…), so you can tell a missing record from a domain that does not exist. You can pass a bare domain or a URL – the scheme and path are stripped.
For reverse DNS, pass an IP address as domain with type=PTR: the API builds the in-addr.arpa / ip6.arpa name. Queries go through Cloudflare’s 1.1.1.1 DNS over HTTPS resolver and are cached for 5 minutes.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
domain | query | string | yes | Domain name or URL (or an IP for type=PTR). | |
type | query | string | no | A,AAAA,MX,TXT,NS,CNAME | Comma-separated record types: A, AAAA, CNAME, MX, TXT, NS, SOA, PTR, SRV, NAPTR, DS, DNSKEY, HTTPS, CAA. |
Example
curl "https://apibox.io.vn/v1/dns?domain=github.com&type=A,MX" \
-H "Authorization: Bearer YOUR_API_KEY"const res = await fetch('https://apibox.io.vn/v1/dns?domain=github.com&type=A,MX', {
method: 'GET',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
});
const data = await res.json();
console.log(data);import requests
res = requests.get(
"https://apibox.io.vn/v1/dns?domain=github.com&type=A,MX",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/dns?domain=github.com&type=A,MX');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"domain": "github.com",
"status": "NOERROR",
"records": {
"A": [
{
"value": "20.205.243.166",
"ttl": 23
}
],
"MX": [
{
"priority": 0,
"exchange": "github-com.mail.protection.outlook.com",
"ttl": 300
}
]
}
}
Use cases
- Verify SPF, DKIM and DMARC TXT records when setting up e-mail
- Check that a customer’s custom domain points to your servers
- Monitor DNS changes and propagation after a migration
- Reverse-lookup IPs from logs to hostnames
FAQ
How do I check the MX records of a domain?
Call /v1/dns?domain=example.com&type=MX. Records are returned sorted as the resolver gives them, each with priority, exchange host and TTL.
How do I do a reverse DNS (PTR) lookup?
Pass the IP as the domain: /v1/dns?domain=8.8.8.8&type=PTR returns dns.google. IPv6 addresses are supported as well.
Why do I see old values after changing DNS?
Resolvers cache records for their TTL, and APIBox caches each answer for 5 minutes. Wait for the old TTL to expire; the ttl field shows how long the current answer stays cached.
Related APIs
IP Geolocation
Look up the country, region, city, coordinates, ASN and ISP of any IPv4 or IPv6 address – or your own IP – in one fast JSON call.
@Email Validator
Validate e-mail addresses: syntax, MX/A records, ~120k disposable domains, role accounts, free providers and typo hints like gmial.com → gmail.com.
☎Phone Number Validator
Validate and format phone numbers for 240+ countries: E.164, international and national formats, country, calling code and line type (mobile, fixed line…).