🚀 Experience the new and improved APIVoid! Check out what's new

DNS Lookup API: Query DNS A, AAAA, MX, NS, CAA, TXT

A JSON API to get common DNS records such as A, AAAA, MX, NS, CAA, TXT, SRV, CNAME, PTR. Use this API to get all required DNS records of a domain, supports multiple DNS records in a single API call.

Consumes 1 credit per API call

# Example Curl request from the command line:
                          
curl -X POST "https://api.apivoid.com/v2/dns-lookup" \
     -H "Content-Type: application/json" \
     -H "X-API-Key: YOUR_API_KEY_HERE" \
     -d '{
           "host":"example.com",
           "dns_types":"A,AAAA,MX,NS,TXT,SOA,DMARC,CAA,SRV"
         }'
         
# Example JSON output for a 200 HTTP status code:

{
    "host": "example.com",
    "records": {
        "a": [
            {
                "target": "93.184.215.14",
                "ttl": 3380
            }
        ],
        "aaaa": [
            {
                "target": "2606:2800:21f:cb07:6820:80da:af6b:8b2c",
                "ttl": 3380
            }
        ],
        "caa": [
            {
                "flag": 0,
                "tag": "iodef",
                "ttl": 3600,
                "value": "mailto:caa-violations@stripe.com"
            },
            {
                "flag": 0,
                "tag": "issue",
                "ttl": 3600,
                "value": "amazon.com"
            },
            {
                "flag": 0,
                "tag": "issue",
                "ttl": 3600,
                "value": "digicert.com"
            },
            {
                "flag": 0,
                "tag": "issue",
                "ttl": 3600,
                "value": "visa.com"
            }
        ],
        "dmarc": [
            {
                "target": "v=DMARC1;p=reject;sp=reject;adkim=s;aspf=s",
                "ttl": 3390
            }
        ],
        "mx": [
            {
                "pref": 10,
                "target": "alt1.gmail-smtp-in.l.google.com",
                "ttl": 2700
            },
            {
                "pref": 20,
                "target": "alt2.gmail-smtp-in.l.google.com",
                "ttl": 2700
            },
            {
                "pref": 30,
                "target": "alt3.gmail-smtp-in.l.google.com",
                "ttl": 2700
            },
            {
                "pref": 40,
                "target": "alt4.gmail-smtp-in.l.google.com",
                "ttl": 2700
            }
        ],
        "ns": [
            {
                "target": "b.iana-servers.net",
                "ttl": 86180
            },
            {
                "target": "a.iana-servers.net",
                "ttl": 86180
            }
        ],
        "soa": [
            {
                "expire": 1209600,
                "minttl": 3600,
                "mname": "ns.icann.org",
                "refresh": 7200,
                "retry": 3600,
                "rname": "noc@dns.icann.org",
                "serial": 2024081460,
                "ttl": 3380
            }
        ],
        "srv": [
            {
                "port": 5060,
                "priority": 50,
                "target": "ygg2.vp.vc",
                "ttl": 1800,
                "weight": 100
            },
            {
                "port": 5060,
                "priority": 10,
                "target": "ygg1.vp.vc",
                "ttl": 1800,
                "weight": 100
            }
        ]
        "txt": [
            {
                "target": "v=spf1 -all",
                "ttl": 86180
            },
            {
                "target": "wgyf8z8cgvm2qmxpnbnldrcltvk4xqfn",
                "ttl": 86180
            }
        ]
    },
    "elapsed_ms": 28
}
Code analysis

Key Features

Get DNS records, specify multiple DNS records, fast response

Businesses and startups use this DNS Lookup API to check common DNS records (A, AAAA, TXT, NS, MX, CAA) of their own domain names or of third-party domains, verify if a DNS record is present.

Multiple DNS Records

You can specify a single DNS record or multiple DNS records (comma separated) in a single API call.

All Common DNS Records

This API supports all most common DNS records, such as the A record (IPv4), AAAA (IPv6), TXT, MX, NS.

DNS Records Details

Other than returning the requested DNS records, the API also returns the TTL (Time to Live) data.

Fast Response

The submitted domain is analyzed in real-time and the response is returned in 1 second (or less) on average.

Common Use Cases

Take a look at some real-world use cases of this API service

Our API can be used in many ways, from cybersecurity tasks to marketing-specific tasks. Here we showcase the most popular use cases according to our customers usage:

All DNS Records

This API can be used to get all common DNS records of a specific domain in a single API call.

Check Domains List

Check a list of domains with this API to extract DNS records of all domains for research purposes.

Enrich SIEM Data

Using a SIEM platform? Add context to security incidents, populate domain DNS records data.

Validate DNS Records

Use this API to verify if a domain has a specific DNS record (e.g TXT record) configured correctly.

Use cases

USAGE EXAMPLE

Learn how seamless it is to add and use DNS Lookup API anywhere you want

All it takes is a HTTPS POST request with JSON payload to our endpoint, and you’ll receive the response within seconds, usually within 1-2 seconds. Here are a few code examples to use the API:

$domain = 'facebook.com';

$apiUrl = 'https://api.apivoid.com/v2/dns-lookup';
$apiKey = 'your_api_key_here';

$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json', 'X-API-Key: ' . $apiKey]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['host' => $domain, 'dns_types' => 'A,AAAA,MX,NS,TXT,SOA,DMARC,CAA,SRV']));
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode === 200) {
    $responseData = json_decode($response, true);

    print_r($responseData);
    
    // Print the list of DNS A records
    print_r($responseData['records']['a'] ?? []);
    
    // Print the list of DNS NS records
    print_r($responseData['records']['ns'] ?? []);
    
    // Print the list of DNS MX records
    print_r($responseData['records']['mx'] ?? []);
    
    // Print the list of DNS TXT records
    print_r($responseData['records']['txt'] ?? []);
}

Start using our API services, it takes just a few minutes

Create your account, pick a subscription plan, and make your first API call instantly with your API key—simple as that!

Get started now