Skip to main content

Fetch your public IP address from external sources with Python.

Project description


Fetch your public IP address from external sources with Python.

Install with pip install whatismyip


>>> import whatismyip
>>> whatismyip.amionline()
>>> whatismyip.whatismyip()
>>> whatismyip.whatismyipv4()
>>> whatismyip.whatismyipv6()
>>> whatismyip.whatismylocalip()  # Returns local IPs of all network cards.
('', '', '', '')
>>> whatismyip.whatismyhostname()

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 2021.8.5 for the version released on August 5, 2021.

How Does whatismyip Work?

There are several public STUN (Session Traversal Utilities for NAT) servers that return your IP address (as it appears to them). There are also several public websites that you can view in your browser:

The whatismyip module does not have any dependencies outside the Python standard library. It does not require Requests to be installed.


If you find this project helpful and would like to support its development, consider donating to its creator on Patreon.

Download files

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

Source Distribution

WhatIsMyIP-2022.7.10.tar.gz (7.7 kB view hashes)

Uploaded source

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