This is the official Ruby client for RoboWhois API.
RoboWhois is a web service that provides an API suite to access WHOIS records and domain related information with a unified, consistent interface.
Using RoboWhois API you can:
- check domain availability for any supported TLD
- lookup WHOIS information for a domain and retrieve the WHOIS record
- access WHOIS data using a consistent, well-structured, HTTP-based interface
- retrieve WHOIS details parsed as convenient JSON structure
Visit RoboWhois site and documentation to learn more about the service.
The best way to install this library is via RubyGems.
$ gem install robowhois
You might need administrator privileges on your system to install the gem.
All the examples below assume you installed the gem and required it via RubyGems. You also need a RoboWhois account and a valid API key.
require 'robowhois'
Please refer to the RoboWhois API Documentation for the list of all available API methods and response attributes.
client = RoboWhois.new(:api_key => 'YOUR_API_KEY')
account = client.account
puts account['email']
# => your email
puts account['credits_limit']
# => available credits
client = RoboWhois.new(:api_key => 'YOUR_API_KEY')
response = client.whois('example.com')
puts response
# => The record String
client = RoboWhois.new(:api_key => 'YOUR_API_KEY')
response = client.whois_properties('example.com')
# The record date
puts response['daystamp']
# The record registrant
if contact = response['properties']['registrant_contacts'].first
puts contact['id']
puts contact['name']
puts contact['organization']
else
puts "Registrant details not available."
end
# The record nameservers
response['properties']['nameservers'].each do |nameserver|
puts nameserver['name']
puts nameserver['ipv4']
puts nameserver['ipv6']
end
You can access the last response object using the last_response
method.
client = RoboWhois.new(:api_key => 'YOUR_API_KEY')
account = client.account
response = client.last_response
response.code
# => 200
response.headers
# => { ... }
In case of failure, the API call raises a RoboWhois::APIError
exception.
client = RoboWhois.new(:api_key => 'YOUR_API_KEY')
begin
response = client.whois_properties('example.es')
rescue => error
puts error.code
# => "R04"
puts error.name
# => "WhoisServerOnlyWeb"
puts error.status
# => 400
end
Error codes are explained in the API Errors documentation page.
See the CHANGELOG.md file for details.
Copyright (c) 2012 RoboDomain Inc. Copyright (c) 2012-2014 Aetrion LLC.
This is Free Software distributed under the MIT license.