Skip to main content

A Python function to get your public IP address.

Project description

A Python function to get your public IP address.

Installation

pip install public-ip

Usage example

import public_ip as ip

ip.get()

Sample output:

212.51.139.31

How it works

The function queries in parallel six different websites...

  1. https://api.ipify.org
  2. https://checkip.amazonaws.com
  3. https://icanhazip.com
  4. https://ifconfig.co/ip
  5. https://ipecho.net/plain
  6. https://ipinfo.io/ip

... and returns the most common IP among the responses. In this manner (a) we don't depend on a single external service and (b) we can determine the IP correctly as long as a majority of these sites return the right value.

Test workflow PyPI badge Black badge

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

public-ip-0.12.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

public_ip-0.12-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page