Class WhoisApi
A Whois API.
This is a client library for the service of http://whois-api.domaininformation.de/.
Register there to get an API key.
With this API you can check if a domain name is available, get its
whois data or query an arbitrary whois server. The service is using
the whois list from https://github.com/whois-server-list/whois-server-list.
Also it avoids hitting any rate limits on the whois servers.
Example:
use whoisServerList\WhoisApi;
$whoisApi = new WhoisApi("apiKey");
echo $whoisApi->isAvailable("example.net") ? "available" : "registered";
Methods summary
public
|
#
__construct( string $apiKey, string $endpoint = "https://whois-v0.p.mashape.com/" )
Builds a Domain API.
Register at http://whois-api.domaininformation.de/ to get an API key.
Parameters
- $apiKey
- API key
- $endpoint
- optional endpoint, default is "https://whois-v0.p.mashape.com/".
|
public
boolean
|
#
isAvailable( string $domain )
Checks if a domain is available.
Checks if a domain is available.
If a domain is available (i.e. not registered) this method
will return true.
Parameters
- $domain
- domain name, e.g. "example.net"
Returns
boolean true if the domain is available, false otherwise.
Throws
|
public
boolean[]
|
#
areAvailable( array $domains )
Checks multiple domains if they are available.
Checks multiple domains if they are available.
areAvailable(["example.net", "example.org", "example.com"])
could return this map:
[
"example.net" => true,
"example.org" => false,
"example.com" => null
]
Parameters
- $domains
- domain names, e.g. ["example.net", "example.org"]
Returns
boolean[] map with the result for each domain. True means
the domain is available, false not. NULL however means that the
query failed for that domain.
|
public
string
|
#
whois( string $domain )
Returns the whois data for a domain.
Returns the whois data for a domain.
Parameters
- $domain
- domain name, e.g. "example.net"
Returns
string response of the respective whois server
Throws
|
public
string
|
#
query( string $host, string $query )
Queries a whois server.
Parameters
- $host
- hostname of the whois server, e.g. "whois.verisign-grs.com"
- $query
- query, e.g. "example.net"
Returns
string response from the whois server
Throws
|
public
string[]
|
#
domains( )
Returns a list of all top and second level domains, which are
known to the Whois API.
Returns a list of all top and second level domains, which are
known to the Whois API.
Returns
string[] all available top and second level domains.
|