get all dns records of a domain using Namecheap API

In the previous post we learn basic methods of namecheap api which are useful to buy domain, check the availability of  domain , expirey of domain, domain renew, reactivation of expired domain and fetch all the information of requrested domain.

In todays post we will see how to do DNS of  a requested domain using   namecheap api method.

Before start  this tutorial first of all we should know about DNS. In Basic words Domain Name System is used to resolvie human readable hostnames like (www.shortlearner.com) into machine readable IP address like 67.211.208.67. DNS also provides us other information about requested domain name such as mail services.

Why DNS is Necessary

DNS is one of the most important task when we host our website.  Basically DNS is like a contact list for the internet. We know the person’s name but we don’t remember their contact number, so you simply look it up in your contact list.

For an example you visit https://www.shortlarner.com  in your browser, your computer  uses DNS to retrieve the website’s ip address of 67.21.208.67. without DNS the website will show only search by its ip http://67.211.208.67
Now we see some of methods/functions which are helpful for access all the dns related activities.

namecheap.domains.dns.setDefault

this methods is use to set domain to use namecheap’s default DNS Servers.

Example

https://api.namecheap.com/xml.response?ApiUser=apiexample&
ApiKey=56b4c87ef4fd49cb96d915c0db68194&UserName=apiexample&
Command=namecheap.domains.dns.setDefault&ClientIp=192.168.1.109&
SLD=domain&TLD=com

namecheap.domains.dns.setCustom

this method is useul for set domain to use custom DNS Server.

Example

https://api.namecheap.com/xml.response?ApiUser=apiexample&
ApiKey=56b4c87ef4fd49cb96d915c0db68194&UserName=apiexample&
Command=namecheap.domains.dns.setCustom&ClientIp=192.168.1.109&
SLD=domain&TLD=com&NameServers=dns1.name-servers.com,dns2.name-servers.com

namecheap.domains.dns.getList

this method is used to get a list of DNS Servers associated with the requested domain.

Example

https://api.namecheap.com/xml.response?ApiUser=apiexample&
ApiKey=56b4c87ef4fd49cb96d915c0db68194&UserName=apiexample&
Command=namecheap.domains.dns.getList&ClientIp=192.168.1.109&
SLD=domain&TLD=com

namecheap.domains.dns.getHosts

this method is used for Retrieves DNS host record settings for the requested domain.

Example

https://api.namecheap.com/xml.response?ApiUser=apiexample&
ApiKey=56b4c87ef4fd49cb96d915c0db68194&UserName=apiexample&
Command=namecheap.domains.dns.getHosts&ClientIp=192.168.1.109
&SLD=domain&TLD=com

namecheap.domains.dns.getEmailForwarding

this method is useful for Gets email forwarding settings for the requested domain.

Example

https://api.namecheap.com/xml.response?ApiUser=apiexample&
ApiKey=56b4c87ef4fd49cb96d915c0db68194&UserName=apiexample&
Command=namecheap.domains.dns.getEmailForwarding&
ClientIp=192.168.1.109&DomainName=domain.com

namecheap.domains.dns.setEmailForwarding

this method is useful for Sets email forwarding for a domain name.

Example

https://api.namecheap.com/xml.response?ApiUser=apiexample&
ApiKey=56b4c87ef4fd49cb96d915c0db68194&UserName=apiexample&
Command=namecheap.domains.dns.setEmailForwarding&
ClientIp=192.168.1.109&DomainName=domain.com&mailbox1=info&
ForwardTo1=domaininfo@gmail.com&mailbox2=careers&
ForwardTo2=domaincareer@gmail.com

namecheap.domains.dns.setHosts

Sets DNS host records settings for the requested domain.

Example

http://api.namecheap.com/xml.response?apiuser=demo&
apikey=d41474b94e7d4536baabb074a09c96bd&username=demo&
Command=namecheap.domains.dns.setHosts&
ClientIp=122.178.155.204&SLD=domain51&
TLD=com&HostName1=@&RecordType1=URL&
Address1=http://www.namecheap.com&
TTL1=100&HostName2=mynewcomp&RecordType2=A&
Address2=12.56.67.78&TTL2=1000