16

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?

1

5 Answers 5

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.

6
  • 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. Dec 8, 2011 at 19:03
  • @dizpers Yes, that service is not free. I suggested another alternative solution - see update of the answer :).
    – kubetz
    Dec 8, 2011 at 19:51
  • 3
    I created a similar service at robowhois.com. We provide JSON output so that you can easily parse it with JavaScript. Dec 9, 2011 at 12:24
  • @dizpers Please see my updated answer and if you have no more questions then accepted it.
    – kubetz
    Dec 10, 2011 at 11:52
  • What is the request limit of your last example?
    – Sisir
    Jul 11, 2012 at 8:52
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.

2
  • thx! but for some reasons I need to use queries only for remote servers. Dec 8, 2011 at 18:37
  • 1
    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. Jan 4, 2018 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.

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.

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

1
  • Looks like it does not work with io domains
    – Shota
    Jan 5 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.