Prerequisites
- A Java 17+ project with
io.ip-api:ipapiadded - A free ip-api.io API key
Autonomous system with asn
Returns the ASN, owning organization, network range, and country for an IP — and
whether it belongs to a datacenter. Nullable fields may be null.
IpApiClient client = IpApiClient.builder()
.apiKey(System.getenv("IP_API_IO_KEY"))
.build();
AsnLookup asn = client.asn("8.8.8.8");
System.out.println(asn.asn()); // 15169
System.out.println(asn.organization()); // "Google LLC"
System.out.println(asn.isDatacenter()); // true Domain registration with whois
WHOIS record for a domain: registrar, registration/expiry/update dates, name servers, status codes, and the raw WHOIS text.
Whois whois = client.whois("example.com");
if (whois.registrar() != null) {
System.out.println(whois.registrar().name());
}
System.out.println(whois.registeredOn()); // "1995-08-14"
System.out.println(whois.nameServers()); DNS with reverseDns, forwardDns & mxRecords
Resolve a PTR record, resolve a hostname to addresses, or list a domain's mail servers.
var rdns = client.reverseDns("8.8.8.8");
System.out.println(rdns.hostname()); // "dns.google"
var fdns = client.forwardDns("dns.google");
fdns.addresses().forEach(record ->
System.out.println(record.type() + " " + record.address() + " " + record.ttl())); // "A" "8.8.8.8" 300
var mx = client.mxRecords("example.com");
mx.mxRecords().forEach(record ->
System.out.println(record.priority() + " " + record.hostname() + " " + record.ttl()));