View Source Whois (Whois v0.2.0)
A WHOIS client for Elixir.
Summary
Functions
Queries the appropriate WHOIS server for the domain.
Types
@type lookup_option() :: {:server, String.t() | Whois.Server.t()}
Functions
@spec lookup(String.t(), [lookup_option()]) :: {:ok, Whois.Record.t()} | {:error, :no_data_provided | :timed_out | :unsupported_tld}
Queries the appropriate WHOIS server for the domain.
Returns {:ok, record}
if we were able to look up WHOIS records (at the minimum,
the date the domain was registered).
Note that for some TLDs (especially country-specific TLDs in the European Union),
WHOIS information is considered private, and the respective WHOIS servers will return
limited information, or even none at all (resulting in {:error, :no_data_provided}
).
For this reason, it's not generally possible to distinguish between cases where the
domain is registered (but our WHOIS queries are blocked), versus cases where the domain
is not registered at all.
Options
- server: the WHOIS server to query. If not specified, we'll automatically choose the appropriate server.
Examples
iex> {:ok, %Whois.Record{domain: "google.com"} = record} = Whois.lookup("google.com")
iex> NaiveDateTime.compare(record.expires_at, NaiveDateTime.utc_now())
:gt
iex> Whois.lookup("scha.ch")
{:error, :no_data_provided}