To use an IP location finding API, you need to send a GET request to the API's endpoint. Here's how you can do it using Ruby:
require 'net/http'
require 'uri'
require 'json'
ip = 'IP_Address' # Replace with the IP Address you want to lookup
token = 'YOUR_API_KEY' # Replace with your actual API key
uri = URI("https://api.findip.net/#{ip}/?token=#{token}")
response = Net::HTTP.get(uri)
data = JSON.parse(response)
puts 'City Name: ' + data['city']['names']['en']
puts 'Continent Code: ' + data['continent']['code']
puts 'Country Name: ' + data['country']['names']['en']
puts 'Latitude: ' + data['location']['latitude'].to_s
puts 'Longitude: ' + data['location']['longitude'].to_s
puts 'Time Zone: ' + data['location']['time_zone']
puts 'Weather Code: ' + data['location']['weather_code']
data['subdivisions'].each do |subdivision|
if subdivision['names'].has_key?('en')
puts 'Subdivision Name: ' + subdivision['names']['en']
end
end
puts 'Autonomous System Number: ' + data['traits']['autonomous_system_number'].to_s
puts 'Autonomous System Organization: ' + data['traits']['autonomous_system_organization']
puts 'Connection Type: ' + data['traits']['connection_type']
puts 'ISP: ' + data['traits']['isp']
puts 'User Type: ' + data['traits']['user_type']
Remember to replace 'IP_Address' and 'YOUR_API_KEY' with the actual IP address you want to verify and your actual API key. Also, ensure to have the necessary packages installed (net/http, uri, json).