HTTParty wrapper for MaxMind's GeoIP service
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
MIT-LICENSE
README.rdoc
maxmind.rb

README.rdoc

maxmind_party

This is a Ruby wrapper for MaxMind’s GeoIP City web service. It uses John Nunemaker's HTTParty.

First, authorize with your API key

MaxMind::GeoIP.authorize 'yourapikeyhere'

Then lookup an IP

>> MaxMind::GeoIP.locate '207.97.227.239'
=> #<MaxMind::Location:0x101552a10 @valid=true, @region="TX", @long="-98.574799", @country="US", @lat="29.507200", @ip="207.97.227.239", @city="San Antonio">

If something goes horribly wrong, it'll likely look like this

>> location = MaxMind::GeoIP.locate '127.0.0.1'
=> #<MaxMind::Location:0x1015286e8 @valid=false, @ip="127.0.0.1">
>> location.valid?
=> false
>> location.error_message
=> 'IP_NOT_FOUND'