Skip to main content

Public IP address checker.

Project description

Discovers your public IP address using pre-defined checkers (external services).


  • Python 2.7, 3.4, 3.5, PyPy


Install with latest stable version from PyPI:

pip install pif

or install the latest stable version from source:

pip install

or install into python path:

python install

That’s all. See the Usage and examples section for more.

Usage and examples

Basic usage

Get public IP:

from pif import get_public_ip

Get public IP using preferred checker:


List available checkers:

from pif.utils import list_checkers

Registering a custom IP checker

pif ships with a number of pre-defined public IP checkers. But you may extend it by defining your own ones as follows.

from pif.base import BaseIPChecker, registry

class MyPublicIPChecker(BaseIPChecker):

    uid = 'mypublicipchecker' # UID of the checker

    def get_public_ip(self):
        # TODO: Implement your logic

# Register the checker

# Get public IP using the preferred checker

Command line usage

It’s possible to get your public IP address from command line using the pif.commands.get_public_ip module.

optional arguments:
  -h, --help            show this help message and exit
                        `preferred_checker` value
  -v VERBOSE, --verbose VERBOSE
                    `verbose` value
Example:(with preferred checked and verbose output)
get-public-ip -c -v 1


Simply type:


or use tox:


or use tox to check specific env:

tox -e py35


GPL 2.0/LGPL 2.1


For any issues contact me at the e-mail given in the Author section.


Artur Barseghyan <>

Project details

Download files

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

Files for pif, version 0.8.2
Filename, size File type Python version Upload date Hashes
Filename, size pif-0.8.2-py2.py3-none-any.whl (19.8 kB) File type Wheel Python version any Upload date Hashes View
Filename, size pif-0.8.2.tar.gz (21.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page