Brand Alert API
Bulk Whois API
DNS Lookup API
Domain Availability API
Email Verification API
Registrant Alert API
Reverse Whois API
Whois API

Making a query to DNS Lookup API web service

Here you’ll find short examples of using www.whoisxmlapi.com Hosted DNS Lookup Web API implemented in multiple languages.

You can view more sample code, incl. dealing with the API’s response formats and more, in the repository.

Please, refer to DNS Lookup API User Guide for authentication instructions.

API key authentication

using System;
using System.IO;
using System.Net;
using System.Text;

class Program {
    public const string domain = "example.com";
    public const string apiKey = "Your DNS Lookup API Key";
    public const string type = "_all";

    static void Main() {
        string url="https://www.whoisxmlapi.com/whoisserver/DNSService?"
                  + $"apiKey={apiKey}&domainName={domain}&type={type}";
        string whoisData = string.Empty;

        HttpWebRequest rq = (HttpWebRequest)WebRequest.Create(url);

        using (HttpWebResponse response = (HttpWebResponse)rq.GetResponse())
        using (Stream stream = response.GetResponseStream())
        using (StreamReader reader = new StreamReader(stream)) {
            whoisData = reader.ReadToEnd();
        }
        Console.WriteLine(whoisData);
    }
}

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;

public class DomainAvailabilityApi {
    public static final String DOMAIN = "example.com";
    public static final String API_KEY = "Your DNS Lookup API Key";
    public static final String TYPE = "_all";

    public static void main(String[] args) throws Exception {
        long time = System.currentTimeMillis();

        String url = "https://www.whoisxmlapi.com/whoisserver/DNSService?"
                   + "apiKey=" + API_KEY + "&domainName=" + DOMAIN + "&type=" + TYPE;

        try (java.util.Scanner s =
                new java.util.Scanner(new java.net.URL(url).openStream())) {
            System.out.println(s.useDelimiter("\\A").next());
        }
    }
}

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
    var domain = "example.com";
    var apiKey = "Your DNS Lookup API Key";
    var type = "_all";

    $(function () {
        $.ajax({
            url: "https://www.whoisxmlapi.com/whoisserver/DNSService",
            dataType: "jsonp",
            data: {apiKey: apiKey, domainName: domain, type: type},
            success: function(data) {
                $("body").append("<pre>"+ JSON.stringify(data,"",2)+"</pre>");
            }
        });
    });
</script>

var http = require('http');

var domain = 'example.com';
var apiKey = 'Your DNS Lookup API public key';
var type = '_all';

var url = 'https://www.whoisxmlapi.com/whoisserver/DNSService?'
    + 'apiKey=' + apiKey + '&domainName=' + domain + '&type=' + type;

http.get(url, function(response) {
    var str = '';
    response.on('data', function(chunk) { str += chunk; });
    response.on('end', function() { console.log(str); });
}).end();

<?php

$domain = 'example.com';
$apiKey = 'Your DNS Lookup API Key';
$type = '_all';

$url = 'https://www.whoisxmlapi.com/whoisserver/DNSService?'
    . "apiKey={$apiKey}&domainName={$domain}&type={$type}";

print(file_get_contents($url));

#!/usr/bin/perl

my $domain = 'example.com';
my $apiKey = 'Your DNS Lookup API Key';
my $type = '_all';

my $url = 'https://www.whoisxmlapi.com/whoisserver/DNSService?'
        . "apiKey=$apiKey&domainName=$domain&type=$type"

print get($url);

$domain = "example.com"
$apiKey = "Your DNS Lookup API Key"
$type = "_all"

$uri = "https://www.whoisxmlapi.com/whoisserver/DNSService?"
     + "apiKey=$($apiKey)&domainName=$($domain)&type=$($type)"

echo (Invoke-WebRequest -Uri $uri).Content

try:
    from urllib.request import urlopen
except ImportError:
    from urllib2 import urlopen

domain = 'example.com'
apiKey = 'Your DNS Lookup API Key'
type = '_all'

url = 'https://www.whoisxmlapi.com/whoisserver/DNSService?'
    + 'apiKey=' + apiKey + '&domainName=' + domain + '&type=' + type

print(urlopen(url).read().decode('utf8'))