IP Lookup API - Ruby Gem
IP Lookup resolves an IP address to its geographic location. It returns the country, region, city, coordinates, postal code, timezone and continent, along with an accuracy radius and an EU-membership flag for compliance routing.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_iplookup'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_iplookup
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_iplookup'
# Initialize the client
client = APIVerve::Iplookup::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({ ip: "173.172.81.20" })
# Print the response
puts response
Error Handling
begin
response = client.execute({ ip: "173.172.81.20" })
puts response["data"]
rescue APIVerve::Iplookup::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Iplookup::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Iplookup::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"ip": "173.172.81.20",
"country": "US",
"countryName": "United States",
"region": "MO",
"regionName": "Missouri",
"city": "Kansas City",
"continent": "NA",
"continentName": "North America",
"timezone": "America/Chicago",
"coordinates": [
39.0831,
-94.5853
],
"postalCode": "64106",
"accuracyRadius": 20,
"isEU": false
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://iplookup.apiverve.com?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.