npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ipgeotrace/client

v0.1.0

Published

Isomorphic IPGeoTrace client for Node, edge, Deno, and Bun. Single and batch IP geolocation with caching and retries.

Readme

@ipgeotrace/client

Isomorphic IPGeoTrace client for Node 18+, edge runtimes, Deno, and Bun. Resolve a single IP or a batch of up to 100, with optional caching and automatic retries. Zero runtime dependencies, fetch-based.

Sign up and grab your API key at ipgeotrace.com.

This is the server-side, secret-key client — you supply the IP. For the browser (resolve the current visitor, no secret key), use @ipgeotrace/browser.

Install

npm add @ipgeotrace/client

Quick start

import { IpGeoTraceClient } from '@ipgeotrace/client';

const client = new IpGeoTraceClient({ apiKey: process.env.IPGEOTRACE_API_KEY! });

const result = await client.resolve('8.8.8.8');
if (result.ok) {
  console.log(`${result.value.city?.name}, ${result.value.country?.name}`);
} else {
  console.log(`failed: ${result.error.code}`);
}

The IP is always supplied by you: a signup form, a webhook payload, a stored audit log. Invalid IPs are caught locally (invalid_ip) with no wasted round trip.

Results, not exceptions

Every call returns Result<T>{ ok: true, value } | { ok: false, error }. Check ok and TypeScript narrows value (or error) for you. The only thrown thing is caller cancellation via an AbortSignal:

const controller = new AbortController();
const result = await client.resolve('8.8.8.8', controller.signal);

Batch lookups

const batch = await client.resolveBatch(logins.map((l) => l.ip));
if (batch.ok) {
  for (const item of batch.value.results) {
    report.add(item.ip, item.found ? item.country?.name : item.error);
  }
}

Results come back in request order, one item per address. A single bad address fails as its own item (found: false, error) without failing the batch. With caching on, cached IPs are served locally and only the misses are sent; if every IP is a hit, no request is made and batch.value.fromCache is true.

Configuration

const client = new IpGeoTraceClient({
  apiKey: '...',
  environment: 'production',   // or 'sandbox'; ignored when baseUrl is set
  baseUrl: undefined,          // absolute override for self-hosted / staging
  timeoutMs: 10_000,
  maxRetries: 2,               // retries 429 (rate_limited) and 503, honoring Retry-After
  cache: true,                 // or supply your own GeoCache (Redis, etc.)
  cacheTtlMs: 5 * 60_000,
  fetch: globalThis.fetch,     // override on Node < 18 or to inject a proxy agent
});

Only successful lookups are cached, never errors. A throwing cache never breaks a lookup — the client falls back to calling the API.

Errors

On failure, error carries the reason:

interface GeoError {
  code: GeoErrorCode;         // GeoErrorCodes.*
  message: string;
  statusCode?: number;
  retryAfterSeconds?: number;
}

Codes: unauthorized, invalid_ip, bad_request, not_found, rate_limited, quota_exceeded, license_inactive, forbidden, service_unavailable, network_error, timeout, invalid_response, unknown.