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

ipregion-js

v1.0.3

Published

Node.js wrapper for ipregion bash script - determines IP geolocation using various GeoIP services

Downloads

11

Readme

ipregion-js

Node.js ESM wrapper for ipregion bash script - determines your IP geolocation using various GeoIP services and popular websites.

Features

  • 🌍 Checks IP geolocation using multiple public GeoIP APIs
  • 📺 Results from popular web services (YouTube, Netflix, Twitch, etc.)
  • 🔄 Supports both IPv4 and IPv6
  • 🔒 SOCKS5 proxy and custom network interface support
  • 📊 JSON output with most likely country detection
  • 🎨 Color-coded CLI output (when used as command-line tool)
  • 📦 ESM module with TypeScript-friendly JSDoc types

Requirements

  • Node.js >= 16.0.0
  • Unix-like OS (Linux, macOS, BSD)
  • Bash
  • Dependencies for ipregion.sh:
    • curl
    • jq
    • util-linux or bsdmainutils (for column)

Installation

As a global CLI tool

npm install -g ipregion-js

As a module in your project

npm install ipregion-js

Usage

Command Line Interface

After global installation, you can use ipregion command directly:

# Show help message
ipregion --help

# Check all services with default settings
ipregion

# Check only GeoIP services
ipregion --group primary

# Check only popular web services
ipregion --group custom

# Test only IPv4
ipregion --ipv4

# Use SOCKS5 proxy
ipregion --proxy 127.0.0.1:1080

# Output as JSON
ipregion --json

As ESM Module

import ipregion from 'ipregion-js';
// or
import { ipregion } from 'ipregion-js';

// Basic usage
const result = await ipregion();
console.log('Your IP:', result.ipv4);
console.log('Most likely country:', result.mostLikelyCountry);

// With options
const result = await ipregion({
  group: 'primary',    // 'primary', 'custom', 'cdn', or 'all'
  ipv4: true,          // Test only IPv4
  timeout: 20,         // Timeout in seconds
  proxy: '127.0.0.1:1080', // SOCKS5 proxy
  verbose: false       // Verbose logging
});

// Process results
result.results.primary.forEach(service => {
  console.log(`${service.service}: ${service.ipv4}`);
});

Example Response

{
  "version": 1,
  "ipv4": "181.158.133.39",
  "ipv6": null,
  "mostLikelyCountry": "NL",  // Added by ipregion-js
  "results": {
    "primary": [
      {
        "service": "maxmind.com",
        "ipv4": "EE",
        "ipv6": null
      },
      {
        "service": "ipinfo.io",
        "ipv4": "NL",
        "ipv6": null
      }
      // ... more services
    ],
    "custom": [
      {
        "service": "Google",
        "ipv4": "RU",
        "ipv6": null
      },
      {
        "service": "Netflix",
        "ipv4": "NL",
        "ipv6": null
      }
      // ... more services
    ],
    "cdn": [
      {
        "service": "Cloudflare CDN",
        "ipv4": "NL (AMS)",
        "ipv6": null
      }
      // ... more services
    ]
  }
}

API

ipregion(options?: IPRegionOptions): Promise<IPRegionResult>

Main function to check IP geolocation.

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | verbose | boolean | false | Enable verbose logging | | group | string | 'all' | Service group: 'primary', 'custom', 'cdn', or 'all' | | timeout | number | 10 | Curl request timeout in seconds | | ipv4 | boolean | false | Test only IPv4 | | ipv6 | boolean | false | Test only IPv6 | | proxy | string | - | SOCKS5 proxy (format: host:port) | | interface | string | - | Network interface to use |

Returns

Promise that resolves to an object with:

  • version: API version
  • ipv4: Your IPv4 address or null
  • ipv6: Your IPv6 address or null
  • mostLikelyCountry: Most frequently detected country code
  • results: Object with service groups ('primary', 'custom', 'cdn')

Country Codes

The script outputs country codes in ISO 3166-1 alpha-2 format (e.g., RU, US, DE). You can look up the meaning of any country code at: https://www.iso.org/obp/ui/#search/code/

Service Groups

  • primary: GeoIP services (MaxMind, IPInfo, Cloudflare, etc.)
  • custom: Popular websites (Google, Netflix, Twitch, etc.)
  • cdn: CDN services (Cloudflare CDN, YouTube CDN, Netflix CDN)

Notes

  • The ipregion.sh in CLI mode is updated automatically. When imported as a module, a permanent script built into the module is used, which can only be updated in another version of the module.
  • This package works only on Unix-like systems (Linux, macOS, BSD)
  • Windows is not supported due to bash dependency
  • The mostLikelyCountry field is calculated based on the most frequently appearing country code across all services

Credits

This is a Node.js wrapper for the original ipregion bash script by @vernette.

License

MIT License - see LICENSE file for details.

Links