A Quova API Client for Ruby

This gem provides a thin wrapper around Quova's GeoIP web service. It is extremely simple to use, accepting IP addresses as input and returning plain ruby Hash objects in response. Data-types will be cast where appropriate (e.g. :longitude and :latitude are provided as Float types).

Installation

gem install quova

Usage

There are two interfaces, depending on which API you want to use. You can use either Quova::QOD (Quova on Demand), which is for the paid service and includes slightly more data, or you can use Quova::REST, which is for the standard service, providing slightly less data (such as anonymizer information).

You'll need the appropriate credential for each of these. You can register for a free account at http://developer.quova.com/.

Quova on Demand

lookup = Quova::QOD.new(:id => "your-id", :password => "your-password")
info = lookup.info("4.2.2.2")

Or you can use the alternative syntax:

info = lookup["4.2.2.2"]

Standard REST API

lookup = Quova::REST.new(:api_key => "your-key", :secret => "your-secret")
info = lookup.info("4.2.2.2")

Or you can use the alternative syntax:

info = lookup["4.2.2.2"]

Both clients return the same Result object, which acts like a Hash. How much information you get depends on the API you're using. Anything that is not provided, will be left as nil:

:ip_address         => String
:ip_type            => String
:anonymizer_status  => String
:domain_tld         => String
:domain_sld         => String
:aol                => Boolean
:organization       => String
:carrier            => String
:asn                => String
:connection_type    => String
:line_speed         => String
:ip_routing_type    => String
:continent_name     => String
:country_code       => String
:country_name       => String
:country_confidence => Integer
:region_name        => String
:state_code         => String
:state_name         => String
:state_confidence   => Integer
:city_name          => String
:city_confidence    => Integer
:postal_code        => String
:time_zone          => String
:area_code          => String
:longitude          => Float
:latitude           => Float
:dma_id             => Integer
:msa_id             => Integer

For any field that was returned blank, or missing, nil will be present in the result.

The Result is an object with Virtus mixed in to ensure valid data types. As a side-effect, you may access the properties either using a Hash ([:key]) syntax, or just like a regular method call. (result.longitude). If you want a plain Hash, call result.attributes.

Note

When using the standard (REST) API, it is important that the system time on your server is correct (give or take 5 minutes), since the API signature is generated by on the current time (see http://developer.quova.com/docs#signing_api for more information).

Resources

Disclaimer

The official maintainer of this Gem, Chris Corbyn (@d11wtq) is no way affiliated with, nor representative of Quova. This code is provided free of charge and shall be used at your own risk.

Copyright (C) 2011 Chris Corbyn