Support Ruby Whois

Whois is an intelligent pure Ruby WHOIS client and parser.

It provides a flexible and programmable API to query WHOIS servers and look up IP/domain WHOIS information. It also offers command-line interface to run WHOIS queries from the console.

It is a OS-independent library and doesn’t require external C libraries or Gems.

This software was developed to power RoboDomain and, since July 2009, it ran more than thousands requests.

An extensive test suite is available to verify the library correctness but you must be aware that registrant might change WHOIS interfaces without notice and at any time causing queries to specific hosts to stop working.

Installation

The best way to install Whois is via RubyGems.

$ gem install whois

You might need administrator privileges on your system to install the Gem.

For more details visit the installation page.

Basic Usage

This section covers the essentials of the Whois library. For a more deep explanation visit the complete usage section or read the whois manual.

Querying a WHOIS

This is the simplest way to send a WHOIS request is using the query method.

c = Whois::Client.new
c.query("google.com")
# => #<Whois::Answer>

The method returns a Whois::Answer instance which essentially looks and behaves like a String but it’s way more powerful than a string (see Consuming the Answer).

You can print, compare and modify it exactly as a string.

c = Whois::Client.new
a = c.query("google.com")

puts a
# the full whois record response
# ...
# ...

If you don’t need to customize the Whois::Client, you can also use the Whois.query shortcut (see Whois::Client shortcuts section for more information).

a = Whois.query("google.com")

puts a
# the full whois record response
# ...
# ...

Whois provides the ability to get WHOIS information for domains, IPv4 and IPv6 IP addresses. The client is smart enough to guess the best WHOIS server according to given query, send the request and return the response.

c = Whois::Client.new

c.query("google.com")
# => #<Whois::Answer ...>

# IPv4 Whois
c.query("74.125.67.100")
# => #<Whois::Answer ...>

# IPv6 Whois
c.query("2001:db8::1428:57ab")
# => #<Whois::Answer ...>

Consuming the Answer

A WHOIS query returns a Whois::Answer instance and this is just the beginning of the story.

Whois::Answer is a super powerful object. It encapsulates the full WHOIS answer and it provides you the ability to parse the WHOIS response with a full object oriented notation.

a = Whois.whois("google.it")
# => #<Whois::Answer ...>

a.available?
# => false
a.registered?
# => true

a.created_on
# => Fri Dec 10 00:00:00 +0100 1999

t = a.technical
# => #<Whois::Answer::Contact ...>
t.id
# => "TS7016-ITNIC"
t.name
# => "Technical Services"

a.nameservers.each do |nameserver|
  puts nameserver
end

This feature is made possible by the Whois::Answer::Parser. Unfortunately, due to the lack of a global standard, each WHOIS server requires a specific parser. For this reason, the library doesn’t currently support all existing WHOIS servers.

If you create a new parser, please consider releasing it to the public so that it can be included in a next version.

More

License

Whois is Copyright © 2009-2010 Simone Carletti and is released under the MIT license.