Here's a Ruby example calling the ipdata.co API.
It's fast and has reliable performance thanks to having 10 global endpoints each able to handle >10,000 requests per second!
This answer uses a 'test' API Key that is very limited and only meant for testing a few calls. Signup for your own Free API Key and get up to 1500 requests daily for development.
Replace 78.8.53.5
with any ip you want to look up
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'
headers = {
:accept => 'application/json'
}
response = RestClient.get 'https://api.ipdata.co/78.8.53.5?api-key=test', headers
puts response
That'd give you
{
"ip": "78.8.53.5",
"is_eu": true,
"city": "G\u0142og\u00f3w",
"region": "Lower Silesia",
"region_code": "DS",
"country_name": "Poland",
"country_code": "PL",
"continent_name": "Europe",
"continent_code": "EU",
"latitude": 51.6557,
"longitude": 16.089,
"asn": "AS12741",
"organisation": "Netia SA",
"postal": "67-200",
"calling_code": "48",
"flag": "https://ipdata.co/flags/pl.png",
"emoji_flag": "\ud83c\uddf5\ud83c\uddf1",
"emoji_unicode": "U+1F1F5 U+1F1F1",
"carrier": {
"name": "Netia",
"mcc": "260",
"mnc": "07"
},
"languages": [
{
"name": "Polish",
"native": "Polski"
}
],
"currency": {
"name": "Polish Zloty",
"code": "PLN",
"symbol": "z\u0142",
"native": "z\u0142",
"plural": "Polish zlotys"
},
"time_zone": {
"name": "Europe/Warsaw",
"abbr": "CEST",
"offset": "+0200",
"is_dst": true,
"current_time": "2018-08-29T15:34:23.518065+02:00"
},
"threat": {
"is_tor": false,
"is_proxy": false,
"is_anonymous": false,
"is_known_attacker": false,
"is_known_abuser": false,
"is_threat": false,
"is_bogon": false
},
}