Skip to content

TypeScript SDK

npm version GitHub

The IPWho TypeScript SDK wraps the IP geolocation API in idiomatic TypeScript — typed responses, built-in error classes, and zero-dependency installation. One call returns the full payload: geolocation, timezone, currency, connection (ASN/ISP), security flags, and more.

Terminal window
npm install @ipwho/ipwho

Requires Node.js 18+ (native fetch) or a modern browser.

import { IPWhoClient } from '@ipwho/ipwho';
const client = new IPWhoClient(process.env.IPWHO_API_KEY);
const res = await client.lookup('8.8.8.8'); // GET /ip/{ip}
const me = await client.me(); // GET /me
const bulk = await client.bulk(['8.8.8.8', '1.1.1.1']); // GET /bulk/{a,b,c}
console.log(res.data.ip);
console.log(res.data.geoLocation.country); // United States
console.log(res.data.connection.asnNumber); // 15169

Client class is IPWhoClient (v1 used IPWho).

import { IPWhoClient, InvalidIPError, RateLimitError, APIResponseError } from '@ipwho/ipwho';
try {
const res = await client.lookup('8.8.8.8');
} catch (e) {
if (e instanceof InvalidIPError) {
// malformed IP address (404)
} else if (e instanceof RateLimitError) {
// plan limit reached (429)
} else if (e instanceof APIResponseError) {
// unexpected response
}
}
v1v2
getIp(ip) / getLocation(ip)lookup(ip) then res.data.geoLocation
getMe() / getLocation()me()
getTimezone / getConnection / getSecuritynested on lookup(ip).data
(missing)bulk(ips)
  • lookup(ip, options?) — GET /ip/{ip}
  • me(options?) — GET /me
  • bulk(ips) — GET /bulk/{a,b,c}; rows on data.responseArray