2.0.0 • Published 5 months ago

gip v2.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 months ago

🐷 GIP (Get IP)

GIP is a Node.js dependency-free tool for getting your Public IPv4 address using "IP echo" services. It will fetch data from multiple services at the same time to give you results as fast as possible.

Requirements

NodeJS version 18.0.0 or higher, becuse of Fetch API.

Installation

Using NPM

npm i gip

Using PNPM

pnpm add gip

Usage

import gip from 'gip'

(async () => {
    try {
        const ip = await gip()
        console.log(ip)
    } catch (error) {
        console.log(`Can't get your IP. Reason: ${error}`)
    }
})()

Usage with custom services:

import gip from 'gip'

const my_services = ['https://ipv4.icanhazip.com/', 'ifconfig.me/ip']

(async () => {
    try {
        const ip = await gip(my_services)
        console.log(ip)
    } catch (error) {
        console.log(`Can't get your IP. Reason: ${error}`)
    }
})()

CLI installation

Using NPM

npm i -g gip

Using PNPM

pnpm add -g gip

CLI usage

gip
# 133.74.20.69

Usage with custom services:

gip "https://ipv4.icanhazip.com/" "https://ifconfig.me/ip"
# 133.74.20.69

gip ipv4.icanhazip.com ifconfig.me/ip
# 133.74.20.69

Additional info

  • Passing your own services will not prioritize them. You will get answer from the fastest service anyway. List of services is located in file services.json

  • If you pass service without specified protocol - GIP will treat it as HTTPS

2.0.0

5 months ago

1.0.8

10 months ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

0.1.0

6 years ago

0.0.1

9 years ago