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 Whois API web service

Here you’ll find short examples of using Hosted Whois Web API implemented in multiple languages.

You can view more sample code in the repository.

Please, refer to Whois API Docs for authentication instructions.

using System;
namespace WhoisApiSample
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            string apiKey = "Your API Key";

            string domain = "whoisxmlapi.com";
            string url = "https://www.whoisxmlapi.com/whoisserver/WhoisService?"
                         + "domainName=" + domain
                         + "&apiKey=" + apiKey
                         + "&outputFormat=" + "JSON";

            try
            {
                // Download JSON into a dynamic object
                dynamic result = new System.Net.WebClient().DownloadString(url);

                // Print a nice informative string
                Console.WriteLine("JSON:\n");
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("An unkown error has occurred!");
            }

        }
    }
}

import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.GetMethod;


public class WhoisApiSample {
    private Logger logger = Logger.getLogger(WhoisApiSample.class.getName());

    public static void main(String[]args) {
        new WhoisApiSample().getWhoisRecordUsingApiKey();
    }

    private void getWhoisRecordUsingApiKey() {

        String apiKey = "Your API key";

        String domainName = "whoisxmlapi.com";
        getWhoisInfo(domainName, apiKey);
    }

    private String executeURL(String url) {
        HttpClient c = new HttpClient();
        System.out.println(url);
        HttpMethod m = new GetMethod(url);
        String res = null;
        try {
            c.executeMethod(m);
            res = new String(m.getResponseBody());
        } catch (Exception e) {
            logger.log(Level.SEVERE, "Cannot get url", e);
        } finally {
            m.releaseConnection();
        }
        return res;
    }

    public void getWhoisInfo(String domainName, String apiKey) {
        StringBuilder sb = new StringBuilder();
        sb.append("https://www.whoisxmlapi.com/whoisserver/WhoisService?");
        sb.append("apiKey=");
        sb.append(apiKey);
        sb.append("&domainName=");
        sb.append(domainName);
        String url = sb.toString();

        String result = executeURL(url);
        if (result != null) {
            logger.log(Level.INFO, "result: " + result);
        }
    }
}

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript">

    const apiKey = "Your API key";

    const url = 'https://www.whoisxmlapi.com/whoisserver/WhoisService?';
    const domainName = 'whoisxmlapi.com';

    $(function () {
        $.ajax({
            url: url,
            dataType: "json",
            data: {
                domainName: domainName,
                apiKey: apiKey,
                outputFormat: 'JSON'
            },
            complete: function(data) {
                $("body").append("<pre>" + JSON.stringify(data.responseJSON, "",2) +"</pre>");
            }
        });
    });
</script>

var https = require('https');
var querystring = require('querystring');

var url = "https://www.whoisxmlapi.com/"
    +"whoisserver/WhoisService?";

var parameters = {
    domainName: 'google.com',
    apiKey: 'Your API key',
    outputFormat: 'json'
};

url = url + querystring.stringify(parameters);

https.get(url, function (res) {
    const statusCode = res.statusCode;

    if (statusCode !== 200) {
        console.log('Request failed: '
            + statusCode
        );
    }

    var rawData = '';

    res.on('data', function(chunk) {
        rawData += chunk;
    });
    res.on('end', function () {
        try {
            var parsedData = JSON.parse(rawData);
            if (parsedData.WhoisRecord) {
                console.log(
                    'Domain name: '
                    + parsedData.WhoisRecord.domainName
                );
                console.log(
                    'Contact email: '
                    + parsedData.WhoisRecord.contactEmail
                );
            } else {
                console.log(parsedData);
            }
        } catch (e) {
            console.log(e.message);
        }
    })
}).on('error', function(e) {
    console.log("Error: " + e.message);
});

<?php

$domainName = 'whoisxmlapi.com';
$apiKey = 'Your API key';

$url = "https://www.whoisxmlapi.com/whoisserver/WhoisService"
    . "?domainName={$domainName}&apiKey={$apiKey}&outputFormat=JSON";

print(file_get_contents($url));


#!/usr/bin/perl

use LWP::Simple;                # From CPAN
use JSON qw( decode_json );     # From CPAN
use Data::Dumper;               # Perl core module
use strict;                     # Good practice
use warnings;                   # Good practice

########################
# Fill in your details #
########################
my $api_key = "Your API key";

my $domain_name = 'whoisxmlapi.com';
my $base_url = 'https://www.whoisxmlapi.com/whoisserver/WhoisService';


print "result\n" . getWhoisRecord();

sub getWhoisRecord {
    my $url = "$base_url?apiKey=$api_key&domainName=$domain_name&outputFormat=JSON";

    print "Get data by URL: $url\n";
    # 'get' is exported by LWP::Simple;
    my $object = get($url);
    die "Could not get $base_url!" unless defined $object;
    return $object
}

########################
# Fill in your details #
########################
$apiKey = "Your API key"

$domainName = "whoisxmlapi.com"

$uri = "https://www.whoisxmlapi.com/whoisserver/WhoisService?"`
    + "domainName=$domainName"`
    + "&apiKey=$apiKey"`
    + "&outputFormat=JSON"


#######################
# Use a JSON resource #
#######################

$j = Invoke-WebRequest -Uri $uri
echo "JSON:`n---" $j.content "`n"

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

domainName = 'whoisxmlapi.com';
apiKey = 'Your API key'

url = 'https://www.whoisxmlapi.com/whoisserver/WhoisService?'\
    + 'domainName=' + domainName + '&apiKey=' + apiKey + "&outputFormat=JSON"

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

require 'open-uri'
require 'json'
require 'rexml/document'
require 'rexml/xpath'
require 'yaml'		# only needed to print the returned result in a very pretty way

########################
# Fill in your details #
########################
apiKey = "Your API key"

domainName = "whoisxmlapi.com"

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

format = "JSON"
# Open the resource
buffer = open(url + '&outputFormat=' + format).read

# Parse the JSON result
result = JSON.parse(buffer)

# Print out a nice informative string
puts "JSON:\n" + result.to_yaml + "\n"