Prerequisites
- A Swift 5.9+ project with
ipapi-swiftadded - A free ip-api.io API key
Age of one domain with domainAge
Returns the registration date and the age in years and days.
let client = IpApiClient(apiKey: ProcessInfo.processInfo.environment["IP_API_IO_KEY"]!)
let age = try await client.domainAge(domain: "example.com")
print(age.isValid) // true
print(age.registrationDate ?? "") // "1995-08-14"
if let days = age.ageInDays {
print(days) // 11000+
if days < 30 {
// treat brand-new domains as higher risk
}
} Many domains with domainAgeBatch
Check an array of domains in one request (throws if empty).
let batch = try await client.domainAgeBatch(
domains: ["example.com", "brand-new-domain.xyz"])
for (domain, age) in batch.results {
if let days = age.ageInDays {
print(domain, days)
}
}