Prerequisites
- Go 1.21+ with
ipapi-goinstalled - A free ip-api.io API key
Age of one domain with DomainAge
Returns the registration date and the age in years and days.
client := ipapi.NewClient(ipapi.WithAPIKey(os.Getenv("IP_API_IO_KEY")))
ctx := context.Background()
age, err := client.DomainAge(ctx, "example.com")
if err != nil {
log.Fatal(err)
}
fmt.Println(age.IsValid) // true
if age.RegistrationDate != nil {
fmt.Println(*age.RegistrationDate) // "1995-08-14"
}
if age.AgeInDays != nil {
fmt.Println(*age.AgeInDays) // 11000+
if *age.AgeInDays < 30 {
// treat brand-new domains as higher risk
}
} Many domains with DomainAgeBatch
Check a slice of domains in one request (returns an error if empty).
batch, _ := client.DomainAgeBatch(ctx, []string{
"example.com",
"brand-new-domain.xyz",
})
for domain, age := range batch.Results {
if age.AgeInDays != nil {
fmt.Println(domain, *age.AgeInDays)
}
}