1.5.1 • Published 10 months ago

ip_requester v1.5.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

IP Requester

It is a simple and minimalistic service that responds your current public IP address based only on external APIs, with no need for external dependencies or libraries, extremely lightweight and customizable.

How To Use

First, Install

  yarn add ip_requester

After that, import

  import { getPublicIp } from "ip_requester";

const publicIp = await getPublicIp();

It will answer a JSON object containing the following keys:\
`ip`            Contains de IP response resolve.\
`responseTime`  Contains the response time of the server that resolved the request.\
`service`       Contains the `url` value of te service that fullfilled the request.
>
```bash
  {
    ip: "123.456.789.1",    // a string with the ip address in IPv4 format.
    responseTime: 100,      // a positive int number representing milliseconds.
    service: "SERVICE_URL"  // a string with the url of the first responder service.
  }

The getPublicIp, getIpgeo, getIpify and getIpconfig functions accept the standard fetch options parameter, adding one more called timeout that is used to configure the maximum amount of time in milliseconds the client will wait. By default it's set at 1 seconds (1000ms).

  const publicIp = await getPublicIp({timeout: 1000});    // 1 second timeout.

You can also use individual services by importing them separately and passing options as needed for each one.

  import { getIpgeo, getIpify, getIpConfig} from "ip_requester";

cont ipgeoIp = await getIpgeo({timeout: 500}); // 500 miliseconds timeout. const ipifyIp = await getIpify({timeout: 1000}); // 1000 miliseconds timeout. const ipconfigIp = await getIpconfig({timeout: 200}); // 200 miliseconds timeout.

1.5.1

10 months ago

1.5.0

10 months ago

1.4.1

10 months ago

1.4.0

10 months ago

1.3.2

10 months ago

1.3.1

10 months ago

1.3.0

10 months ago

1.2.1

10 months ago

1.2.0

10 months ago

1.1.7

10 months ago

1.1.6

10 months ago

1.1.5

10 months ago

1.1.4

10 months ago

1.1.2

10 months ago

1.1.1

10 months ago

1.0.0

10 months ago