An API Key from Heroku
Ruby v2.x or greater
Index | Name | Example | Description |
---|---|---|---|
0 | ip |
string | IPv4 or IPv6 address |
$ > require "ip_to_earth"
# Note: the 'Controller' here is not a reference to Rails controllers
# but an internal structure, won't interfere with your Rails app and will
# work fine in a standalone ruby app or another framework
$ > ite = IpToEarth::APIController.new
$ > result = ite.lookup('68.10.149.45') # Pass in any valid IPv4 or IPv6 value
$ > result.valid
=> true
$ > result.country
=> "United States"
$ > result.country_code
=> "US"
$ > result.hostname
=> ""
$ > result.city
=> "Virginia Beach"
$ > result.ip
=> "68.10.149.45"
$ > result.latitude
=> 36.852928161621094
$ > result.longitude
=> -75.97798156738281
$ > result.region
=> "Virginia"
# In your Gemfile
gem 'iptoearth', git: 'https://github.com/mbuckbee/Ip-To-Earth-Gem.git'
Attribute | Type | Description |
---|---|---|
valid |
boolean | If the IP Address passed in is syntactically valid |
country |
string | Full country name where the IP address is located |
country_code |
string | ISO Country Code for the IP Address |
hostname |
string | Hostname - if any - for the IP address |
city |
string | City where the IP Address is located |
ip |
string | IP address that was evaluated |
latitude |
float | Geographic latitude of the identified IP address |
longitude |
float | Geographic longitude of the identified IP address |
region |
string | State or Region where the IP address is located |
Doublecheck results, use a Live Proxy and check your API Key with the interactive documentation at:
http://docs.iptoearthexp.apiary.io/
You will need your IPTOEARTH_API_KEY
from the setup screen where you've provisioned the IP to Earth add-on.
As a sanity check it is sometimes useful to bypass your app stack and check the endpoint, your API Key and parameters directly.
Test with your browser
# Modify the following to use your actual API Key
'https://iptoearth.expeditedaddons.com/?api_key=REPLACE_WITH_YOUR_IPTOEARTH_API_KEY&ip=68.10.149.45'
A successful call will return your requested data with a HTTP result code of 200
and be in JSON
format. We recommend the JSON Formatter extension as a useful tool.
The IP to Earth gem relies upon the environment variable ENV['IPTOEARTH_API_KEY']
being present and correctly configured to authenticate to the service. You will need to have this variable present in your local environment for the gem to work correctly.
If you're using Heroku, please read their Guide to Heroku Local which has instructions on easily copying your config values to your development environment.
DOTENV
https://github.com/bkeepers/dotenv
If you're trying to use IP to Earth in your local development or test environment with the dotenv gem be sure that you are loading the dotenv-rails
gem with the rails-now
requirement.
# Example Gemfile excerpt
gem 'dotenv-rails', :require => 'dotenv/rails-now'
gem 'iptoearth'
FOREMAN
https://github.com/ddollar/foreman
If you're having issues with configuring dotenv
, you might want to try foreman which will also autoload .env
files in your local environment.
Test in the Rails console
Launch rails c
in your development project directory and at the prompt enter ENV[IPTOEARTH_API_KEY]
which, if you've configured your development environment correctly should display your API Key.
Please email support@expeditedaddons.com
The IP to Earth gem is licensed under the MIT license.
If you found IP to Earth useful, please check out our other similarly structured services and gems.
QRACKAJACKGenerate QR codes for use anywhere. |
WEIGHTS & MEASURESConversational interface to convert between units of measure. |
SCRAPETASTICPull structured data from any website. |
USER AGENT IDENTIFIERBoost User Agent identification with our always up to date UA parsing. |
IP INVESTIGATORCheck if an IP address is hosting Proxies, Bots or Malware. |
RESIZERResize images for Retina use, thumbnails and social promotion. |
URL X-RAYPull website status and domain information for any URL. |
WEB TO PDFGenerate PDF Documents from Webpages. |
WATERMARKERIdentify and protect images by adding a watermark to them. |
IP TO EARTHFind the Country and City of origin for an IP Address. |
GEOCODYConvert mailing addresses into Lat,Long Coordinates. |
REAL EMAILReduce bounced emails and errors by validating emails against MX records. |