A fast and reliable Node.js/browser library to retrieve your public IPv4 or IPv6 address.
public-ip is a JavaScript library that retrieves your public IP address from various external services. It solves the problem of programmatically determining a device's public IP in Node.js or browser environments, handling both IPv4 and IPv6 addresses with fallback mechanisms for reliability.
Developers building applications that need to detect or log public IP addresses, such as network tools, analytics platforms, or services requiring IP-based geolocation or security checks.
Developers choose public-ip for its speed, multi-source redundancy, and simple API. It's maintained by sindresorhus, ensuring quality and reliability, and includes features like HTTPS-only mode for security and custom fallback endpoints.
Get your public IP address - very fast!
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Queries DNS records from OpenDNS and Google DNS, plus HTTPS services like icanhazip and ipify, ensuring the IP is fetched even if some sources fail.
Provides separate methods for IPv4 (publicIpv4) and IPv6 (publicIpv6), and a unified method that tries IPv6 first, handling both versions seamlessly.
Offers an onlyHttps option for tamper-proof checks, though it's slower, as noted in the README, enhancing security in Node.js environments.
Allows adding custom HTTPS URLs via fallbackUrls, providing flexibility if default services are unavailable, as shown in the usage examples.
The onlyHttps security option is not available in browser environments, limiting secure checks to Node.js only, as stated in the README.
Enabling onlyHttps mode significantly increases retrieval time due to HTTPS overhead, making it unsuitable for latency-sensitive applications.
Relies on third-party services that could change or become unavailable, requiring manual intervention or fallback configuration for continued reliability.