ip-address-retriever
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

ip-address-retriever

A TypeScript utility for retrieving the public IPv4 and IPv6 addresses using the ipify API.

Installation

Use the package manager npm or yarn to install ip-address-retriever.

npm install ip-address-retriever
yarn add ip-address-retriever

Usage

import { IP } from 'ip-address-retriever';

// Retrieve IPv4 and IPv6 addresses
async function fetchIP(): Promise<void> {
    try {
        const ipv4: string = await IP.getIpv4();
        const ipv6: string = await IP.getIpv6();
        console.log('IPv4:', ipv4);
        console.log('IPv6:', ipv6);
    } catch (error) {
        console.error('Error:', error);
    }
}

fetchIP();

API

IP.getIpv4(): Promise

Returns a promise that resolves to the public IPv4 address of the client.

IP.getIpv6(): Promise

Returns a promise that resolves to the public IPv6 address of the client.

Credit

This package utilizes the ipify API for retrieving IP addresses

Package Sidebar

Install

npm i ip-address-retriever

Weekly Downloads

4

Version

1.0.1

License

MIT

Unpacked Size

7.29 kB

Total Files

4

Last publish

Collaborators

  • sammali