定制 rdapapi/rdapapi-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rdapapi/rdapapi-php

Composer 安装命令:

composer require rdapapi/rdapapi-php

包简介

Official PHP SDK for the RDAP API — look up domains, IPs, ASNs, nameservers, and entities via RDAP.

README 文档

README

Official PHP SDK for the RDAP API — look up domains, IP addresses, ASNs, nameservers, and entities via the RDAP protocol.

Packagist Version PHP Version CI

Installation

composer require rdapapi/rdapapi-php

Requires PHP 8.2 or later.

Quick Start

<?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", ...]

Usage

Configuration

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 Lookup

$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 Address Lookup

$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 Lookup

$asn = $api->asn(15169);           // integer
$asn = $api->asn('AS15169');       // string with prefix (stripped automatically)

echo $asn->name;           // "GOOGLE"
echo $asn->start_autnum;   // 15169

Nameserver Lookup

$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 Lookup

$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"

Bulk Domain Lookup

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";
    }
}

Supported TLDs Catalog

List every TLD the API can resolve, with the date support was added and a qualitative summary of which fields the registry's RDAP server populates. Does not count against your monthly quota.

$tlds = $api->tlds();
if ($tlds !== null) {
    echo "{$tlds->meta->count} TLDs, coverage ".round($tlds->meta->coverage * 100)."%\n";

    foreach ($tlds->data as $tld) {
        $availability = $tld->field_availability;
        if ($availability !== null) {
            echo "{$tld->tld}: expires_at={$availability->expires_at}\n";
        }
    }
}

Filter to recent additions or to a single registry:

$recent = $api->tlds(['since' => '2026-04-01T00:00:00Z']);
$verisign = $api->tlds(['server' => 'rdap.verisign.com']);

Pass back the previous etag to skip the transfer when nothing has changed:

$first = $api->tlds();
$later = $api->tlds(['if_none_match' => $first?->etag ?? '']);
if ($later === null) {
    echo "No change since last poll\n";
}

Look up a single TLD:

$com = $api->tld('com');
echo $com->data->rdap_server_host; // "rdap.verisign.com"

Error Handling

All API errors are thrown as typed exceptions that extend RdapApiException:

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 'Subscription required';
}

NotSupportedException extends NotFoundException, so catching NotFoundException still handles both cases.

Exception HTTP Status Description
ValidationException 400 Invalid input
AuthenticationException 401 Invalid or missing API key
SubscriptionRequiredException 403 No active subscription
NotFoundException 404 Namespace is covered but no record exists
NotSupportedException 404 Namespace (TLD, IP range, ASN range) is not covered by RDAP
RateLimitException 429 Rate limit or quota exceeded
UpstreamException 502 Upstream RDAP server failure
TemporarilyUnavailableException 503 Domain data temporarily unavailable

All exceptions expose statusCode, errorCode, and getMessage(). RateLimitException and TemporarilyUnavailableException also have retryAfter (int or null).

Nullable Fields

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;

Development

Set up pre-commit hooks (runs lint + tests before each commit):

git config core.hooksPath .githooks

License

MIT — see LICENSE.

rdapapi/rdapapi-php 适用场景与选型建议

rdapapi/rdapapi-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「dns」 「domain」 「entity」 「whois」 「IP」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 rdapapi/rdapapi-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rdapapi/rdapapi-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 rdapapi/rdapapi-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 35
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-25