Installation
First, install the library:Basic usage
The library provides two main functions:getDnsRecords()- Get specific DNS record types for a hostnamegetAllDnsRecords()- Discover all DNS records for a domain
Get specific DNS records
UsegetDnsRecords() to retrieve records of a specific type:
Get all DNS records
UsegetAllDnsRecords() to discover all DNS records for a domain, including subdomains:
Complete example
Here’s a complete example that demonstrates both functions:Expected output
When you query all DNS records, you’ll receive an array with various record types:API reference
getDnsRecords()
name(string) - Fully qualified domain name (e.g.,'google.com'or'mail.apple.com')type(string, optional) - Record type:'A','AAAA','TXT','MX','CNAME','NS','SOA', etc. Defaults to'A'resolver(string, optional) - DNS resolver to use:'cloudflare-dns','google-dns','node-dns','node-dig', or'deno-dns'. Auto-selected if not specified
getAllDnsRecords()
domain(string) - Valid domain name (e.g.,'google.com')options(object, optional) - Configuration options:resolver(string) - Which DNS resolver to usecommonSubdomainsCheck(boolean) - Check for common subdomains from built-in list. Default:truesubdomains(string[]) - Array of extra subdomains to check for
DnsRecord type
Next steps
API Reference
Explore the complete API documentation
Examples
See more usage examples and patterns