<commit_before># RoboWhois - Ruby Client

This is the official Ruby client for [RoboWhois](http://www.robowhois.com/) [API](http://docs.robowhois.com/api/).

[RoboWhois](http://www.robowhois.com/) 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](http://www.robowhois.com/) and [documentation](http://docs.robowhois.com/) to learn more about the service.


## Installation

The best way to install this library is via [RubyGems](https://rubygems.org/).

    $ 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](http://www.robowhois.com/) account and a valid API key.

    require 'robowhois'

Please refer to the RoboWhois [API Documentation](http://docs.robowhois.com/api/) for the list of all available API methods and response attributes.

### Account information

    client = RoboWhois.new('YOUR_API_KEY')
    account = client.account

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

### Original WHOIS record

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

    puts response
    # => The record String

### Parsed WHOIS record

    client = RoboWhois.new('YOUR_API_KEY')
    response = client.whois_properties('example.com')

    # The record date
    puts response['daystamp']

    # The record registrant
    if contact = response['properties']['registrant_contacts']
      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('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('YOUR_API_KEY')

    begin
      response = client.whois_properties('example.es')
    rescue => error
      puts error.code
      # => "R2"
      puts error.name
      # => "ServerWhoisOnlyWeb"
      puts error.status<commit_msg>Fix outdated documentation<commit_after># RoboWhois - Ruby Client

This is the official Ruby client for [RoboWhois](http://www.robowhois.com/) [API](http://docs.robowhois.com/api/).

[RoboWhois](http://www.robowhois.com/) 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](http://www.robowhois.com/) and [documentation](http://docs.robowhois.com/) to learn more about the service.


## Installation

The best way to install this library is via [RubyGems](https://rubygems.org/).

    $ 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](http://www.robowhois.com/) account and a valid API key.

    require 'robowhois'

Please refer to the RoboWhois [API Documentation](http://docs.robowhois.com/api/) 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']
      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
      # => "R2"
      puts error.name
      # => "ServerWhoisOnlyWeb"
      puts error.status
{'fraction_non_alphanumeric': 0.10259453959640495, 'fraction_numerical': 0.002034933016788197, 'mean_word_length': 3.4988558352402745, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 24, 'https://': 2, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7260206', 'n_tokens_mistral': 1781, 'n_tokens_neox': 1723, 'n_words': 562}