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 Brand Alert API web service

Here you’ll find short examples of using brand-alert.whoisxmlapi.com Hosted Brand Alert 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 Brand Alert API Documentation for request parameters and response schema description


using Hs = System.Collections.Hashtable;
using Js = System.Web.Script.Serialization.JavaScriptSerializer;

namespace brandAlertApiExample
{
    internal class BrandAlertApiExample
    {
        public static void Main(string[] args)
        {
            string key = "Your Brand Alert 2.0 API key";
            string[] terms = {"facebook"};
            string mode = "preview";
            string url = "https://brand-alert.whoisxmlapi.com/api/v2";

            var data = new Hs {{"apiKey", key},{"mode", mode},
                {"includeSearchTerms", terms}};

            try {
                var request = System.Net.WebRequest.Create(url);
                request.Method = "POST";
                var arg =System.Text.Encoding.UTF8.GetBytes(new Js().Serialize(data));
                request.GetRequestStream().Write(arg, 0, arg.Length);
                System.Console.WriteLine(new System.IO.StreamReader(
                    request.GetResponse().GetResponseStream()).ReadToEnd());
            }
            catch (System.Exception e) {
                System.Console.WriteLine("An error has occurred!");
            }
        }
    }
}


public class BrandAlertApiRequest {
    public static void main(String[]args){
        String API_URL="https://brand-alert.whoisxmlapi.com/api/v2";
        String body="{\"apiKey\": \"Your Brand Alert 2.0 API key\","
		+ "\"mode\": \"preview\","
		+ "\"includeSearchTerms\": [\"facebook\"]}";
        try {
            java.net.URL url = new java.net.URL(API_URL);
            java.net.HttpURLConnection http =
                (java.net.HttpURLConnection)url.openConnection();
            http.setRequestMethod("POST");
            http.setDoOutput(true);
            http.setDoInput(true);
            byte[] data = body.getBytes("UTF-8");
            http.setFixedLengthStreamingMode(data.length);
            http.setRequestProperty("Content-Type",
                "application/json; charset=UTF-8");
            http.connect();
            http.getOutputStream().write(data);
            byte[] response = new byte[1024];
            http.getInputStream().read(response, 0, 1024);
            System.out.print(new String(response, "UTF-8"));
        } catch (Exception ex) {
    		ex.printStackTrace();
        }
    }
}

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
    //     Fill in your details
    var key = "Your Brand Alert 2.0 API key";
    var term = "facebook";
    var format = "json";
    var mode = 'preview';

    window.addEventListener("load", onPageLoad, false);

    function onPageLoad() {
        $.ajax({
            type: 'POST',
            url: "https://brand-alert.whoisxmlapi.com/api/v2",
            dataType: "json",
            contentType: 'application/json',
            data: JSON.stringify({
                includeSearchTerms: [term],
                apiKey: key,
                mode: mode,
                outputFormat: format
            }),
            success: function(data) {
                $("body").append("<pre>"+ JSON.stringify(data,"",2)+"</pre>");
            }
        });
    }
</script>

const http = require('https');

const key = 'Your Brand Alert 2.0 API key';
const terms = ["facebook"];
const mode = "preview";
const host = 'brand-alert.whoisxmlapi.com';
const path = '/api/v2';
const data = {
    apiKey: key,
    includeSearchTerms: terms,
    mode: mode
};
const options = {
    method: "POST",
    hostname: host,
    path: path
};
var req = http.request(options, function(response) {
    var str = '';
    response.on('data', function(chunk) { str += chunk; });
    response.on('end', function() { console.log(str); });
});
req.write(JSON.stringify(data));
req.end();

<?php
    $data = [
        'apiKey' => 'Your Brand Alert 2.0 API key',
        'mode' => 'preview',
        'includeSearchTerms' => ['facebook'],
    ];

    $stream = stream_context_create(
        [
            'http' => [
                'method' => 'POST',
                'header' => 'Content-Type: application/json/r/n',
                'content' => json_encode($data),
            ]
        ]
    );

    $url = "https://brand-alert.whoisxmlapi.com/api/v2";

    print(file_get_contents($url, false, $stream));

#!/usr/bin/perl

use LWP::UserAgent;              # From CPAN
use JSON;                        # From CPAN
use HTTP::Request;
use Encode qw( encode_utf8 );
use Data::Dumper;                # Perl core module
use strict;
use warnings;

my $url = "https://brand-alert.whoisxmlapi.com/api/v2";
my @terms = ["facebook"];
my $key = "Your Brand Alert 2.0 API key";
my $mode = 'preview';
my $body = {'apiKey'=>$key, 'mode'=>$mode, 'includeSearchTerms'=>@terms};
my $header = ['Content-Type' => 'application/json; charset=UTF-8'];

my $req = HTTP::Request->new(
    'POST', $url, $header, encode_utf8(encode_json($body))
);

my $ua = LWP::UserAgent->new();

print "Response ". $ua->request($req)->content();

$url = "https://brand-alert.whoisxmlapi.com/api/v2"

$data = @{apiKey="Your Brand Alert 2.0 API key"`
    ;mode="preview";includeSearchTerms=@('facebook')} | ConvertTo-Json
$r = Invoke-WebRequest -Uri $url -Method POST -Body $data
echo "JSON:`n---" $r.content "`n"

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

from json import dumps

terms = ['facebook'];
key = 'Your Brand Alert 2.0 API key'
mode = 'preview'

data = {'includeSearchTerms': terms, 'apiKey': key, 'mode': mode}
url = 'https://brand-alert.whoisxmlapi.com/api/v2'

req = Request(url)

print(urlopen(req, dumps(data).encode('utf-8')).read().decode('utf8'))

require 'uri'
require 'json'
require 'net/https'

key = "Your Brand Alert 2.0 API key"
mode = "preview"
terms = ["facebook"]

url = 'https://brand-alert.whoisxmlapi.com/api/v2'
data = {apiKey: key, mode: mode, includeSearchTerms: terms}
uri = URI.parse(url)
http, http.use_ssl = Net::HTTP.new(uri.host, uri.port), true
req, req.body = Net::HTTP::Post.new(uri.request_uri), data.to_json
http.request(req).body

puts http.request(req).body