WHOIS API

This API allows you to get information of a domain.

Access APIDownload

Description

This allows you to get WHOIS information using PHP. It gathers domain and registrar information from WHOIS (Who-Is) servers.

The API is also released under the LGPL, so you can integrate the API within your sites.

Installation

By using this API, you agree to Tevine's policies.

Simply extract the getwhois.php file to any place you want to use. You can then access the file directly using the following parameters:

  • domain: The domain without http://
  • server: The WHOIS server

Using the API requires you to have fsockopen() enabled on your web host.

Note: Usage of WHOIS information has to be under compliance with the relevant terms and conditions of the third parties hosting the WHOIS server.

How it works

This API accesses a WHOIS server (e.g. rs.internic.net) via port 43 (default). The script then sends a request to the WHOIS server, and the server returns the raw WHOIS information.

The code:

function whois($domain, $server="rs.internic.net")
{ 
    $fp = fsockopen ($server, 43, &$errno, &$errstr) or die("$errstr ($errno)");
    fputs($fp, "$domain\n");
    while (!feof($fp))
        echo fgets($fp, 2048)."<br>";
    fclose($fp); 
} 
whois('example.com');

Other servers can be used as well. Here is a list of WHOIS servers.

Download