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

rockygeo

v0.1.0

Published

Minimal fetch-based TypeScript client for the RockyGeo IP Geolocation API

Readme

rockygeo

Minimal fetch-based TypeScript client for the RockyGeo IP Geolocation API.

Use cases

  • Content localization — pick language, currency, or regional content from country_code / region.
  • Compliance and access control — gate features or block traffic by country or region.
  • Analytics and segmentation — enrich server logs, events, or sign-ups with geo dimensions.
  • Timezone-aware UX — schedule emails, show local times, or pick date formats from tz.
  • Fraud and abuse signals — compare claimed location vs. IP-derived country/city as a risk signal.
  • Bulk enrichment — resolve many IPs in one round trip with the batch endpoint (imports, ETL, nightly jobs).

Install

yarn add rockygeo

Requires Node.js 18+ (global fetch).

Quick start

import { RockyGeoClient } from 'rockygeo';

const client = new RockyGeoClient({ apiKey: 'your-api-key' });

const geo = await client.lookup('8.8.8.8');
console.log(geo.country, geo.city);

const batch = await client.lookupBatch(['8.8.8.8', '1.1.1.1']);
console.log(batch.results['8.8.8.8'].country_code);

const health = await client.health();
console.log(health.dataVersion, health.lastSyncAt);

Anonymous requests work without an API key (lower rate limit).

Get an API key

Subscribe through one of these providers for higher rate limits:

RapidAPI — Rocky Geo

Use your RapidAPI subscription key with the x-rapidapi-key header:

const client = new RockyGeoClient({
  apiKey: process.env.RAPIDAPI_KEY,
  authHeader: 'x-rapidapi-key',
});

API.market — Rocky Geo

Use your API.market subscription key with the default x-api-market-key header:

const client = new RockyGeoClient({
  apiKey: process.env.APIMARKET_KEY,
  healthEndpoint: '/health',
  healthBaseUrl: 'https://prod.api.market/api/v1/rocky/geo',
});

Configuration

| Option | Default | Description | |--------|---------|-------------| | baseUrl | https://prod.api.market | API base URL | | apiKey | — | API key | | authHeader | x-api-market-key | Auth header name (x-api-market-key or x-rapidapi-key) |

API reference

lookup(ip: string): Promise<GeoRecord>

Look up a single IPv4 or IPv6 address.

  • Returns geolocation data on success (found: true).
  • Throws RockyGeoError with status: 404 and ip when no geo data exists.
  • Throws on invalid IP (400), rate limit (429), or server error (500).

lookupBatch(ips: string[]): Promise<BatchResponse>

Look up up to 100 IPs in one request.

  • Always returns a results map on success.
  • Unknown or invalid IPs appear with found: false (never returns 404).
  • Validates batch size locally (1–100) before sending.

health(): Promise<HealthResponse>

Returns service health, data version, last sync time, and uptime. No authentication required.

Error handling

import { RockyGeoClient, RockyGeoError } from 'rockygeo';

try {
  await client.lookup('10.0.0.1');
} catch (error) {
  if (error instanceof RockyGeoError) {
    console.error(error.message, error.status, error.ip);

    if (error.status === 429 && error.rateLimit?.retryAfter) {
      console.log(`Retry after ${error.rateLimit.retryAfter}s`);
    }
  }
}

For batch lookups, check found on each result instead of catching 404:

const { results } = await client.lookupBatch(['8.8.8.8', '10.0.0.1']);
if (!results['10.0.0.1'].found) {
  console.log('No geo data for 10.0.0.1');
}

Types

Exported types: GeoRecord, BatchResponse, HealthResponse, RockyGeoClientConfig, RockyGeoAuthHeader, RockyGeoRateLimit, RockyGeoErrorBody.

License

MIT

#geolocation #geoip #ip #rockygeo #typescript #nodejs #ip-geolocation #api-client