15

I want to be able to get whois data (and idn domains too) by client-side javascript. Is it possible? Maybe some free REST-like WhoIs service exists?

xpda
  • 15,585
  • 8
  • 51
  • 82
Dmitry Belaventsev
  • 6,347
  • 12
  • 52
  • 75

5 Answers5

10

Try using http://whoisxmlapi.com service.

The service URL: http://www.whoisxmlapi.com/whoisserver/WhoisService

You need to specify outputFormat=json and domainName=insert_domain_here parameters..

Example URL: http://www.whoisxmlapi.com/whoisserver/WhoisService?outputFormat=json&domainName=stackoverflow.com.

Example code (using jQuery to simplify AJAX communication):

$.ajax({
  url: 'http://www.whoisxmlapi.com/whoisserver/WhoisService',
  dataType: 'jsonp',
  data: {
    domainName: 'stackoverflow.com',
    outputFormat: 'json'
  },
  success: function(data) {
    console.log(data.WhoisRecord);
  }
});

HERE is the working code.

Update:

The service mentioned above is not free, but there are several free whois services that are providing HTML output and by using YQL you can retrieve the HTML as a JS. See THIS answer for more details.

Example (using jQuery & jquery.xdomainajax):

var domain = 'stackoverflow.com';
$.ajax({
  url: 'http://whois.webhosting.info/' + domain,
  type: 'GET',
  success: function(res) {
    // using jQuery to find table with class "body_text" and appending it to a page
    $(res.responseText).find('table.body_text').appendTo('body');
  }
});

HERE is the working code.

You need to have a look at the structure of the HTML document and select, process and display the data you are interested in. The example is just printing whole table without any processing.

Community
  • 1
  • 1
kubetz
  • 8,485
  • 1
  • 22
  • 27
  • thx! it looks very cool! but as I understand - this service allows only about 50 queries and if i want more I should pay for it. is it so? or maybe I have some misunderstanding. – Dmitry Belaventsev Dec 08 '11 at 19:03
  • @dizpers Yes, that service is not free. I suggested another alternative solution - see update of the answer :). – kubetz Dec 08 '11 at 19:51
  • 3
    I created a similar service at http://www.robowhois.com/. We provide JSON output so that you can easily parse it with JavaScript. – Simone Carletti Dec 09 '11 at 12:24
  • @dizpers Please see my updated answer and if you have no more questions then accepted it. – kubetz Dec 10 '11 at 11:52
  • What is the request limit of your last example? – Sisir Jul 11 '12 at 08:52
  • @dizpers I used to use the great service by [robowhois](http://robowhois.com) but they are discontinued now so i switched to [this provider](https://jsonwhoisapi.com) instead, hope that helps! – sousdev Sep 18 '16 at 11:53
5

What you can do if you have exec() enabled in php is create a php file with the following:

exec('whois domain.com');

and then create aa .ajax() request to the php script where you pass the domain name and output it.

Meisam Mulla
  • 1,845
  • 3
  • 23
  • 37
  • thx! but for some reasons I need to use queries only for remote servers. – Dmitry Belaventsev Dec 08 '11 at 18:37
  • Wrong advice. Do not shell out from PHP just to run a whois command. You have specific libraries inside of PHP to do whois queries or just open a TCP socket on port 43 this is enough, and read RFC3912 for details. – Patrick Mevzek Jan 04 '18 at 15:15
2

An npm package called node-whois did the job for me. It's server side JS, not client side, but perhaps this will help someone.

demiters
  • 596
  • 7
  • 28
1

i'm also trying to find out a free whois provider with JSON output, couldn't find one. But, there are WHOIS windows client provided by Microsoft and like someone mentioned above, we can use PHP/cgi to get the details.

I'm not sure whether there's any WHOIS lookup/query provider gives JSON output at free cost.

BTW, i just found this phpWhois from sourceforge.net, would be a good starting point to use whois from the server. This is the library used by RoboWhois / RubyWhois provider as well.

palmplam
  • 707
  • 9
  • 20
user793439
  • 11
  • 2
1

You could use whois npm module

https://www.npmjs.com/package/whois

Also in mac terminal, try this to see whois data

whois google.com

Bharath Kumar
  • 351
  • 3
  • 3