Fetch your public IP address from external sources with Python.
Project description
whatismyip
Fetch your public IP address from external sources with Python.
Install with pip install whatismyip
Example:
>>> import whatismyip
>>> whatismyip.amionline()
True
>>> whatismyip.whatismyip()
'69.89.31.226'
>>> whatismyip.whatismyipv4()
'69.89.31.226'
>>> whatismyip.whatismyipv6()
'2345:0425:2CA1:0000:0000:0567:5673:23b5'
>>> whatismyip.whatismylocalip() # Returns local IPs of all network cards.
('192.168.189.1', '192.168.220.1', '192.168.56.1', '192.168.1.201')
>>> whatismyip.whatismyhostname()
'GIBSON'
On average these ip-finding functions take about half a second to run. Your results may vary.
Because whatismyip relies on online services, you always want to update to the latest version. This module uses calendar versioning, such as version 2024.2.20 for the version released on February 20, 2024.
How Does whatismyip Work?
There are several public STUN (Session Traversal Utilities for NAT) servers (listed in the whatismyip.STUN_SERVERS variable, in order of response speed) that return your IP address (as it appears to them). There are also several public websites that you can view in your browser (listed in whatismyip.IP4_WEBSITES, whatismyip.IP6_WEBSITES, and whatismyip.IP_WEBSITES):
- https://api.ipify.org
- https://checkip.amazonaws.com/
- https://icanhazip.com
- https://ipinfo.io/ip
- https://ipecho.net/plain
- https://ifconfig.me/ip
- https://v4.ident.me
- https://v6.ident.me
- https://v4.tnedi.me
- https://v6.tnedi.me
- https://tnedi.me/
- https://curlmyip.net
- https://wtfismyip.com/text
The whatismyip module does not have any dependencies outside the Python standard library. It does not require Requests to be installed.
Support
If you find this project helpful and would like to support its development, consider donating to its creator on Patreon.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file whatismyip-2026.5.22.tar.gz.
File metadata
- Download URL: whatismyip-2026.5.22.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e764fcc23afea4622f69992ac7015bed4e514773c7047ebd0afc1c421e79465
|
|
| MD5 |
262bc3c0c4b6c44b17bbe7acbc045866
|
|
| BLAKE2b-256 |
3280a2885b9235029b8b5cfbe9457f8d365cd48d0f0b33307fbc5eb484813cbf
|
File details
Details for the file whatismyip-2026.5.22-py3-none-any.whl.
File metadata
- Download URL: whatismyip-2026.5.22-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
955563cfe03264c8f2bc361f592123443bbec0a3c4d2f18ae37830f0dc50d126
|
|
| MD5 |
49833db65230107c9540503dcd2155eb
|
|
| BLAKE2b-256 |
93e0835571ca502ddb4a0c02d55d16fca999454a4686aee5c6f55adb55f788bd
|