Prerequisites
- Node.js 18+ with
ip-api-ioinstalled - 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.
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" 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); 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
} 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);
} emailInfo / validateEmail for deliverability checks.