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.

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 <apikey>
LOGIN <username> <password> Deprecated
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 <apikey> <domain>
IS <username> <password> <domain>Deprecated
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 apikey
<<< 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("apikey");
 * $ip->check('domainname', 'com');
 *
 * $result = $ip->result();
 * echo $result['domain'].' '.$result['result'];
 *
 * $ip->close();
 * </code>
 */

class IsProxy {
    /**
     * Connection
     *
     * @var     object
     */
    private $fp;

    private $apikey;

    private $host;

    private $port;

    /**
     * Construct
     *
     * @param   string  The api key
     * @param   string  The IsProxy host, defaults to "is.yoursrs.com"
     * @param   int     The IsProxy port, defaults to 2001
     * @return  void
     */
    public function __construct($apikey, $host = "is.yoursrs.com", $port = 2001) {
        $this->apikey = $apikey;
        $this->host = $host;
        $this->port = $port;
    }

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

        @fclose($this->fp);
    }

    /**
     * Connect
     *
     * @return  bool    Connection established?
     */
    private 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
     */
    public 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 ]
     */
    public 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?
     */
    public function is_connected() {
        return is_resource($this->fp);
    }

    /**
     * Login
     *
     * @return  bool    Login successfull?
     */
    public function login() {
        if(!$this->write('LOGIN '.$this->apikey)) {
            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
     */
    private 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?
     */
    private 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 api key
 */
$apikey = 'apikey';

/**
 * 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($apikey);

        $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>';
    }
}