Skip to content

sfumanal/robowhois-ruby

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RoboWhois - Ruby Client

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.

Installation

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.

Usage

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.

Account information

client = RoboWhois.new(:api_key => 'YOUR_API_KEY')
account = client.account

puts account['email']
# => your email
puts account['credits_limit']
# => available credits

Original WHOIS record

client = RoboWhois.new(:api_key => 'YOUR_API_KEY')
response = client.whois('example.com')

puts response
# => The record String

Parsed WHOIS record

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

Response Object

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
# => { ... }

Errors

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.

Changelog

See the CHANGELOG.md file for details.

License

Copyright (c) 2012 RoboDomain Inc. Copyright (c) 2012-2014 Aetrion LLC.

This is Free Software distributed under the MIT license.

About

Ruby client for the RoboWhois API.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%