Net::Whois::Async
Asynchronous Raku interface to the Whois service using IO::Socket::Async.
Installation
zef install Net::Whois::Async
Quick Start
use Net::Whois::Async;
my $w = Net::Whois::Async.new;
# Parsed key/value Hash
my %info = await $w.query('example.com', 'whois.iana.org');
say %info<domain>;
# Raw lines
my @lines = await $w.query('example.com', 'whois.iana.org', :raw);
.say for @lines;
# Query several servers concurrently
my %multi = await $w.query('example.com', 'whois.iana.org', 'whois.verisign-grs.com');
say %multi<whois.iana.org><domain>;
API Reference
Net::Whois::Async.new()
Constructor. Takes no arguments.
multi method query(Str:D $who, Str:D $server, Bool :$raw! --> Promise)
Query a single Whois server and return a Promise that resolves to a List of raw
response lines (one per element, no stripping of comments).
Parameters
| Name | Type | Description |
|---|
$who | Str (IP or Domain) | The IP address or domain name to look up |
$server | Str | Whois server hostname |
:raw | Bool (required) | Must be passed to select this candidate |
Returns Promise → List[Str]
my @lines = await $w.query('93.184.216.34', 'whois.arin.net', :raw);
multi method query(Str:D $who, Str:D $server, Bool :$multiple = False --> Promise)
Query a single Whois server and return a Promise that resolves to a Hash of
parsed key/value pairs.
Comment lines starting with % or # are skipped. If the response contains a
ReferralServer: whois://... field, that server is queried automatically and its
result is returned instead.
Parameters
| Name | Type | Description |
|---|
$who | Str (IP or Domain) | The IP address or domain name to look up |
$server | Str | Whois server hostname |
:multiple | Bool | When True, duplicate keys are concatenated with a space |
Returns Promise → Hash[Str,Str]
my %h = await $w.query('example.com', 'whois.iana.org');
say %h<domain>; # example.com
my %m = await $w.query('example.com', 'whois.iana.org', :multiple);
say %m<nserver>; # all nameservers concatenated
multi method query(Str:D $who, *@servers, Bool :$multiple = False, Bool :$raw = False --> Promise)
Query multiple Whois servers concurrently and return a Promise that resolves to
a Hash keyed by server hostname.
Parameters
| Name | Type | Description |
|---|
$who | Str (IP or Domain) | The IP address or domain name to look up |
*@servers | List[Str] | Two or more Whois server hostnames |
:multiple | Bool | Passed through to the per-server parsed query |
:raw | Bool | When True, each value is a List of raw lines |
Returns Promise → Hash where each value is either a Hash (default) or a List (:raw)
my %r = await $w.query('example.com',
'whois.iana.org',
'whois.verisign-grs.com',
:raw);
say %r<whois.iana.org>.elems;
Exported subsets
| Name | Matches |
|---|
IP | A valid dotted-quad IPv4 address (each octet 0–255) |
Domain | A syntactically valid domain name (≤ 253 chars, LDH labels) |
use Net::Whois::Async;
say '1.2.3.4' ~~ IP; # True
say '256.0.0.0' ~~ IP; # False
say 'example.com' ~~ Domain; # True
Error Handling
- Passing a
$who value that matches neither IP nor Domain throws 'Not a valid IP or domain name'. - Network errors (refused connection, DNS failure) cause the returned
Promise to be broken; wrap in try { await ... } or use .then(..., quit => ...) to handle them.
my %info = try { await $w.query('example.com', 'whois.iana.org') };
if $! { say "Query failed: $!" }
License
Artistic-2.0 — Copyright 2026 Zer0-Tolerance