Need help? Call Live Support at +31 (0) 38 453 07 59

The IsProxy interface offers the most efficient way to check domain name validity and availability. It reduces overhead by using a telnet based protocol that allows multiple checks to be made in parallel. The interface can be used most effectively by reusing existing sessions as much as possible, this will lower the overhead on session creation and authentication.

Because the IsProxy uses a unencrypted protocol and is mostly used in customer facing systems we strongly advice to create a separate user specifically to use for the IsProxy. This user only needs the permission "CHECK_DOMAIN".

Connection

The API is available on two different locations. A production environment and a test environment.

  • Production: Host is.yoursrs.com, Port 2001
  • Test: Host is.yoursrs-ote.com, Port 2001
Commands

The IsProxy supports a number of commands.

STARTTLS
Upgrade to a encrypted TLS connection. The response to this command will be send unencrypted, when the client recieves the "100 OK" response the TLS negotiation can be started.
Possible responses:
  • 100 OK
LOGIN <username> <password>
Login to the session.
Possible responses:
  • 100 Login ok
  • 400 Login failed
  • 400 Wrong number of arguments
  • 400 Already authenticated
IS <domain>
Check a domain name. Multiple IS commands can be send at once, each domain name will be checked in parallel. Responses will be returned as the become available, not necessarily in the order they were requested.
Possible responses:
  • <domain> available
  • <domain> not available
  • <domain> invalid domain
  • <domain> error
  • 400 not authenticated
ENABLE <function>
Enable extra functionality for the IsProxy.
Possible functions:
  • reason
    • adds a reason to the IS response, characters (), are escaped using a \: <domain> not available (reason=<reason>)
  • premium
    • enables premium support, will return prices in case of premium: <domain> available (type=premium,price=<price>,currency=<currency>)
Possible responses:
  • 100 OK
QUIT
Close the session. Session is closed after all pending "IS" commands have been processed.
IS <username> <password> <domain>
Login and check domain name. This can be used when only a single domain name needs to be checked, session will be closed immediately.
Possible responses:
  • <domain> available
  • <domain> not available
  • <domain> invalid domain
  • <domain> error
  • 400 Login failed
Example session
>>> LOGIN customer/user password
<<< 100 Login ok
>>> IS example1.com
<<< example1.com not available
>>> IS example2.com
>>> IS example3.net
>>> IS example4.info
<<< example2.com available
<<< example4.info not available
<<< example3.net not available
>>> IS --.org
<<< --.org invalid domain
>>> QUIT
                    
IsProxy.php

Class implementing the Isproxy protocol

<?php

/**
 * Realtime Register is proxy
 *
 * <code>
 * require_once 'IsProxy.php';
 *
 * $ip = new IsProxy("customer/user", "password");
 * $ip->check('domainname', 'com');
 *
 * $result = $ip->result();
 * echo $result['domain'].' '.$result['result'];
 *
 * $ip->close();
 * </code>
 */

class IsProxy {
    /**
     * Connection
     *
     * @var     object
     */
    var $_fp;

    /**
     * Construct
     *
     * @param   string  The username in the form "customer/user"
     * @param   string  The password
     * @param   string  The IsProxy host, defaults to "is.yoursrs.com"
     * @param   int     The IsProxy port, defaults to 2001
     * @return  void
     */
    function IsProxy($username, $password, $host = "is.yoursrs.com", $port = 2001) {
        $this->username = $username;
        $this->password = $password;
        $this->host = $host;
        $this->port = $port;
    }

    /**
     * Close
     *
     * @return  void
     */
    function close() {
        $this->write('CLOSE');

        @fclose($this->_fp);
    }

    /**
     * Connect
     *
     * @return  bool    Connection established?
     */
    function connect() {
        $this->_fp = @fsockopen($this->host, $this->port, $errno, $errstr, 10);
        if(!is_resource($this->_fp)) {
            return false;
        }

        /**
         * Login
         */
        return $this->login();
    }

    /**
     * Check
     *
     * @param   string  Domainname
     * @param   mixed   TLD(s)
     * @return  void
     */
    function check($domainname, $tlds) {
        if(!is_array($tlds)) {
            $tlds = (array) $tlds;
        }

        foreach($tlds as $tld) {
            $this->write('IS '.$domainname.'.'.$tld);
        }
    }

    /**
     * Result
     *
     * @return  array   [ domain, result ]
     */
    function result() {
        $response = $this->read();
        if(preg_match('#^([\-\w.]+)\s(available|not\savailable|invalid\sdomain|error)#', $response, $match)) {
            return array('domain' => $match[1], 'result' => $match[2]);
        }

        return array('domain' => '-', 'result' => 'error');
    }

    /**
     * Is connected?
     *
     * @return  bool    Connection?
     */
    function is_connected() {
        return is_resource($this->_fp);
    }

    /**
     * Login
     *
     * @return  bool    Login successfull?
     */
    function login() {
        if(!$this->write('LOGIN '.$this->username.' '.$this->password)) {
            return false;
        }

        $response = $this->read();
        if(preg_match('#^400\sLogin\sfailed#', $response)) {
            return false;
        }

        return preg_match('#^100\sLogin\sok#', $response);
    }

    /**
     * Read
     *
     * @return  string  Response
     */
    function read() {
        if(!$this->is_connected()) {
            $this->connect();
        }

        if(!$response = fgets($this->_fp, 1024)) {
            return false;
        }

        return trim($response);
    }

    /**
     * Write
     *
     * @param   string  Message
     * @return  bool    Writing successfull?
     */
    function write($message) {
        if(!$this->is_connected()) {
            $this->connect();
        }

        return @fputs($this->_fp, $message."\r\n");
    }
}

?>
Usage

Example usage of the IsProxy class.

<?php

/**
 * Realtime Register is proxy example usage
 */

/**
 * Realtime Register is proxy username
 */
$username = 'CUSTOMER/USER';

/**
 * Realtime Register is proxy password
 */
$password = 'PASSWORD';

/**
 * TLDs
 */
$tlds = array('com', 'net', 'org', 'info');

/**
 * Text
 */
$text = array(
    'error'             => 'Error',
    'available'         => 'Available',
    'not available'     => 'Not available',
    'invalid domain'    => 'Invalid domain',
);

$domainname = isset($_REQUEST['domainname']) ? $_REQUEST['domainname'] : null;
$tld = isset($_REQUEST['tld']) ? $_REQUEST['tld'] : null;

echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
echo '  <table>';
echo '    <tr>';
echo '      <td><input type="text" name="domainname" value="'.$domainname.'" /></td>';
echo '      <td>.</td>';
echo '      <td><select name="tld"><option value="all" '.($tld == 'all' ? 'selected="selected"' : null).'>(all)</option>';

foreach($tlds as $opt) {
    echo '        <option value="'.$opt.'"'.($tld == $opt ? 'selected="selected"' : null).'>'.$opt.'</option>';
}

echo '      </select></td>';
echo '      <td><input type="submit" value="Check" /></td>';
echo '    </tr>';
echo '  </table>';
echo '</form>';

if($_SERVER['REQUEST_METHOD'] == 'POST') {
    if(is_null($domainname) || is_null($tld)) {
        echo '<p>Ongeldige domeinnaam</p>';
    }
    else {
        /**
         * Initiate Realtime Register whois proxy
         */
        require_once 'IsProxy.php';

        $ip = new IsProxy($username, $password);

        $tld_check = $tld == 'all' ? $tlds : (array) $tld;

        $tld_count = sizeof($tld_check);
        $a = 0;

        echo '<table>';

        $ip->check($domainname, $tld_check);
        while($result = $ip->result()) {
            $a++;

            echo '<tr><td>'.$result['domain'].'</td><td>'.$text[$result['result']].'</td></tr>';
            flush();

            if($a == $tld_count) {
                $ip->close();

                break;
            }
        }

        echo '</table>';
    }
}

?>