Using the Node.js ip-info-finder Package.
Published: 2023-02-24 18:34:01


![ip-info-finder cover](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w381ts8scpwq4zaibfuv.png)


Have you ever wished to use a Node.js application to retrieve information about an IP address? Perhaps you want to search up a website's WHOIS information or learn more about the region or weather connected with an IP address. All of these tasks are made simple by the ip-info-finder software. This tutorial will teach you how to retrieve information about an IP address using the ip-info-finder package.

## Installation

Installing the [ip-info-finder](https://www.npmjs.com/package/ip-info-finder) package using npm is the first step:

```
npm install ip-info-finder
```

We may begin utilizing it in our Node.js application after it has been installed.

### Obtain IP Information

The getIPInfo function can be used to retrieve information about an IP address. Here's an illustration:

```
const ipInfo = require('ip-info-finder');

ipInfo.getIPInfo('8.8.8.8')
  .then((data) => {
    console.log(data);
  })
  .catch((err) => {
    console.error(err);
  });
```

This program will record information about the IP address 8.8.8.8 to the console after retrieving it. The IP address, nation, area, city, latitude, and longitude are among the pieces of information that are returned.

## Setting Options

The second argument to the getIPInfo function is an optional settings object. Some of the choices are as follows:

- language: The response's appropriate language code (default is en).
- Whether to include security-related information (default is true).
- hostname: Whether or not to include information about the hostname (default is true).
- Currency: Whether or not to include data linked to currencies (default is true).

### Location

To discover more details about the area from the IP address, such as the county, city, street, suburb, and postcode, we can use the location method:

```
const ipInfo = require('ip-info-finder');

ipInfo.getIPInfo.location('8.8.8.8')
  .then((data) => {
    console.log(data);
  })
  .catch((err) => {
    console.error(err);
  });

```
This code will fetch information about the location of the IP address 8.8.8.8.

### Weather

In addition to location information, we can also discover the climate associated with an IP address using the weather method:

```
const ipInfo = require('ip-info-finder');

ipInfo.getIPInfo.weather('8.8.8.8')
  .then((data) => {
    console.log(data);
  })
  .catch((err) => {
    console.error(err);
  });

```
This code will fetch information about the weather associated with the IP address **8.8.8.8**.


### IP Checker

We can also use the isIP, isIPv4, isIPv6, and
Let's go on to ip-info-WHOIS finder's functionality, which is the following feature. By entering an IP address or website address, you may quickly discover WHOIS information with this tool.

Here is an illustration of some code:

```
ipInfo.getIPInfo.whois('IP OR WEBSITE').then(data => {
    console.log(data);
})
.catch(err => console.log(err));

```

Overall, the ip-info-finder npm package is a helpful tool that offers a straightforward and user-friendly interface for retrieving IP information. Developers that need to work with IP addresses in their projects will find it to be a useful tool because to its many functions and possible settings.
[github repo](https://github.com/hamedpa/ip-info-finder)