DNS Lookup API

The DNS Lookup API retrieves DNS records for any given domain.

/v1/dnslookup GET

https://api.api-ninjas.com/v1/dnslookup

Returns a list of DNS records associated with a particular domain. Currently the following record types are supported:

A premium only
AAAA premium only
CNAME premium only
MX premium only
NS
PTR
SRV
SOA
TXT premium only
CAA

Parameters

  • domain  required

    Valid domain to check (e.g. example.com). For top-level domains other than .com, a premium subscription is required.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Sample Request Live Demo!

domain
https://api.api-ninjas.com/v1/dnslookup?domain=example.com

Sample Response

JSON
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 [ { "record_type": "A", "value": "93.184.215.14" }, { "record_type": "AAAA", "value": "2606:2800:21f:cb07:6820:80da:af6b:8b2c" }, { "record_type": "MX", "priority": 0, "value": "." }, { "record_type": "NS", "value": "b.iana-servers.net." }, { "record_type": "NS", "value": "a.iana-servers.net." }, { "record_type": "SOA", "mname": "ns.icann.org.", "rname": "noc.dns.icann.org.", "serial": 2024041801, "refresh": 7200, "retry": 3600, "expire": 1209600, "ttl": 3600 }, { "record_type": "TXT", "value": "v=spf1 -all" }, { "record_type": "TXT", "value": "wgyf8z8cgvm2qmxpnbnldrcltvk4xqfn" } ]

Code Examples

1 2 3 4 5 6 7 8 9 import requests domain = 'example.com' api_url = 'https://api.api-ninjas.com/v1/dnslookup?domain={}'.format(domain) response = requests.get(api_url, headers={'X-Api-Key': 'YOUR_API_KEY'}) if response.status_code == requests.codes.ok: print(response.text) else: print("Error:", response.status_code, response.text)

If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.