DNS Lookup API

Query comprehensive DNS records for any domain using our REST API. Get A, AAAA, MX, TXT, NS, CAA, SRV, DNSKEY and more.

Last updated Nov 29, 2024

The DNS Lookup API allows you to query comprehensive DNS records for any domain. It returns all common record types including A, AAAA, MX, TXT, NS, CAA, SRV, DNSKEY, and more.

Endpoint

GET https://api.requestguard.com/v1/dns/lookup

Parameters

ParameterTypeRequiredDescription
domainstringYesThe domain name to query (e.g., example.com)

Response

The API returns a JSON object with the following structure:

{
  "success": true,
  "data": {
    "domain": "example.com",
    "queryTimeMs": 145,
    "dnssec": true,
    "dnsProvider": "Cloudflare",
    "records": [
      {
        "type": "A",
        "name": "example.com.",
        "value": "93.184.216.34",
        "ttl": 86400,
        "geo": {
          "country": "US",
          "asn": 15133,
          "asnName": "Edgecast Inc."
        }
      }
    ],
    "queriedAt": "2024-11-29T12:00:00.000Z"
  }
}

Response Fields

Root Object

FieldTypeDescription
successbooleanWhether the request was successful
dataobjectThe DNS query result

Data Object

FieldTypeDescription
domainstringThe queried domain name (normalized)
queryTimeMsnumberTotal query time in milliseconds
dnssecbooleanWhether DNSSEC is enabled for the domain
dnsProviderstring | nullDetected DNS provider (e.g., Cloudflare, AWS Route 53)
recordsarrayArray of DNS records
queriedAtstringISO 8601 timestamp of when the query was made

Record Object

FieldTypeDescription
typestringDNS record type (A, AAAA, MX, TXT, etc.)
namestringRecord name (usually ends with a dot)
valuestringRecord value
ttlnumberTime-to-live in seconds
geoobject | undefinedGeolocation data for A/AAAA records

Geo Object (for A/AAAA records)

FieldTypeDescription
ipstringThe IP address
countrystringTwo-letter country code
asnnumberAutonomous System Number
asnNamestringASN organization name

Supported Record Types

The API queries the following DNS record types:

Address Records

  • A - IPv4 address mapping
  • AAAA - IPv6 address mapping

Mail Records

  • MX - Mail exchange servers

Name Records

  • NS - Authoritative nameservers
  • CNAME - Canonical name aliases
  • SOA - Start of authority
  • PTR - Reverse DNS pointer

Text & Verification

  • TXT - Text records (SPF, DKIM, DMARC, etc.)

Service Discovery

  • SRV - Service location records
  • HTTPS - HTTPS service binding
  • SVCB - Service binding
  • NAPTR - Naming authority pointer

Security & Certificates

  • CAA - Certificate authority authorization
  • TLSA - DANE TLS authentication
  • SSHFP - SSH fingerprints
  • DNSKEY - DNSSEC public keys
  • DS - Delegation signer

Other

  • LOC - Geographic location

Example Request

curl "https://api.requestguard.com/v1/dns/lookup?domain=cloudflare.com"

Example Response

{
  "success": true,
  "data": {
    "domain": "cloudflare.com",
    "queryTimeMs": 234,
    "dnssec": true,
    "dnsProvider": "Cloudflare",
    "records": [
      {
        "type": "A",
        "name": "cloudflare.com.",
        "value": "104.16.132.229",
        "ttl": 300,
        "geo": {
          "ip": "104.16.132.229",
          "country": "US",
          "asn": 13335,
          "asnName": "CLOUDFLARENET"
        }
      },
      {
        "type": "AAAA",
        "name": "cloudflare.com.",
        "value": "2606:4700::6810:84e5",
        "ttl": 300
      },
      {
        "type": "MX",
        "name": "cloudflare.com.",
        "value": "10 mailstream-central.mxrecord.io.",
        "ttl": 300
      },
      {
        "type": "NS",
        "name": "cloudflare.com.",
        "value": "ns1.cloudflare.com.",
        "ttl": 86400
      },
      {
        "type": "TXT",
        "name": "cloudflare.com.",
        "value": "\"v=spf1 ip4:199.15.212.0/22 ip4:173.245.48.0/20 include:_spf.google.com ~all\"",
        "ttl": 300
      },
      {
        "type": "CAA",
        "name": "cloudflare.com.",
        "value": "0 issue \"digicert.com\"",
        "ttl": 300
      }
    ],
    "queriedAt": "2024-11-29T12:00:00.000Z"
  }
}

Error Responses

Invalid Domain

{
  "success": false,
  "error": {
    "code": "INVALID_DOMAIN",
    "message": "Invalid domain format"
  }
}

Domain Not Found

{
  "success": false,
  "error": {
    "code": "NOT_FOUND",
    "message": "No DNS records found for this domain"
  }
}

Rate Limits

PlanRequests per minute
Free10
Pro100
EnterpriseUnlimited

DNS Provider Detection

The API automatically detects the DNS provider based on NS records. Supported providers include:

  • Cloudflare
  • AWS Route 53
  • Google Cloud DNS
  • Azure DNS
  • GoDaddy
  • Namecheap
  • DigitalOcean
  • DNSimple
  • NS1
  • Dyn
  • UltraDNS
  • Akamai
  • Verisign
  • Hetzner
  • OVH
  • Gandi

DNSSEC Validation

The API checks for DNSSEC by examining the AD (Authenticated Data) flag in the DNS response. If DNSSEC is enabled and the chain of trust is valid, dnssec will be true.

IP Geolocation

For A and AAAA records, the API includes geolocation data obtained via Team Cymru’s DNS-based IP-to-ASN service. This includes:

  • Country code (ISO 3166-1 alpha-2)
  • Autonomous System Number (ASN)
  • ASN organization name

Try It Out

Use our interactive DNS Lookup Tool to query DNS records directly in your browser.