All Projects → jeroenj → Geo_ip

jeroenj / Geo_ip

Licence: mit
Retreive the geolocation of an IP address based on the ipinfodb.com webservice

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Geo ip

Country Ip Blocks
CIDR country-level IP data, straight from the Regional Internet Registries, updated hourly.
Stars: ✭ 100 (-2.91%)
Mutual labels:  geolocation, geoip, country
GeoLite2-Country
GeoLite2-Country.mmdb.gz CDN files based on Free Open Source CDN jsDelivr!
Stars: ✭ 69 (-33.01%)
Mutual labels:  country, geoip
tinygeoip
🐉 tiny geoip microservice
Stars: ✭ 13 (-87.38%)
Mutual labels:  geolocation, geoip
IP2Location-PHP-Module
This module is a PHP module that enables the user to find the country, region, city, coordinates, zip code, ISP, domain name, timezone, connection speed, IDD code, area code, weather station code, weather station name, mobile, usage types, address type, IAB category, etc that any IP address or host name originates from.
Stars: ✭ 154 (+49.51%)
Mutual labels:  country, geolocation
Shiny geoip
IP to location API service
Stars: ✭ 172 (+66.99%)
Mutual labels:  geolocation, geoip
GeoLite.mmdb
MaxMind's GeoIP2 GeoLite2 Country, City, and ASN databases
Stars: ✭ 690 (+569.9%)
Mutual labels:  geolocation, geoip
IP2Location-C-Library
IP2Location C library enables the user to find the country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather station code, weather station name, mobile, usage types, etc that any IP address or hostname originates from.
Stars: ✭ 37 (-64.08%)
Mutual labels:  country, geolocation
Iploc
Fastest IP To Country Library
Stars: ✭ 224 (+117.48%)
Mutual labels:  geolocation, geoip
nodejs-geoip2ws
Maxmind GeoIP2 Web Services for Node.js
Stars: ✭ 47 (-54.37%)
Mutual labels:  geolocation, geoip
express-ip
An Express Middleware for getting IP information
Stars: ✭ 28 (-72.82%)
Mutual labels:  geolocation, geoip
country
IP to country
Stars: ✭ 32 (-68.93%)
Mutual labels:  geolocation, geoip
ip2location-nginx
Nginx module that allows user to lookup for geolocation information using IP2Location database.
Stars: ✭ 33 (-67.96%)
Mutual labels:  country, geolocation
locus
MMDB reader for geolocation and ASN lookup of IP addresses
Stars: ✭ 93 (-9.71%)
Mutual labels:  geolocation, geoip
Maxminddb Golang
MaxMind DB Reader for Go
Stars: ✭ 319 (+209.71%)
Mutual labels:  geolocation, geoip
Geoip2 Golang
Unofficial MaxMind GeoIP2 Reader for Go
Stars: ✭ 1,074 (+942.72%)
Mutual labels:  geolocation, geoip
Geo Recon
An OSINT CLI tool desgined to fast track IP Reputation and Geo-locaton look up for Security Analysts.
Stars: ✭ 82 (-20.39%)
Mutual labels:  geolocation
Pgeocode
Postal code geocoding and distance calculation
Stars: ✭ 92 (-10.68%)
Mutual labels:  geolocation
Wsdl Creator
PHP WSDL Creator using PHPdoc (annotations, reflections).
Stars: ✭ 79 (-23.3%)
Mutual labels:  webservice
Webservice
Bringing the power of the CakePHP ORM to your favourite webservices
Stars: ✭ 79 (-23.3%)
Mutual labels:  webservice
Osint San
Framework для сбора данных из открытых источников. В Framework используется большое количество API, их необходимо зарегистрировать самому.​
Stars: ✭ 99 (-3.88%)
Mutual labels:  geolocation

GeoIp

Retreive the geolocation of an IP address based on the ipinfodb.com webservice.

As of 8th November 2010, the service is asking that all users register for an API key.

Consider making a donation to ipinfodb.com at http://ipinfodb.com/donate.php.

Usage

Set API key

GeoIp.api_key = 'YOUR_API_KEY'

This must be done before making the geolocation call.

Retrieve geolocation

GeoIp.geolocation(ip_address)

Example

# 209.85.227.104 = google.be (US)
GeoIp.geolocation('209.85.227.104')

returns:

{
  :status_code    => "OK",
  :status_message => "",
  :ip             => "209.85.227.104"
  :country_code   => "US",
  :country_name   => "UNITED STATES",
  :region_name    => "CALIFORNIA",
  :city           => "MONTEREY PARK",
  :zip_code       => "91754",
  :latitude       => "34.0505",
  :longitude      => "-118.13"
}

Country only

There is an option to only retreive the country information and thus excluding the city details. This results in a faster response from the service since less queries need to be done.

GeoIp.geolocation('209.85.227.104', :precision => :country)

returns:

{
  :status_code    => "OK",
  :status_message => "",
  :ip             => "209.85.227.104"
  :country_code   => "US",
  :country_name   => "UNITED STATES"
}

Timezone information

There is an option now to retrieve optional timezone information too:

GeoIp.geolocation('209.85.227.104', :timezone => true)

returns:

{
  :status_code    => "OK",
  :status_message => "",
  :ip             => "209.85.227.104"
  :country_code   => "US",
  :country_name   => "UNITED STATES",
  :region_name    => "CALIFORNIA",
  :city           => "MONTEREY PARK",
  :zip_code       => "91754",
  :latitude       => "34.0505",
  :longitude      => "-118.13"
  :timezone       => "-08:00"
}

Obviously it is not possible to have the country precision enabled while retrieving the timezone information.

Reserved / Private / Local IPs

Passing reserved, private or local IPs, such as 127.0.0.1 will return - for all location data, for example:

GeoIp.geolocation('127.0.0.1')

returns:

{
  :status_code    => "OK",
  :status_message => "",
  :ip             => "127.0.0.1",
  :country_code   => "-",
  :country_name   => "-",
  :region_name    => "-",
  :city           => "-",
  :zip_code       => "-",
  :latitude       => "0",
  :longitude      => "0"
}

Timeout

It is possible to set a timeout for all requests. By default it is one second, but you can easily set a different value. Just like you would set the api_key you can set the timeout:

GeoIp.timeout = 5 # In order to set it to five seconds

Getting it

GeoIp can be installed as a Ruby Gem:

gem install geo_ip

note: As of v0.6.0 GeoIp is only compatible with ruby 1.9.3 or higher. You can still use v0.5.0 if you need ruby 1.8.7 or 1.9.2 compatiblity.

Rails

Bundler enabled (Rails 3.x and 2.3.x)

In your Gemfile:

gem 'geo_ip'

Then create an initializer config/initializers/geo_ip (or name it whatever you want):

GeoIp.api_key = 'YOUR_API_KEY'

Pre-bundler (Rails 2.3.x or older)

In your config/environment.rb:

config.gem 'geo_ip'

Then create an initializer config/initializers/geo_ip (or name it whatever you want):

GeoIp.api_key = 'YOUR_API_KEY'

Testing

Set up your API key first for the test suite by creating a spec/api.yml file. Follow the example in spec/api.yml.example. Then run the tests with:

ruby spec/geo_ip_spec.rb

If you get a LoadError, you should run the tests with:

ruby -rubygems spec/geo_ip_spec.rb

Contributors

Bugs

Please report them on the Github issue tracker for this project.

If you have a bug to report, please include the following information:

  • Version information for geo_ip, ruby and/or rails.
  • Stack trace and error message.

You may also fork this project on Github and create a pull request. Do not forget to include tests.

Copyright

Copyright (c) 2010-2018 Jeroen Jacobs. See LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].