Prerequisites
- Ruby 3.0+ with
ip-api-ioinstalled - A free ip-api.io API key
Age of one domain with domain_age
Returns the registration date and the age in years and days.
client = Ipapi::Client.new(api_key: ENV.fetch("IP_API_IO_KEY"))
age = client.domain_age("example.com")
puts age.valid? # true
puts age.registration_date # "1995-08-14"
if age.age_in_days
puts age.age_in_days # 11000+
# treat brand-new domains as higher risk
flag_for_review if age.age_in_days < 30
end Many domains with domain_age_batch
Check an array of domains in one request (raises ArgumentError if empty).
batch = client.domain_age_batch([
"example.com",
"brand-new-domain.xyz"
])
batch.results.each do |domain, age|
puts "#{domain} #{age.age_in_days}" if age.age_in_days
end