DNS Records API
URL Meta also offers a simple API to fetch DNS records of any domain. Given a domain name and record type (e.g: A, AAAA, CNAME, MX, TXT, etc.), the API will return the DNS records of that domain in JSON format.
Auth
The API requires the same authorization as the /meta API. Follow the auth guide to add the required headers and your API key with requests.
Usage
| Key | Value | Help |
|---|---|---|
| Endpoint | api.urlmeta.org/dns | Should always be accessed over https |
| Method | GET |
Query Parameters
| Key | Value | Help |
|---|---|---|
| domain | The domain to fetch the DNS of. | required - Only the domain name. E.g.: google.com |
| record | The type of records you want to fetch. | optional - Case-insensitive. E.g.: A, NS, MX. Default: A |
Example
To get the NS record for backupdiary.com, we'll use:
https://api.urlmeta.org/dns?domain=backupdiary.com&record=nsResponse
The API will always return JSON response. Here's the response schema returned by the DNS API.
{
"result": {
"status": "OK"
},
"dns": [ ... ]
}dns key will be an array, it would contain the DNS records of the requested type.
Here is the example response of the above API call:
{
"result": {
"status": "OK"
},
"dns": [
{
"type": "NS",
"ttl": 21600,
"value": "isla.ns.cloudflare.com."
},
{
"type": "NS",
"ttl": 21600,
"value": "norm.ns.cloudflare.com."
}
]
}parsedTXT value
The TXT records are often used to store SPF, DKIM, and DMARC, site verifications. They are usually stored in the key=value format seperated by a semicolon (;).
The DNS API parses the TXT records and returns them in a more usable format.
For example, the following DMARC TXT record:
v=DMARC1; p=quarantine; pct=100; rua=mailto:re+pwdjsi9384gea@dmarc.postmarkapp.com; sp=quarantine; aspf=r;Will be returned as:
{
"type": "TXT",
"value": "v=DMARC1; p=quarantine; pct=100; rua=mailto:re+pwdjsi9384gea@dmarc.postmarkapp.com; sp=quarantine; aspf=r;",
"parsedTXT": {
"v": "DMARC1",
"p": "quarantine",
"pct": "100",
"rua": "mailto:re+pwdjsi9384gea@dmarc.postmarkapp.com",
"sp": "quarantine",
"aspf": "r"
}
}Supported record types
Our API supports all the standard DNS record types, inlcuding:
A: Returns the IPv4 address of the domain.NS: The nameservers of the domain.CNAME: Returns the canonical name.SOA: Start of authority record.PTR: The reverse DNS lookup of the domain.HINFO: Host information of the domain.MINFO: Mailbox or mail list information.MX: Mail exchange records.TXT: Text records.SIG: Signature.KEY: Public key.AAAA: IPv6 address.CERT: Certificate.DNSKEY: DNS public key.SPF: Sender Policy Framework.
All of these are dependent on the DNS records of the domain. If the domain doesn't have the requested record, the API will return an empty array.
Special record types
In addition to the standard records, we also support the following values for record parameter.
BIMI: Brand Indicator Message Identification (BIMI) Records are used to specify the location of the logo and certificate for a domain.DMARC: Domain-based Message Authentication, Reporting, and Conformance (DMARC) records are used to specify the policy for emails sent from the domain.
These were added to make it easier to fetch these records, as they are not standard DNS records. If you have any suggestions, please let us know.
Common Issues
-
The
CNAMErecord does not return anything for the root domain.This is because the root domain is not a CNAME, it's an
Arecord. If you want to fetch theCNAMErecord of the root domain, you can usewwwas the domain name. This type is mostly used to get the address a sub-domain is pointing to. For example, usingsomething.example.comis going to return theCNAMErecord. -
All the
TXTrecords are not returned.Only the
TXTrecords of the given domain will be returned. Some records, like DKIM are stored as the sub-domains of the root domain. For example, the DKIM record ofexample.comcan be stored asemailapp._domainkey.example.com. To fetch this record, you'll useemailapp._domainkey.example.comas the domain name.