{"id":22108419,"url":"https://github.com/jeroenj/geo_ip","last_synced_at":"2025-04-05T23:08:29.319Z","repository":{"id":56873954,"uuid":"464996","full_name":"jeroenj/geo_ip","owner":"jeroenj","description":"Retreive the geolocation of an IP address based on the ipinfodb.com webservice","archived":false,"fork":false,"pushed_at":"2022-11-08T22:01:31.000Z","size":75,"stargazers_count":104,"open_issues_count":2,"forks_count":26,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-04-29T18:08:59.543Z","etag":null,"topics":["country","geoip","geolocation","ipinfodb","ruby","timezone-information","webservice"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/geo_ip","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeroenj.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-01-09T10:49:50.000Z","updated_at":"2023-04-04T13:47:56.000Z","dependencies_parsed_at":"2023-01-21T13:45:46.307Z","dependency_job_id":null,"html_url":"https://github.com/jeroenj/geo_ip","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeroenj%2Fgeo_ip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeroenj%2Fgeo_ip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeroenj%2Fgeo_ip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeroenj%2Fgeo_ip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeroenj","download_url":"https://codeload.github.com/jeroenj/geo_ip/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411234,"owners_count":20934653,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["country","geoip","geolocation","ipinfodb","ruby","timezone-information","webservice"],"created_at":"2024-12-01T09:14:49.927Z","updated_at":"2025-04-05T23:08:29.283Z","avatar_url":"https://github.com/jeroenj.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GeoIp\n\nRetreive the geolocation of an IP address based on the [ipinfodb.com](http://ipinfodb.com/) webservice.\n\nAs of 8th November 2010, the service is asking that all users [register](http://ipinfodb.com/register.php) for an API key.\n\nConsider making a donation to [ipinfodb.com](http://ipinfodb.com/) at [http://ipinfodb.com/donate.php](http://ipinfodb.com/donate.php).\n\n## Usage\n\n### Set API key\n    GeoIp.api_key = 'YOUR_API_KEY'\n\nThis must be done before making the geolocation call.\n\n### Retrieve geolocation\n    GeoIp.geolocation(ip_address)\n\n### Example\n\n    # 209.85.227.104 = google.be (US)\n    GeoIp.geolocation('209.85.227.104')\n\nreturns:\n\n    {\n      :status_code    =\u003e \"OK\",\n      :status_message =\u003e \"\",\n      :ip             =\u003e \"209.85.227.104\"\n      :country_code   =\u003e \"US\",\n      :country_name   =\u003e \"UNITED STATES\",\n      :region_name    =\u003e \"CALIFORNIA\",\n      :city           =\u003e \"MONTEREY PARK\",\n      :zip_code       =\u003e \"91754\",\n      :latitude       =\u003e \"34.0505\",\n      :longitude      =\u003e \"-118.13\"\n    }\n\n### Country only\n\nThere 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.\n\n    GeoIp.geolocation('209.85.227.104', :precision =\u003e :country)\n\nreturns:\n\n    {\n      :status_code    =\u003e \"OK\",\n      :status_message =\u003e \"\",\n      :ip             =\u003e \"209.85.227.104\"\n      :country_code   =\u003e \"US\",\n      :country_name   =\u003e \"UNITED STATES\"\n    }\n\n### Timezone information\n\nThere is an option now to retrieve optional timezone information too:\n\n    GeoIp.geolocation('209.85.227.104', :timezone =\u003e true)\n\nreturns:\n\n    {\n      :status_code    =\u003e \"OK\",\n      :status_message =\u003e \"\",\n      :ip             =\u003e \"209.85.227.104\"\n      :country_code   =\u003e \"US\",\n      :country_name   =\u003e \"UNITED STATES\",\n      :region_name    =\u003e \"CALIFORNIA\",\n      :city           =\u003e \"MONTEREY PARK\",\n      :zip_code       =\u003e \"91754\",\n      :latitude       =\u003e \"34.0505\",\n      :longitude      =\u003e \"-118.13\"\n      :timezone       =\u003e \"-08:00\"\n    }\n\nObviously it is not possible to have the country precision enabled while retrieving the timezone information.\n\n### Reserved / Private / Local IPs\n\nPassing reserved, private or local IPs, such as `127.0.0.1` will return `-` for all location data, for example:\n\n    GeoIp.geolocation('127.0.0.1')\n\nreturns:\n\n    {\n      :status_code    =\u003e \"OK\",\n      :status_message =\u003e \"\",\n      :ip             =\u003e \"127.0.0.1\",\n      :country_code   =\u003e \"-\",\n      :country_name   =\u003e \"-\",\n      :region_name    =\u003e \"-\",\n      :city           =\u003e \"-\",\n      :zip_code       =\u003e \"-\",\n      :latitude       =\u003e \"0\",\n      :longitude      =\u003e \"0\"\n    }\n\n### Timeout\n\nIt 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:\n\n    GeoIp.timeout = 5 # In order to set it to five seconds\n\n## Getting it\n\nGeoIp can be installed as a Ruby Gem:\n\n    gem install geo_ip\n\n*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.\n\n### Rails\n\n#### Bundler enabled (Rails 3.x and 2.3.x)\n\nIn your Gemfile:\n\n    gem 'geo_ip'\n\nThen create an initializer `config/initializers/geo_ip` (or name it whatever you want):\n\n    GeoIp.api_key = 'YOUR_API_KEY'\n\n#### Pre-bundler (Rails 2.3.x or older)\n\nIn your `config/environment.rb`:\n\n    config.gem 'geo_ip'\n\nThen create an initializer `config/initializers/geo_ip` (or name it whatever you want):\n\n    GeoIp.api_key = 'YOUR_API_KEY'\n\n## Testing\n\nSet 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:\n\n    ruby spec/geo_ip_spec.rb\n\nIf you get a LoadError, you should run the tests with:\n\n    ruby -rubygems spec/geo_ip_spec.rb\n\n## Contributors\n\n* [seanconaty](https://github.com/seanconaty)\n* [luigi](https://github.com/luigi)\n* [idris](https://github.com/idris)\n* [Rylon](https://github.com/Rylon)\n* [harleyttd](https://github.com/harleyttd)\n* [dnswus](https://github.com/dnswus)\n\n## Bugs\n\nPlease report them on the [Github issue tracker](https://github.com/jeroenj/geo_ip/issues)\nfor this project.\n\nIf you have a bug to report, please include the following information:\n\n* Version information for geo_ip, ruby and/or rails.\n* Stack trace and error message.\n\nYou may also fork this project on Github and create a pull request.\nDo not forget to include tests.\n\n## Copyright\n\nCopyright (c) 2010-2018 Jeroen Jacobs. See LICENSE for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeroenj%2Fgeo_ip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeroenj%2Fgeo_ip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeroenj%2Fgeo_ip/lists"}