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

node-ip-details

v0.0.7

Published

ip-details is an lightweight fast node package to find full details of any ip address

Downloads

95

Readme

node-ip details

npm package

node-ip-details is an lightweight fast node package to find full details of any ip address. It is perfect to use when wanting to block requests from certain countries ip addresses, tracking if the request has came from a proxy or not, finding out the internet provider for the ip address and finding full geolocation details for the ip.

super simple to use

node-ip-details has been designed to be the simplest way possible to retrieve full details of any ip address or ip addresses.

native promises

single ip address

// import that library
const ipdetails = require("node-ip-details");
// initilise the class with the config details
const ipInitialised = ipdetails.initialise({ip: "1.1.1.1"});

// return all the information for the IP supplied
ipInitialised.allInformation()
         .then(r => console.dir(r))
         .catch(err => console.error(err))

multiple ip addresses, you can request a maximum of 100 in each request

// import that library
const ipdetails = require("node-ip-details");
// initilise the class with the config details
const ipInitialised = ipdetails.initialise({ips: ["1.1.1.1", "8.8.8.8"]});

// return all the information for the IP supplied
ipInitialised.allInformation()
         .then(r => console.dir(r))
         .catch(err => console.error(err))

async and await

single ip address

// import that library
const ipdetails = require("node-ip-details");
// initilise the class with the config details
const ipInitialised = ipdetails.initialise({ip: "1.1.1.1"});

async () => {
    try {
        const result = await ipInitialised.allInformation()
        console.dir(result)
    } catch (err) {
        // ... error checks
    }
}

multiple ip addresses, you can request a maximum of 100 in each request

// import that library
const ipdetails = require("node-ip-details");
// initilise the class with the config details
const ipInitialised = ipdetails.initialise({ips: ["1.1.1.1", "8.8.8.8"]});

async () => {
    try {
        const result = await ipInitialised.allInformation()
        console.dir(result)
    } catch (err) {
        // ... error checks
    }
}

example successful response for single ip address

{
    city: "Leicester",
    regionName: "England",
    regionCode: "Eng",
    countryName: "United Kingdom",
    countryCode: "GB",
    latitude: 54.8794,
    longitude: -6.7389,
    mobile: false,
    internetProvider: "Virgin Media",
    proxy: "false",
    query: "81.45.980.123",
    timezone: "Europe/London",
    zip: "LE1",
}

example successful response for multiple ip addresses

Bulk request will not give you details about if they are on mobile or if they are on an proxy.

[
    {
        city: "Research",
        regionName: "Victoria",
        regionCode: "VIC",
        countryName: "Australia",
        countryCode: "AU",
        latitude: -37.7,
        longitude: 145.1833,
        internetProvider: "APNIC and Cloudflare DNS Resolver project",
        query: "1.1.1.1",
        timezone: "Australia/Melbourne",
        zip: "3095"
    },
    {
        city: "Mountain View",
        regionName: "California",
        regionCode: "CA",
        countryName: "United States",
        countryCode: "US",
        latitude: 37.4229,
        longitude: -122.085,
        internetProvider: "Google",
        query: "8.8.8.8",
        timezone: "America/Los_Angeles",
        zip: ""
    }
]

response table content

| Name | Description | Type | | ---------------- | ------------------------------ | ---------- | | countryName | the country name | string | | countryCode | the country code | string | | regionName | the region name | string | | regionCode | the region code | string | | city | the city name | string | | zip | the zip address | string | | latitude | the latitude | float | | longitude | the longitude | float | | internetProvider | Organization name | string | | regionName | the region name | string | | proxy | proxy (anoymous) | bool | | mobile | mobile (cellular) connection | bool | | query | ip used for the query | string |

initialise the ip details module

The node-ip-details package uses classes which contain a contructor which is dependate on a config supplied (see below for details on the config). This then allows the developer to initialise the class and then use it throughout without having to supply the same details constantly. If you want to use it for another ip or ips you need to reinitialise the class.

single ip address

// import that library
const ipdetails = require("node-ip-details");
// initilise the class with the config details
const ipInitialised = ipdetails.initialise({ip: "1.1.1.1"});

multiple ip addresses, you can request a maximum of 100 in each request

// import that library
const ipdetails = require("node-ip-details");
// initilise the class with the config details
const ipInitialised = ipdetails.initialise({ips: ["1.1.1.1", "8.8.8.8"]});

once initialised you can use all the functions which are explained below.

config

{
    ip: "this is the ip address you want to get the details about. It does not need to be supplied if `ips` is used.",
    ips "this is an array of ips you want to get the details about. It does not need to be supplied if `ip` is used."
}

get the latitude and longitude of the ip address(es)

native promises

ipInitialised.getLatitudeAndLongitude()
            .then(r => console.log(r))

async and await

async () => {
     try {
        const results = await ipInitialised.getLatitudeAndLongitude();
        console.dir(results);
     } catch (err) {
         // ... error checks
     }
}

example successful response for single ip

{
    latitude: 58.6333,
    longitude: -1.9333,
}

example successful response for multiple ips

[
  {
    latitude: -37.7,
    longitude: 145.1833,
    query: "1.1.1.1",
  },
  {
    latitude: 37.4229,
    longitude: -122.085,
    query: "8.8.8.8",
  }
]

get the timezone of the ip address(es)

native promises

ipInitialised.getTimezone()
            .then(r => console.dir(r))
            .catch(err => console.error(err));

async and await

async () => {
     try {
        const results = await ipInitialised.getTimezone();
        console.dir(results);
     } catch (err) {
         // ... error checks
     }
}

example successful response for single ip

"Europe/London"

example successful response for multiple ips

[
  {
    timezone: "Australia/Melbourne",
    query: "1.1.1.1",
  },
  {
    timezone: "America/Los_Angeles",
    query: "8.8.8.8",
  }
]

get the internet provider of the ip address(es)

native promises

ipInitialised.getInternetProvider()
            .then(r => console.dir(r))
            .catch(err => console.error(err));

async and await

async () => {
     try {
        const results = await ipInitialised.getInternetProvider();
        console.dir(results);
     } catch (err) {
         // ... error checks
     }
}

example successful response for single ip

"Virgin Media"

example successful response for multiple ips

[
  {
    provider: "APNIC and Cloudflare DNS Resolver project",
    query: "1.1.1.1",
  },
  {
    provider: "Google",
    query: "8.8.8.8",
  }
]

see if the ip address is on an proxy (not supported for ips)

native promises

ipInitialised.isOnProxy()
            .then(r => console.dir(r))
            .catch(err => console.error(err));

async and await

async () => {
     try {
        const results = await ipInitialised.isOnProxy();
        console.dir(results);
     } catch (err) {
         // ... error checks
     }
}

example successful response for single ip

true

example successful response for multiple ips

Not supported for multiple ips request

see if the ip address is on a mobile (not supported for ips)

native promises

ipInitialised.isOnMobile()
            .then(r => console.dir(r))
            .catch(err => console.error(err));

async and await

async () => {
     try {
        const results = await ipInitialised.isOnMobile();
        console.dir(results);
     } catch (err) {
         // ... error checks
     }
}

example successful response for single ip

true

example successful response for multiple ips

Not supported for multiple ips request

get the address of the ip address

native promises

ipInitialised.getAddress()
            .then(r => console.dir(r))
            .catch(err => console.error(err));

async and await

async () => {
     try {
        const results = await ipInitialised.getAddress();
        console.dir(results);
     } catch (err) {
         // ... error checks
     }
}

example successful response for single ip

{
    city: "Leicester",
    zip: "LE1",
    regionName: "England",
    regionCode: "ENG",
    countryName: "United Kingdom",
    countryCode: "GB",
}

example successful response for multiple ips

[
  {
    city: "Research",
    zip: "3095"
    regionName: "Victoria",
    regionCode: "VIC",
    countryName: "Australia",
    countryCode: "AU",
    query: "1.1.1.1",
  },
  {
    city: "Mountain View",
    zip: "",
    regionName: "California",
    regionCode: "CA",
    countryName: "United States",
    countryCode: "US",
    query: "8.8.8.8",
  }
]

provider

To get all the information for the ip address this packages uses a free provider called "ip-api". They allow the use of there packages for non-commercial use. Look at there usage limits below to see the criteria of using this package:

usage limits

ip-api system will automatically ban any IP addresses doing over 150 requests per minute. To unban your IP click here.

You are free to use ip-api.com for non-commercial use. They do not allow commercial use without prior approval.

For commercial, unlimited use see there pro service (this is very cheap and you can get unlimited API calls for 13$ a month).

it is down to the user of the package to use this within the terms of the above.

disclaimer

ip addresses can be faked with VPN and proxies, the package will give you the most update to date information it has on the ip address which is provided but this ip could of been vpn to fake location etc.

ip addresses can be made private so any private ips will not return any data about them.