TypeScript SDK
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.
- Source: lavrox/SDK-IPWho-IP-Geolocation-Typescript
- npm:
@ipwho/ipwho - API key: ipwho.org/free-plan
Installation
Section titled “Installation”npm install @ipwho/ipwhoRequires Node.js 18+ (native fetch) or a modern browser.
Quick start
Section titled “Quick start”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 /meconst 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 Statesconsole.log(res.data.connection.asnNumber); // 15169Client class is IPWhoClient (v1 used IPWho).
Error handling
Section titled “Error handling”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 }}Migrating from v1
Section titled “Migrating from v1”| v1 | v2 |
|---|---|
getIp(ip) / getLocation(ip) | lookup(ip) then res.data.geoLocation |
getMe() / getLocation() | me() |
getTimezone / getConnection / getSecurity | nested on lookup(ip).data |
| (missing) | bulk(ips) |
Methods
Section titled “Methods”lookup(ip, options?)—GET /ip/{ip}me(options?)—GET /mebulk(ips)—GET /bulk/{a,b,c}; rows ondata.responseArray