Java SDK · Feature

ASN & DNS Lookups in Java

Resolve the network and DNS layer behind an IP or domain: which autonomous system owns an address, who registered a domain, what a host's PTR record is, and which mail servers a domain uses — all from the same client.

Trusted by thousands of businesses
Fast JSON API responses
Real-time validation
Simple integration, SDKs & examples
What it does

Network ownership and DNS in one client

Behind every IP and domain is a network and DNS layer that tells you who owns the address space, when a domain was registered, and how its mail and hostnames resolve. ip-api.io exposes ASN, WHOIS, reverse/forward DNS, and MX lookups through the same client, so you can enrich logs, verify ownership, and feed fraud rules without juggling separate DNS libraries.

Prerequisites

1

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
2

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());
3

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()));
Reference

Response reference

MethodReturnsKey accessors
asn(ip)AsnLookupip(), asn(), organization(), network(), isDatacenter(), country(), countryCode()
whois(domain)Whoisdomain(), registrar(), registeredOn(), expiresOn(), updatedOn(), nameServers(), status(), raw()
reverseDns(ip)ReverseDnsip(), hostname(), ptrRecord(), ttl()
forwardDns(hostname)ForwardDnshostname(), addresses() (each type(), address(), ttl())
mxRecords(domain)MxLookupdomain(), mxRecords() (each priority(), hostname(), ttl())
FAQ

Frequently asked questions

How do I find the ASN and owner of an IP in Java?

Call client.asn(ip). It returns the ASN number, owning organization, network range, country, and whether the IP belongs to a datacenter. Nullable fields may be null.

How do I do a WHOIS lookup in Java?

Use client.whois(domain). It returns the registrar, registration/expiry/update dates, name servers, status codes, and the raw WHOIS text for a domain.

Can I do reverse and forward DNS lookups?

Yes. client.reverseDns(ip) returns the PTR hostname for an IP, and client.forwardDns(hostname) resolves a hostname to its A/AAAA addresses. client.mxRecords(domain) returns a domain's mail servers.

What's the difference between mxRecords here and email validation?

mxRecords(domain) returns the raw MX records (priority, hostname, ttl) for DNS inspection. The email validation methods use MX presence as one input to a deliverability verdict for a specific address.

Start building with the ip-api.io Java SDK

Add io.ip-api:ipapi to your build, drop in your free API key, and ship in minutes — one client for geolocation, fraud detection, and email validation.

Need support?

Explore how IP-API.io can enhance your security, provide robust bot protection, and improve IP geolocation accuracy for your applications.

Contact Support

Found a bug in the SDK?

The io.ip-api:ipapi library is open source. Open an issue or pull request on GitHub and we'll take a look.

Open on GitHub