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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file public-ip-0.12.tar.gz.

File metadata

  • Download URL: public-ip-0.12.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for public-ip-0.12.tar.gz
Algorithm Hash digest
SHA256 e7930b430b9ddb7aa03db597a9ec649369687181024c831f9b350b108da02c11
MD5 3428a9db3b8b3c08884ce79ebcfe24f3
BLAKE2b-256 036a002a5a4ac6e37d2c3040c686ff8fa659316889f840087d2a369db0ff294e

See more details on using hashes here.

File details

Details for the file public_ip-0.12-py3-none-any.whl.

File metadata

  • Download URL: public_ip-0.12-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for public_ip-0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 7e5fb6d504b11a8fa06af3648a22cb2a4438f6fc1460392aab72c5eb6e835e10
MD5 77a5ffabc5b1f6232107df8e9060b41f
BLAKE2b-256 c3fb2c86b3f47c9465310057e3135cec4ccf36dc68ec656b2b63dcaee3a9fa49

See more details on using hashes here.

Supported by

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