Fetching contributors…
Cannot retrieve contributors at this time
211 lines (126 sloc) 8.76 KB


Whois is an intelligent pure Ruby WHOIS client and parser.

Build Status

Whois is a OS-independent library and doesn't require any external binaries or C libraries: it is a 100% Ruby software.

This library was developed to power RoboDomain and RoboWhois. It has been performing queries in production since July 2009.

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.


Support Whois at Pledgie.

Click here to lend your support to: whois and make a donation at !

Whois is free software, but it costs money to write, test, and distribute it. You can support the development by sending a donation. Any amount, even $5, is greatly appreciated.



  • Ruby >= 1.8.7

Whois >= 1.5 requires Ruby 1.8.7 or newer. For older versions of Ruby, see the CHANGELOG.rdoc file.

In addition to the standard Ruby interpreter (MRI), Whois has been successfully tested against several Ruby implementations.


The best way to install Whois is via RubyGems.

$ gem install whois

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


Install the newer version via RubyGems.

$ gem install whois

Minor and bugfix releases normally won't break backwards-compatibility. You can read the file to learn about the changes in each release.

Read the Upgrading documentation page for detailed information about incompatible changes and further instructions.

Getting Started

Note. This section covers only the essentials for getting started with the Whois library. The documentation provides a more accurate explanation including tutorials, more examples and technical details about the client/server/record/parser architecture.

Querying the Server

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

Check out the following examples:

# Domain WHOIS
w =
# => #<Whois::Record>

w =
# => #<Whois::Record>

w =
# => #<Whois::Record>

w =
# => #<Whois::Record>

The query method is stateless. For this reason, you can safely re-use the same client instance for multiple queries.

w =

If you just need a WHOIS response and you don't care about a full control of the WHOIS client, the {Whois} module provides an all-in-one method called {Whois.whois}. This is the simplest way to send a WHOIS request.

# => #<Whois::Record>

Did I mention you can even use blocks? do |w|

Consuming the Record

Any WHOIS query returns a Whois::Record. This object looks like a String, but it's way more powerful.

Whois::Record encapsulates a WHOIS record and provides the ability to parse the WHOIS response programmatically, by using an object oriented syntax.

r = Whois.whois("")
# => #<Whois::Record>

# => false
# => true

# => Fri Dec 10 00:00:00 +0100 1999

t = r.technical_contact
# => #<Whois::Record::Contact>
# => "TS7016-ITNIC"
# => "Technical Services"

r.nameservers.each do |nameserver|
  puts nameserver

This feature is made possible by the Whois record parsers. Unfortunately, due to the lack of a global standard, each WHOIS server requires a specific parser. For this reason, the library doesn't 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.


By default, each query run though the client has a timeout value of 5 seconds. If the execution exceeds timeout limit, the client raises a Timeout::Error exception.

Off course, you can customize the timeout value setting a different value. If timeout is nil, the client will until the response is sent back from the server or the process is killed. Don't disable the timeout unless you really know you are doing!

w = => 10)
w.timeout # => 10
w.timeout = 5
w.timeout # => 5



First of all, I would like to express my most sincere thanks to Cyril Mougel, the author of the first Ruby Whois gem that has been available since 2007. Cyril has been kind enough to yield me the privilege of using the RubyForge Whois project and the Whois package name to publish this library. To express all my gratitude, the release 0.5.0 and all sub sequential versions of the new Whois up to 0.9.x are 100% compatible with Cyril's Whois.

Whois is largely inspired by other notable Whois projects, most of all the Debian Whois library written and maintained by Marco D'Itri. Other good ideas and design decisions come from the PERL Net::DRI package.

I would lie if I say I'm completely unaware of the other Ruby Whois projects. Before starting this Ruby Whois library I deeply investigated the available resources and, despite none of them was a good candidate for a refactoring, some of them expose a really cool API. They didn't directly influence this library or any design decision, but they have been a really interesting code-reading.

The parser architecture has been inspired by the PHPWhois project. The authors puts lot of effort to create whois-specific parsers normalizing the different responses in a single tree-based structure. So far, this is the only one open source project that offers such this feature in all the programming language ecosystem.

Despite I spent weeks reading source code from the available whois libraries, Ruby Whois has been built from scratch trying to focus on long-term maintainability and flexibility and cannot be considered a Ruby port of any of other existing Whois libraries.



Direct questions and discussions to the mailing list.

Pull requests are very welcome! Please include spec and/or feature coverage for every patch, and create a topic branch for every separate change you make.

Report issues or feature requests to GitHub Issues.



See the CHANGELOG file for details.


Copyright (c) 2009-2012 Simone Carletti. This is Free Software distributed under the MIT license.