Socket
Socket
Sign inDemoInstall

@e9x/ipi

Package Overview
Dependencies
41
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@e9x/ipi

A free library/cli tool to get IP information.


Version published
Maintainers
1
Weekly downloads
15
decreased by-81.71%

Weekly downloads

Readme

Source

IPI (IP-Info)

npm version

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)

testduration
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.

Keywords

FAQs

Last updated on 06 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc