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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@e9x/ipi

v2.1.0

Published

A free library/cli tool to get IP information.

Downloads

50

Readme

IPI (IP-Info)

A free library/cli tool to get IP information.

Performance

Due to the nature of libraries used (SQLite3, IP2Location), this project is seemingly littered with synchronous operations.

Despite this, this project still delivers reasonable runtime performance that beats using an API.

Benchmarks: (not quite accurate, tested on my development machine)

| test | duration | | ----------- | -------- | | require() | 44.36 ms | | ipi() | 0.066 ms |

An extreme solution to the blocking API is wrapping the API with piscina.

Maintenance

You might want to update the databases library from time to time. Databases will be updated usually every month (No guarantees 😅️)

npm i @e9x/ipi-databases@latest

API

Example:

import ipi from "@e9x/ipi";

const ipInfo = ipi("69.42.0.123");
console.log(ipInfo);
{
  success: true,
  asn: 11404,
  asd: 'AS-WAVE-1',
  city: 'San Francisco',
  region: 'California',
  zipCode: '94102',
  timezone: '-08:00',
  latitude: 37.774929,
  longitude: -122.419418,
  countryLong: 'United States of America',
  countryShort: 'US'
}

If you need to access the IPInfo type (TypeScript):

import ipi, { IPInfo } from "@e9x/ipi";

const whatever: IPInfo = ipi("69.42.0.123");

console.log(whatever);

CLI

Install the CLI tool globally:

$ npm install --location=global @e9x/ipi

If you encounter a read/write error when running the tool after installing globally on Linux, refer to https://github.com/sindresorhus/guides/blob/main/npm-global-without-sudo.md

The CLI syntax is as follows:

Usage: ipi <IP>

IP-Info cli

Arguments:
  IP          IP address. Can be IPv4 or IPv6.

Example:

$ ipi 2607:f188::dead:beef:cafe:fed1
{
  success: true,
  asn: 21769,
  asd: 'AS-COLOAM',
  city: 'Las Vegas',
  region: 'Nevada',
  zipCode: '89136',
  timezone: '-07:00',
  latitude: 36.174969,
  longitude: -115.137222,
  countryLong: 'United States of America',
  countryShort: 'US'
}

API

Install the dependency:

$ npm i @e9x/ipi

See examples/ for examples of the API.

Usage in libraries

As of v2.0.0-beta, this package is safe to use in libraries! Data fetching is done when publishing the package.