UNPKG

@lavanjan/ip-info

Version:

A simple utility to get IP address, device, and location details

70 lines (44 loc) 1.29 kB
# @lavanjan/ip-info A simple package to fetch IP address, device, and location details. ## Installation ```sh npm install @lavanjan/ip-info ``` ## Usage ```ts import IPInfo from "@lavanjan/ip-info"; IPInfo.getInfo().then((info) => console.log(info)); ``` ## Features - Fetches public IP address - Detects browser, OS, and device type - Retrieves location details based on IP ## API Methods ### `IPInfo.getPublicIP()` Fetches the public IP address of the user. ```ts IPInfo.getPublicIP().then((ip) => console.log("Public IP:", ip)); ``` ### `IPInfo.getDeviceDetails()` Retrieves device information such as OS and browser. ```ts const device = IPInfo.getDeviceDetails(); console.log("Device Info:", device); ``` ### `IPInfo.getLocationDetails(ip: string)` Fetches location details based on the given IP address. ```ts IPInfo.getLocationDetails("8.8.8.8").then((location) => console.log("Location Info:", location) ); ``` ### `IPInfo.getInfo()` Retrieves all details: IP address, device info, and location data. ```ts IPInfo.getInfo().then((info) => console.log("Full Info:", info)); ``` ## License MIT --- **Author:** Lavanjan **Email:** [ravilavanjan23@gmail.com](mailto:ravilavanjan23@gmail.com)