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...
- https://api.ipify.org
- https://checkip.amazonaws.com
- https://icanhazip.com
- https://ifconfig.co/ip
- https://ipecho.net/plain
- 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.
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)
| File | Size | Uploaded | |
|---|---|---|---|
| public-ip-0.12.tar.gz | 3.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|