whoisjson/whoisjson

A PHP client for the WhoisJSON API - Get WHOIS, DNS, and SSL certificate information in JSON format

Installs: 10

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 1

Open Issues: 0

pkg:composer/whoisjson/whoisjson

v1.0.0 2025-05-30 12:57 UTC

This package is auto-updated.

Last update: 2025-10-30 14:06:08 UTC


README

A PHP wrapper for the WhoisJSON API - Get WHOIS, DNS, and SSL certificate information in JSON format.

Free accounts include 500 requests per month. Check out our full documentation for more details about our API.

Installation

composer require whoisjson/whoisjson

Usage

First, sign up for a free API key to get started with 500 monthly requests.

use WhoisJson\WhoisJsonClient;

// Initialize the client
$whois = new WhoisJsonClient('YOUR_API_KEY');

try {
    // WHOIS lookup
    $whoisInfo = $whois->whois('example.com');
    print_r($whoisInfo);

    // DNS lookup
    $dnsInfo = $whois->nslookup('example.com');
    print_r($dnsInfo);

    // SSL certificate info
    $sslInfo = $whois->sslCertCheck('example.com');
    print_r($sslInfo);
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage();
}

Response Examples

WHOIS Lookup Response

[
    'server' => 'gamma',
    'name' => 'example.com',
    'idnName' => 'example.com',
    'status' => [
        'clientDeleteProhibited',
        'clientTransferProhibited'
    ],
    'nameserver' => [
        'dns1.example.com',
        'dns2.example.com'
    ],
    'ips' => '93.184.216.34',
    'created' => '1995-08-14T04:00:00Z',
    'changed' => '2024-02-14T08:00:00Z',
    'expires' => '2025-08-13T04:00:00Z',
    'registered' => true,
    'dnssec' => 'signedDelegation',
    'whoisserver' => 'whois.example.com',
    'contacts' => [
        'owner' => [[
            'handle' => 'REDACTED FOR PRIVACY',
            'name' => 'REDACTED FOR PRIVACY',
            'email' => 'REDACTED FOR PRIVACY',
            'country' => 'US'
        ]]
    ],
    'registrar' => [
        'id' => '123',
        'name' => 'Example Registrar, Inc.',
        'email' => 'support@example.com',
        'url' => 'https://example.com',
        'phone' => '+1.2345678900'
    ]
]

NSLookup Response

[
    'domain' => 'example.com',
    'records' => [
        'a' => ['93.184.216.34'],
        'aaaa' => ['2606:2800:220:1:248:1893:25c8:1946'],
        'mx' => [
            [
                'priority' => 10,
                'exchange' => 'mail.example.com'
            ]
        ],
        'ns' => [
            'ns1.example.com',
            'ns2.example.com'
        ],
        'txt' => ['v=spf1 include:_spf.example.com ~all'],
        'soa' => [
            'mname' => 'ns1.example.com',
            'rname' => 'hostmaster.example.com',
            'serial' => 2024021401,
            'refresh' => 7200,
            'retry' => 3600,
            'expire' => 1209600,
            'minimum' => 3600
        ]
    ]
]

SSL Certificate Response

[
    'domain' => 'example.com',
    'valid' => true,
    'issuer' => [
        'organization' => "Let's Encrypt",
        'commonName' => 'R3',
        'countryName' => 'US'
    ],
    'subject' => [
        'commonName' => 'example.com'
    ],
    'validFrom' => '2024-01-01T00:00:00Z',
    'validTo' => '2024-04-01T00:00:00Z',
    'serialNumber' => '123456789',
    'version' => 3,
    'signatureAlgorithm' => 'SHA256withRSA',
    'subjectAlternativeNames' => [
        'example.com',
        'www.example.com'
    ]
]

API Reference

new WhoisJsonClient($apiKey, $baseUrl = 'https://whoisjson.com/api/v1')

Creates a new WhoisJson client instance.

Parameters

  • $apiKey (string): Your WhoisJSON API key
  • $baseUrl (string, optional): Custom API base URL

whois($domain)

Get WHOIS information for a domain.

Parameters

  • $domain (string): The domain name to lookup

Returns

Array containing the WHOIS information.

nslookup($domain)

Get DNS records for a domain.

Parameters

  • $domain (string): The domain name to lookup

Returns

Array containing the DNS records information.

sslCertCheck($domain)

Get SSL certificate information for a domain.

Parameters

  • $domain (string): The domain name to check

Returns

Array containing the SSL certificate information.

Error Handling

The package throws exceptions in the following cases:

  • Invalid API key
  • Invalid domain name
  • API rate limit exceeded
  • Network errors
  • Other API errors

Requirements

  • PHP 7.4 or higher
  • GuzzleHttp 7.0 or higher
  • ext-json

License

MIT