1. Go to this page and download the library: Download rdapapi/rdapapi-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use RdapApi\RdapApi;
// Default configuration
$api = new RdapApi('your-api-key');
// Custom timeout (in seconds)
$api = new RdapApi('your-api-key', ['timeout' => 10]);
// Custom base URL
$api = new RdapApi('your-api-key', ['base_url' => 'https://custom.api.com/v1']);
$domain = $api->domain('example.com');
echo $domain->domain; // "example.com"
echo $domain->registrar->name; // Registrar name
echo $domain->registrar->iana_id; // IANA registrar ID
var_dump($domain->dnssec); // true, false, or null when the registry publishes no status
// With registrar follow-through (for thin registries)
$domain = $api->domain('example.com', ['follow' => true]);
echo $domain->meta->followed; // true
$domain = $api->domain('example.it');
echo $domain->meta->source; // "whois"
echo $domain->meta->server; // "whois.nic.it"
// Refuse the fallback: those TLDs then raise NotSupportedException.
$domain = $api->domain('example.it', ['whois' => false]);
$domain = $api->domain('google.co.uk');
$method = $domain->redacted?->entities['registrant']['email'] ?? null;
if ($method === 'replacementValue') {
echo 'The email is a substitute, not the real one.';
}
$ip = $api->ip('8.8.8.8');
echo $ip->name; // "LVLT-GOGL-8-8-8"
echo $ip->country; // "US"
print_r($ip->cidr); // ["8.8.8.0/24"]
echo $ip->start_address; // "8.8.8.0"
echo $ip->end_address; // "8.8.8.255"
echo $ip->geofeed; // RFC 8805 geofeed URL, or null
// A CIDR block returns that network, so different prefix lengths can
// return different allocations.
$ip = $api->ip('8.8.8.0/24');
$asn = $api->asn(15169); // integer
$asn = $api->asn('AS15169'); // string with prefix (stripped automatically)
echo $asn->name; // "GOOGLE"
echo $asn->start_autnum; // 15169
echo $asn->country; // "US", or null when no contact supplies one
if ($api->ping()) {
echo 'The API is reachable';
}
use RdapApi\Exceptions\AuthenticationException;
use RdapApi\Exceptions\NotFoundException;
use RdapApi\Exceptions\NotSupportedException;
use RdapApi\Exceptions\RateLimitException;
use RdapApi\Exceptions\SubscriptionRequiredException;
try {
$domain = $api->domain('example.nope');
} catch (NotSupportedException $e) {
// Catch before NotFoundException: it's a subclass.
echo 'The TLD is not covered by RDAP.';
} catch (NotFoundException $e) {
echo 'The domain is not registered.';
} catch (RateLimitException $e) {
echo "Rate limited, retry after {$e->retryAfter} seconds";
} catch (AuthenticationException $e) {
echo 'Invalid API key';
} catch (SubscriptionRequiredException $e) {
echo match ($e->errorCode) {
'plan_upgrade_