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 Reverse Whois API web service
Here you’ll find short examples of using www.whoisxmlapi.com Hosted Reverse Whois Web API implemented in multiple languages.
You can view more sample code, incl. dealing with the API’s response formats, request parameters and more, in the repository.
Please, refer to Reverse Whois User Guide for request parameters and response schema description
using System;
using System.IO;
using System.Net;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
// Note that you need to make sure your Project is set to ".NET Framework 4"
// and NOT ".NET Framework 4 Client Profile". Once that is set, make sure the
// following references are present under the References tree under the
// project: Microsoft.CSharp, System, System.Web.Extensions, and System.XML.
namespace ReverseWhoisApi
{
public static class ReverseWhoisApiV2Sample
{
private const string ApiKey = "Your reverse whois api key";
private const string Url =
"https://reverse-whois.whoisxmlapi.com/api/v2";
private const string SearchParamsAdvanced =
@"{
advancedSearchTerms: [
{
field: 'RegistrantContact.Name',
term: 'Test'
}
],
sinceDate: '2018-07-12',
mode: 'purchase',
apiKey: 'API_KEY'
}";
private const string SearchParamsBasic =
@"{
basicSearchTerms: {
include: [
'test',
'US'
],
exclude: [
'Europe',
'EU'
]
},
sinceDate: '2018-07-12',
mode: 'purchase',
apiKey: 'API_KEY'
}";
private static void Main()
{
var responsePost = SendPostReverseWhois();
PrintResponse(responsePost);
responsePost = SendPostReverseWhois(true);
PrintResponse(responsePost);
// Prevent command window from closing automatically
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();
}
private static void PrintResponse(string response)
{
dynamic responseObject = JsonConvert.DeserializeObject(response);
if (responseObject != null)
{
Console.Write(responseObject);
Console.WriteLine("--------------------------------");
return;
}
Console.WriteLine(response);
Console.WriteLine();
}
private static string SendPostReverseWhois(bool isAdvanced=false)
{
Console.Write("Sending request to: " + Url + "\n");
var httpWebRequest = (HttpWebRequest)WebRequest.Create(Url);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
var searchParams =
isAdvanced ? SearchParamsAdvanced : SearchParamsBasic;
using (var streamWriter =
new StreamWriter(httpWebRequest.GetRequestStream()))
{
var json = searchParams.Replace("API_KEY", ApiKey);
var jsonData = JObject.Parse(json).ToString();
streamWriter.Write(jsonData);
streamWriter.Flush();
streamWriter.Close();
}
var res = "";
using (var response=(HttpWebResponse)httpWebRequest.GetResponse())
using (var responseStream = response.GetResponseStream())
{
if (responseStream == null || responseStream == Stream.Null)
{
return res;
}
using (var streamReader = new StreamReader(responseStream))
{
res = streamReader.ReadToEnd();
}
return res;
}
}
}
}
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import com.google.gson.*;
public class ReverseWhoisV2Sample
{
private String apiKey;
public static void main(String[] args) throws Exception
{
ReverseWhoisV2Sample query = new ReverseWhoisV2Sample();
// Fill in your details
query.setApiKey("Your reverse whois api key");
try {
String responseStringPost = query.sendPost();
query.prettyPrintJson(responseStringPost);
responseStringPost = query.sendPost(true);
query.prettyPrintJson(responseStringPost);
} catch (IOException e) {
e.printStackTrace();
}
}
public String getApiKey(boolean quotes)
{
if (quotes)
return "\"" + this.getApiKey() + "\"";
else
return this.getApiKey();
}
public void setApiKey(String apiKey)
{
this.apiKey = apiKey;
}
public String sendPost() throws Exception
{
return sendPost(false);
}
// HTTP POST request
public String sendPost(boolean isAdvanced) throws Exception
{
String userAgent = "Mozilla/5.0";
String url = "https://reverse-whois.whoisxmlapi.com/api/v2";
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("User-Agent", userAgent);
String terms = isAdvanced ? getAdvancedTerms() : getBasicTerms();
// Send POST request
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(terms);
wr.flush();
wr.close();
System.out.println("\nSending 'POST' request to URL : " + url);
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
return response.toString();
}
private String getAdvancedTerms()
{
String field = "\"field\": \"RegistrantContact.Name\"";
String term = "\"term\": \"Test\"";
String options = this.getRequestOptions();
String searchTerms = "{ " + field + ", " + term + " }";
String terms =
"\"advancedSearchTerms\": [" + searchTerms + "]";
return "{ " + terms + ", " + options +" }";
}
private String getApiKey()
{
return this.apiKey;
}
private String getBasicTerms()
{
String exclude = "\"exclude\": [\"pay\"]";
String include = "\"include\": [\"test\"]";
String options = this.getRequestOptions();
String terms =
"\"basicSearchTerms\": {" + include + ", " + exclude + "}";
return "{ " + terms + ", " + options +" }";
}
private String getRequestOptions()
{
return "\"sinceDate\": \"2018-07-16\","
+ "\"mode\": \"purchase\","
+ "\"apiKey\": " + this.getApiKey(true);
}
private void prettyPrintJson(String jsonString)
{
Gson gson = new GsonBuilder().setPrettyPrinting().create();
JsonParser jp = new JsonParser();
JsonElement je = jp.parse(jsonString);
String prettyJsonString = gson.toJson(je);
System.out.println("\n\n" + prettyJsonString);
System.out.println("----------------------------------------");
}
}
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
var url = "https://reverse-whois.whoisxmlapi.com/api/v2";
var apiKey = "Your reverse whois api key";
var post_data_basic = {
"apiKey": apiKey,
"sinceDate": "2018-07-15",
"mode": "purchase",
"basicSearchTerms": {
"include": [
"cinema",
],
"exclude": [
"online"
]
}
};
var post_data_advanced = {
"apiKey": apiKey,
"sinceDate": "2018-07-15",
"mode": "purchase",
"advancedSearchTerms": [{
"field": "RegistrantContact.Name",
"term": "Test"
}]
};
$(function() {
$.post(
url,
JSON.stringify(post_data_basic),
function(data) {
$("body").append("Basic:<br>" +
"<pre>" + JSON.stringify(data, null, 2) + "</pre>");
}
);
$.post(
url,
JSON.stringify(post_data_advanced),
function(data) {
$("body").append("Advanced:<br>" +
"<pre>" + JSON.stringify(data, null, 2) + "</pre>");
}
);
});
</script>
var https = require('https');
// Fill in your details
var api_key = 'Your reverse whois api key';
// Build the post string
var post_data_advanced = {
advancedSearchTerms: [
{
field: 'RegistrantContact.Name',
term: 'Test'
}
],
apiKey: api_key,
mode: 'purchase',
sinceDate: '2018-07-12'
};
var post_data_basic = {
basicSearchTerms: {
include: [
'test',
'US'
],
exclude: [
'Europe',
'EU'
],
},
apiKey: api_key,
mode: 'purchase',
sinceDate: '2018-07-12'
};
function api_call(data, callback)
{
var body = '';
var opts = {
hostname: 'reverse-whois.whoisxmlapi.com',
path: '/api/v2',
method:'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Content-Length': JSON.stringify(data).length
}
};
var req = https.request(opts, function(response) {
response.on('data', function(chunk) {
body += chunk;
});
response.on('end', function() {
callback(JSON.parse(body));
});
});
req.on('error', function(e) {
console.error(e);
process.exit(1);
});
req.write(JSON.stringify(data));
req.end();
}
// Send requests and log responses
api_call(post_data_basic, function(body) {
console.log('Basic:');
console.log(body);
api_call(post_data_advanced, function(body) {
console.log('Advanced:');
console.log(body);
});
});
<?php
$apiKey = 'Your reverse whois api key';
$termsAdvanced = array(
'advancedSearchTerms' => array(
array(
'field' => 'RegistrantContact.Name',
'term' => 'Test'
)
),
'mode' => 'purchase',
'apiKey' => $apiKey,
'sinceDate' => '2018-07-15'
);
$termsBasic = array(
'basicSearchTerms' => array(
'include' => array(
'test'
),
'exclude' => array(
'whois',
'api'
)
),
'mode' => 'purchase',
'apiKey' => $apiKey,
'sinceDate' => '2018-07-15'
);
function reverse_whois_api(array $data=array())
{
$header ="Content-Type: application/json\r\nAccept: application/json\r\n";
$url = 'https://reverse-whois.whoisxmlapi.com/api/v2';
$options = array(
'http' => array(
'method' => 'POST',
'header' => $header,
'content' => json_encode($data)
)
);
return file_get_contents($url, false, stream_context_create($options));
}
print('Basic:' . PHP_EOL);
print_r(json_decode(reverse_whois_api($termsBasic)));
print('Advanced:' . PHP_EOL);
print_r(json_decode(reverse_whois_api($termsAdvanced)));
#!/usr/bin/perl
use HTTP::Request::Common qw{ POST }; # From CPAN
use JSON qw( decode_json ); # From CPAN
use LWP::UserAgent; # From CPAN
use strict;
use warnings;
########################
# Fill in your details #
########################
my $api_key = 'Your reverse whois api key';
my $url = 'https://reverse-whois.whoisxmlapi.com/api/v2';
my $search_params_advanced = '{
"advancedSearchTerms": [
{
"field": "RegistrantContact.Name",
"term": "Test"
}
],
"apiKey": "' . $api_key . '",
"mode": "purchase",
"sinceDate": "2018-07-12"
}';
my $search_params_basic = '{
"basicSearchTerms": {
"include": [
"test"
],
"exclude": [
"whois",
"api"
]
},
"apiKey": "' . $api_key . '",
"mode": "purchase",
"sinceDate": "2018-06-15"
}';
#######################
# Basic search #
#######################
my $response = JSON->new->decode(reverseWhoisApiSearch(0));
print "Basic\n---\n";
print JSON->new->pretty->encode($response);
#######################
# Advanced search #
#######################
$response = JSON->new->decode(reverseWhoisApiSearch(1));
print "Advanced\n---\n";
print JSON->new->pretty->encode($response);
#######################
# Getting the data #
#######################
sub reverseWhoisApiSearch {
my ($isAdvanced) = @_;
my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });
my $req = HTTP::Request->new('POST', $url);
my $search_params =
$isAdvanced ? $search_params_advanced : $search_params_basic;
$req->header('Content-Type' => 'application/json');
$req->header('Accept', 'application/json');
$req->content($search_params);
my $result = $ua->request($req);
return $result->content;
}
########################
# Fill in your details #
########################
$apiKey = 'Your reverse whois api key'
$paramsAdvanced = @{
advancedSearchTerms = @(
@{
field = 'RegistrantContact.Name'
term = 'Test'
}
)
apiKey = $apiKey
mode = 'purchase'
sinceDate = '2018-07-15'
} | ConvertTo-Json
$paramsBasic = @{
basicSearchTerms = @{
include = @(
'test'
)
exclude = @(
'whois',
'api'
)
}
apiKey = $apiKey
mode = 'purchase'
sinceDate = '2018-07-15'
} | ConvertTo-Json
#######################
# POST request #
#######################
$uri = 'https://reverse-whois.whoisxmlapi.com/api/v2'
$response = Invoke-WebRequest -Uri $uri -Method POST -Body $paramsBasic `
-ContentType 'application/json'
echo 'Basic:'
echo $response.content | convertfrom-json | convertto-json -depth 10
$response = Invoke-WebRequest -Uri $uri -Method POST -Body $paramsAdvanced `
-ContentType 'application/json'
echo 'Advanced:'
echo $response.content | convertfrom-json | convertto-json -depth 10
try:
import http.client as http
except ImportError:
import httplib as http
import json
api_key = 'Your reverse whois api key'
def print_response(txt):
response_json = json.loads(txt)
print(json.dumps(response_json, indent=4, sort_keys=True))
payload_advanced = {
'advancedSearchTerms': [
{
'field': 'RegistrantContact.Name',
'term': 'Test'
}
],
'searchType': 'current',
'sinceDate': '2018-07-18',
'mode': 'purchase',
'apiKey': api_key,
'responseFormat': 'json'
}
payload_basic = {
'basicSearchTerms': {
'include': [
'test',
'US'
],
'exclude': [
'Europe',
'EU'
],
},
'searchType': 'current',
'sinceDate': '2018-07-18',
'mode': 'purchase',
'apiKey': api_key,
'responseFormat': 'json'
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
conn = http.HTTPSConnection('reverse-whois.whoisxmlapi.com')
# Basic search
conn.request('POST', '/api/v2', json.dumps(payload_basic), headers)
response = conn.getresponse()
text = response.read().decode('utf8')
print('Basic:')
print_response(text)
# Advanced search
conn.request('POST', '/api/v2', json.dumps(payload_advanced), headers)
response = conn.getresponse()
text = response.read().decode('utf8')
print('Advanced:')
print_response(text)
require 'json'
require 'net/https'
require 'openssl'
require 'uri'
require 'yaml' # only needed to print the returned result in a very pretty way
url = 'https://reverse-whois.whoisxmlapi.com/api/v2'
########################
# Fill in your details #
########################
key = 'Your reverse whois api key'
params_advanced = {
advancedSearchTerms: [
{
field: 'RegistrantContact.Name',
term: 'Test'
}
],
mode: 'purchase',
apiKey: key,
sinceDate: '2018-07-15'
}
params_basic = {
basicSearchTerms: {
include: %w[
test
],
exclude: %w[
whois
api
]
},
mode: 'purchase',
apiKey: key,
sinceDate: '2018-07-15'
}
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
# Connect using ssl
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(uri.request_uri)
# Set headers
request.add_field('Content-Type', 'application/json')
request.add_field('Accept', 'application/json')
# Basic search
request.body = params_basic.to_json
response = http.request(request)
# Print pretty parsed json
puts 'Basic:'
puts JSON.parse(response.body).to_yaml
# Advanced search
request.body = params_advanced.to_json
response = http.request(request)
puts "\nAdvanced:"
puts JSON.parse(response.body).to_yaml