DNS Record Types Explained: A, AAAA, MX, TXT, CNAME, NS

The Domain Name System underpins nearly everything on the internet, yet many developers interact with it only when something breaks. Understanding different DNS record types -- and knowing how to query them programmatically -- helps you monitor infrastructure, debug connectivity issues, and validate configurations. The Apixies DNS Lookup API supports ten record types, and this guide explains each one with real query examples.

How to Query Any Record Type

Every example in this guide follows the same pattern. Send a GET request to the DNS Lookup endpoint with the domain and type parameters:

curl -H "X-API-Key: YOUR_API_KEY" \
  "https://apixies.io/api/v1/dns-lookup?domain=example.com&type=A"

The API returns a JSON object with a records array. Anonymous requests allow 20 lookups per day, and a free registered account gives you 75 requests/day. Get a free API key to unlock the higher limit.

A Records -- IPv4 Addresses

An A record maps a domain name to an IPv4 address. This is the most fundamental DNS record type and the one your browser uses every time you visit a website.

curl -H "X-API-Key: YOUR_API_KEY" \
  "https://apixies.io/api/v1/dns-lookup?domain=example.com&type=A"
{
  "records": [
    { "type": "A", "value": "93.184.216.34", "ttl": 3600 }
  ]
}

When to use it: Verifying that a domain points to the correct server, monitoring IP address changes after infrastructure migrations, and building health-check systems that confirm DNS is resolving as expected.

AAAA Records -- IPv6 Addresses

AAAA records serve the same purpose as A records but map to IPv6 addresses instead. As IPv6 adoption grows, querying AAAA records is increasingly important for verifying dual-stack configurations.

curl -H "X-API-Key: YOUR_API_KEY" \
  "https://apixies.io/api/v1/dns-lookup?domain=google.com&type=AAAA"
{
  "records": [
    { "type": "AAAA", "value": "2607:f8b0:4004:800::200e", "ttl": 300 }
  ]
}

When to use it: Confirming IPv6 readiness for a domain, auditing network configurations, and ensuring that services are reachable over both IPv4 and IPv6.

MX Records -- Mail Servers

MX (Mail Exchange) records identify the servers responsible for receiving email for a domain. Each record includes a priority value -- lower numbers indicate higher priority.

curl -H "X-API-Key: YOUR_API_KEY" \
  "https://apixies.io/api/v1/dns-lookup?domain=google.com&type=MX"
{
  "records": [
    { "type": "MX", "value": "smtp.google.com", "priority": 5, "ttl": 3600 },
    { "type": "MX", "value": "smtp2.google.com", "priority": 10, "ttl": 3600 }
  ]
}

When to use it: Validating that a domain can receive email before sending to it, diagnosing email delivery failures, and auditing mail infrastructure. For a detailed walkthrough, see the Check MX Records for Email Deliverability guide.

TXT Records -- Text Metadata

TXT records hold arbitrary text strings. In practice, they are most commonly used for email authentication (SPF, DKIM, DMARC), domain ownership verification (Google Search Console, SSL certificate issuance), and security policies.

curl -H "X-API-Key: YOUR_API_KEY" \
  "https://apixies.io/api/v1/dns-lookup?domain=google.com&type=TXT"

A single domain can have many TXT records, each serving a different purpose. Common patterns to look for:

  • v=spf1 ... -- SPF policy defining which servers may send email.
  • v=DKIM1; ... -- DKIM public key for email signature verification (usually on a subdomain).
  • v=DMARC1; ... -- DMARC policy for email authentication alignment (at _dmarc.domain.com).
  • google-site-verification=... -- Domain ownership proof for Google services.

When to use it: Auditing email security policies across a portfolio of domains, verifying domain ownership tokens, and debugging SPF/DKIM/DMARC configuration issues.

CNAME Records -- Domain Aliases

A CNAME (Canonical Name) record aliases one domain to another. The resolver follows the alias and resolves the target domain instead.

curl -H "X-API-Key: YOUR_API_KEY" \
  "https://apixies.io/api/v1/dns-lookup?domain=www.example.com&type=CNAME"
{
  "records": [
    { "type": "CNAME", "value": "example.com", "ttl": 3600 }
  ]
}

CNAME records are widely used to point subdomains to CDN endpoints (e.g., cdn.example.com to d1234.cloudfront.net), SaaS platforms, and load balancers.

When to use it: Confirming that a subdomain is correctly aliased to a CDN or hosting provider and verifying customer domain configurations in multi-tenant applications.

NS Records -- Authoritative Nameservers

NS (Name Server) records specify which DNS servers are authoritative for a domain -- the servers that hold the definitive records and respond to queries from resolvers.

curl -H "X-API-Key: YOUR_API_KEY" \
  "https://apixies.io/api/v1/dns-lookup?domain=example.com&type=NS"
{
  "records": [
    { "type": "NS", "value": "a.iana-servers.net", "ttl": 86400 },
    { "type": "NS", "value": "b.iana-servers.net", "ttl": 86400 }
  ]
}

When to use it: Verifying that a domain's nameservers have been updated after a DNS provider migration, confirming delegation is correct, and identifying which provider manages a domain's DNS.

SOA Records -- Zone Authority

The SOA (Start of Authority) record contains administrative information about a DNS zone: the primary nameserver, zone serial number, and timing parameters for transfers and caching.

curl -H "X-API-Key: YOUR_API_KEY" \
  "https://apixies.io/api/v1/dns-lookup?domain=example.com&type=SOA"

When to use it: Debugging DNS propagation by checking serial numbers and verifying zone configuration.

SRV Records -- Service Location

SRV (Service) records specify the hostname and port for specific services like SIP (VoIP), XMPP (chat), and LDAP. Each record includes priority, weight, port, and target fields.

curl -H "X-API-Key: YOUR_API_KEY" \
  "https://apixies.io/api/v1/dns-lookup?domain=_sip._tcp.example.com&type=SRV"

When to use it: Discovering service endpoints in enterprise environments and building DNS-based service discovery tools.

CAA Records -- Certificate Authority Authorization

CAA (Certificate Authority Authorization) records specify which certificate authorities are permitted to issue SSL/TLS certificates for a domain. This is a security measure that prevents unauthorized CAs from issuing certificates.

curl -H "X-API-Key: YOUR_API_KEY" \
  "https://apixies.io/api/v1/dns-lookup?domain=google.com&type=CAA"
{
  "records": [
    { "type": "CAA", "value": "0 issue \"pki.goog\"", "ttl": 86400 }
  ]
}

When to use it: Auditing SSL certificate policies and verifying that CAA records are in place before requesting a certificate.

PTR Records -- Reverse DNS

PTR (Pointer) records are the reverse of A records. They map an IP address back to a domain name. Reverse DNS lookups use a special domain format -- for IPv4, the IP octets are reversed and appended to in-addr.arpa.

curl -H "X-API-Key: YOUR_API_KEY" \
  "https://apixies.io/api/v1/dns-lookup?domain=34.216.184.93.in-addr.arpa&type=PTR"

When to use it: Verifying reverse DNS for mail servers (many receiving servers reject email from IPs without valid PTR records) and investigating the origin of network traffic.

Querying Multiple Record Types Programmatically

In practice, you often want a complete picture of a domain's DNS configuration. Here is a script that queries several record types in sequence:

import requests
import os

api_key = os.environ["APIXIES_KEY"]
domain = "example.com"
record_types = ["A", "AAAA", "MX", "TXT", "NS", "CAA"]

for rtype in record_types:
    response = requests.get(
        "https://apixies.io/api/v1/dns-lookup",
        params={"domain": domain, "type": rtype},
        headers={"X-API-Key": api_key},
    )
    data = response.json()
    count = len(data.get("records", []))
    print(f"{rtype:6s} -- {count} record(s) found")

With 75 requests/day on a free account, you can run a full audit across multiple record types for several domains per day.

Next Steps

The Apixies DNS Lookup API gives you a clean, consistent interface to query all of these record types without installing libraries or configuring resolvers.

Get your free API key and start exploring DNS records programmatically.

Try the DNS Lookup API

Free tier is for development & small projects. 75 requests/day with a registered account.

Getting Started

Explore

Resources

Get Started Free

Free for development and small projects.

Get Free API Key