Project

geolocate

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
A library to return information about a given IP (currently using ip-api.com)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 1
 Project Readme

Geolocate

A Ruby library which will return information about a given IP using the ip-api.com API.

Installation

Add to your Gemfile as normal and then bundle to install.

gem "geolocate", "~> 1.0"

Usage

if result = Geolocate.find_from_ip('185.22.208.1', :timeout => 4)
  result.country          #=> "United Kingdom"
  result.country_code     #=> "GB"
  result.city             #=> "Poole"
  result.time_zone        #=> "Europe/London"
  result.latitude         #=> 50.7324
  result.longitude        #=> -1.9753
  result.isp              #=> "Atech Media Ltd"
  result.organization     #=> "Atech Media Ltd"
else
  # Failed to do the lookup after 4 seconds maximum.
end