Go SDK · Feature

ASN & DNS Lookups in Go

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 are pointers.

client := ipapi.NewClient(ipapi.WithAPIKey(os.Getenv("IP_API_IO_KEY")))
ctx := context.Background()

asn, _ := client.ASN(ctx, "8.8.8.8")

if asn.ASN != nil {
	fmt.Println(*asn.ASN)          // 15169
}
if asn.Organization != nil {
	fmt.Println(*asn.Organization) // "Google LLC"
}
fmt.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, _ := client.Whois(ctx, "example.com")

if whois.Registrar != nil && whois.Registrar.Name != nil {
	fmt.Println(*whois.Registrar.Name)
}
if whois.RegisteredOn != nil {
	fmt.Println(*whois.RegisteredOn) // "1995-08-14"
}
fmt.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.

rdns, _ := client.ReverseDNS(ctx, "8.8.8.8")
if rdns.Hostname != nil {
	fmt.Println(*rdns.Hostname) // "dns.google"
}

fdns, _ := client.ForwardDNS(ctx, "dns.google")
for _, record := range fdns.Addresses {
	fmt.Println(record.Type, record.Address, record.TTL) // "A" "8.8.8.8" 300
}

mx, _ := client.MXRecords(ctx, "example.com")
for _, record := range mx.MXRecords {
	fmt.Println(record.Priority, record.Hostname, record.TTL)
}
Reference

Response reference

MethodReturnsKey fields
ASN(ctx, ip)*ASNLookupIP, ASN, Organization, Network, IsDatacenter, Country, CountryCode
Whois(ctx, domain)*WhoisDomain, Registrar, RegisteredOn, ExpiresOn, UpdatedOn, NameServers, Status, Raw
ReverseDNS(ctx, ip)*ReverseDNSIP, Hostname, PTRRecord, TTL
ForwardDNS(ctx, hostname)*ForwardDNSHostname, Addresses (each Type, Address, TTL)
MXRecords(ctx, domain)*MXLookupDomain, MXRecords (each Priority, Hostname, TTL)
FAQ

Frequently asked questions

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

Call client.ASN(ctx, ip). It returns the ASN number, owning organization, network range, country, and whether the IP belongs to a datacenter. Nullable fields are pointers.

How do I do a WHOIS lookup in Go?

Use client.Whois(ctx, 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(ctx, ip) returns the PTR hostname for an IP, and client.ForwardDNS(ctx, hostname) resolves a hostname to its A/AAAA addresses. client.MXRecords(ctx, domain) returns a domain's mail servers.

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

MXRecords(ctx, 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 Go SDK

Run go get github.com/ip-api-io/ipapi-go, drop in your free API key, and ship in minutes — one typed, context-aware 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 ipapi-go module is open source. Open an issue or pull request on GitHub and we'll take a look.

Open on GitHub