Official PHP SDK for the RDAP API — look up domains, IP addresses, ASNs, nameservers, and entities via the RDAP protocol.
composer require rdapapi/rdapapi-phpRequires PHP 8.2 or later.
<?php
use RdapApi\RdapApi;
$api = new RdapApi('your-api-key');
$domain = $api->domain('google.com');
echo $domain->registrar->name; // "MarkMonitor Inc."
echo $domain->dates->registered; // "1997-09-15T04:00:00Z"
echo $domain->dates->expires; // "2028-09-14T04:00:00Z"
print_r($domain->nameservers); // ["ns1.google.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
echo $domain->dnssec; // true/false
// With registrar follow-through (for thin registries)
$domain = $api->domain('example.com', ['follow' => true]);
echo $domain->meta->followed; // true$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"$asn = $api->asn(15169); // integer
$asn = $api->asn('AS15169'); // string with prefix (stripped automatically)
echo $asn->name; // "GOOGLE"
echo $asn->start_autnum; // 15169$ns = $api->nameserver('ns1.google.com');
echo $ns->ldh_name; // "ns1.google.com"
print_r($ns->ip_addresses->v4); // ["216.239.32.10"]
print_r($ns->ip_addresses->v6); // ["2001:4860:4802:32::a"]$entity = $api->entity('GOGL');
echo $entity->name; // "Google LLC"
echo $entity->organization; // "Google LLC"
echo $entity->autnums[0]->handle; // "AS15169"
echo $entity->networks[0]->cidr[0]; // "8.8.8.0/24"Requires a Pro or Business plan. Up to 10 domains per call.
$resp = $api->bulkDomains(
['google.com', 'github.com', 'example.com'],
['follow' => true],
);
echo $resp->summary->total; // 3
echo $resp->summary->successful; // 3
foreach ($resp->results as $result) {
if ($result->status === 'success') {
echo "{$result->domain} — {$result->data->registrar->name}\n";
} else {
echo "{$result->domain} — error: {$result->message}\n";
}
}All API errors are thrown as typed exceptions that extend RdapApiException:
use RdapApi\Exceptions\AuthenticationException;
use RdapApi\Exceptions\NotFoundException;
use RdapApi\Exceptions\RateLimitException;
use RdapApi\Exceptions\SubscriptionRequiredException;
try {
$domain = $api->domain('example.com');
} catch (NotFoundException $e) {
echo "Not found: {$e->getMessage()}";
} catch (RateLimitException $e) {
echo "Rate limited, retry after {$e->retryAfter} seconds";
} catch (AuthenticationException $e) {
echo "Invalid API key";
} catch (SubscriptionRequiredException $e) {
echo "Subscription required";
}| Exception | HTTP Status | Description |
|---|---|---|
ValidationException |
400 | Invalid input |
AuthenticationException |
401 | Invalid or missing API key |
SubscriptionRequiredException |
403 | No active subscription |
NotFoundException |
404 | No RDAP data found |
RateLimitException |
429 | Rate limit or quota exceeded |
UpstreamException |
502 | Upstream RDAP server failure |
All exceptions expose statusCode, errorCode, and getMessage(). RateLimitException also has retryAfter (int or null).
Fields that may be absent in API responses use nullable types (?string, ?int). Check for null before using:
if ($domain->dates->expires !== null) {
echo "Expires: {$domain->dates->expires}";
}
// Or use PHP 8's nullsafe operator
echo $domain->entities->registrant?->name;MIT — see LICENSE.