Skip to main content

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

Metadata

Release files for public-ip 0.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for public-ip 0.12
File Size Uploaded
public-ip-0.12.tar.gz 3.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for public-ip 0.12
File Interpreter ABI Platform
public_ip-0.12-py3-none-any.whl Python 3 none any Details

Total release size: 7.5 kB

Release files / public-ip-0.12.tar.gz

Download URL public-ip-0.12.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e7930b430b9ddb7aa03db597a9ec649369687181024c831f9b350b108da02c11
BLAKE2b-256 checksum
How to use checksums
036a002a5a4ac6e37d2c3040c686ff8fa659316889f840087d2a369db0ff294e
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / public_ip-0.12-py3-none-any.whl

Download URL public_ip-0.12-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e5fb6d504b11a8fa06af3648a22cb2a4438f6fc1460392aab72c5eb6e835e10
BLAKE2b-256 checksum
How to use checksums
c3fb2c86b3f47c9465310057e3135cec4ccf36dc68ec656b2b63dcaee3a9fa49
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.12 This release

2 release files

0.11

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page