This Ruby code performs the following steps:

  1. Sets the API credentials (username and password).
  2. Defines the IP address to query.
  3. Constructs the API endpoint URL.
  4. Creates a URI object with the API URL.
  5. Creates an HTTP object and enables SSL for secure communication.
  6. Creates a GET request object.
  7. Sets the basic authentication header using Base64 encoding.
  8. Sends the HTTP request to the API endpoint.
  9. Checks the response code and prints the response body if the request was successful.
require 'net/http'
require 'base64'

# API credentials
username = 'username'
password = 'password'

# IP address to query
ip_address = ''

# API endpoint
api_url = "{ip_address}"

# Create URI object
uri = URI(api_url)

# Create HTTP object
http =, uri.port)
http.use_ssl = true

# Create request
request =

# Set basic authentication header
auth_string = "#{username}:#{password}"
encoded_auth_string = Base64.strict_encode64(auth_string)
request['Authorization'] = "Basic #{encoded_auth_string}"

# Send request
response = http.request(request)

# Check response
if response.code == '200'
  puts response.body
  puts "Error: #{response.code} - #{response.message}"

Make sure to replace ‘username’ and ‘password’ with your actual API credentials.