JavaScript SDK · Feature

ASN & DNS Lookups in Node.js

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 one typed ip-api-io client.

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

The network layer behind an address

Geolocation tells you where an IP is; ASN and DNS lookups tell you who runs it and how it's connected. Identify the owning organization and whether an IP is hosted in a datacenter, pull a domain's WHOIS record and registration dates, resolve hostnames in both directions, and read a domain's mail servers — the building blocks for abuse investigation, deliverability checks, and infrastructure tooling.

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.

import { IpApiClient } from "ip-api-io";

const client = new IpApiClient({ apiKey: process.env.IP_API_IO_KEY });

const asn = await client.asn("8.8.8.8");

console.log(asn.asn);            // 15169
console.log(asn.organization);  // "Google LLC"
console.log(asn.network);       // "8.8.8.0/24"
console.log(asn.is_datacenter); // true
console.log(asn.country_code);  // "US"
2

Domain registration with whois

WHOIS record for a domain: registrar, registration/expiry/update dates, name servers, status codes, and the raw WHOIS text.

const whois = await client.whois("example.com");

console.log(whois.registrar?.name);
console.log(whois.registered_on);     // "1995-08-14"
console.log(whois.expires_on);
console.log(whois.name_servers);      // ["a.iana-servers.net", ...]
console.log(whois.status[0]?.humanized);
3

Reverse & forward DNS

Resolve an IP to its PTR hostname, or a hostname to its addresses.

const rdns = await client.reverseDns("8.8.8.8");
console.log(rdns.hostname);    // "dns.google"
console.log(rdns.ptr_record);
console.log(rdns.ttl);

const fdns = await client.forwardDns("dns.google");
for (const record of fdns.addresses) {
  console.log(record.type, record.address, record.ttl); // "A" "8.8.8.8" 300
}
4

Mail servers with mxRecords

const mx = await client.mxRecords("example.com");

for (const record of mx.mx_records) {
  console.log(record.priority, record.hostname, record.ttl);
}
Cleaning email lists? The same MX data powers email validation — use emailInfo / validateEmail for deliverability checks.
Reference

Response reference

MethodReturnsKey fields
asn(ip)AsnLookupip, asn, organization, network, is_datacenter, country, country_code
whois(domain)Whoisregistrar (name, url, iana_id), registered_on, expires_on, updated_on, name_servers, status, raw
reverseDns(ip)ReverseDnsip, hostname, ptr_record, ttl
forwardDns(hostname)ForwardDnshostname, addresses (each type, address, ttl)
mxRecords(domain)MxLookupdomain, mx_records (each priority, hostname, ttl)
FAQ

Frequently asked questions

How do I do a reverse DNS lookup in Node.js?

Call await client.reverseDns(ip). It returns the hostname (PTR record), the raw ptr_record, and the ttl. For the opposite direction, client.forwardDns(hostname) resolves a host to its A/AAAA addresses.

How do I look up the ASN that owns an IP?

Use client.asn(ip). It returns the asn number, owning organization, network range, country, and whether the address belongs to a datacenter.

Can I get WHOIS data for a domain in Node.js?

Yes. client.whois(domain) returns the registrar, registration/expiry/update dates, name servers, status codes, and the raw WHOIS text. For just the registration age, use domainAge.

How do I fetch a domain's MX records?

Call client.mxRecords(domain). It returns an mx_records array where each entry has priority, hostname, and ttl — the same data used to confirm an email domain can receive mail.

Start building with the ip-api.io JavaScript SDK

Install ip-api-io, drop in your free API key, and ship in minutes — one typed 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 ip-api-io package is open source. Open an issue or pull request on GitHub and we'll take a look.

Open on GitHub