Skip to main content

Testing Build Publish

What is this?

License: MIT

Simple python module for getting your public IP V4 and V6 from several providers in random mode with also several protocols (DNS, HTTPS and STUN).

Supported providers

IP Checker HTTPS STUN DNS IPv4 IPv6 Use Policy
google ❌ ✔️ ✔️ ✔️ ✔️
cloudflare ✔️ ❌ ✔️ ✔️ ✔️
openDNS ❌ ❌ ✔️ ✔️ ✔️
akamai ✔️ ❌ ✔️ ✔️ ✔️
ipify ✔️ ❌ ❌ ✔️ ✔️
icanhazip ✔️ ❌ ❌ ✔️ ✔️
matrix ❌ ✔️ ❌ ✔️ ✔️
framasoft ❌ ✔️ ❌ ✔️ ✔️
ifconfig.me ✔️ ❌ ❌ ✔️ ✔️

Installation

python 3.13.x python 3.12.x python 3.11.x python 3.10.x

This module can be installed from pypi website

pip install publicaddr

Lookup for IPv4 and IPv6

Lookup for your public IPs from random providers with DNS or HTTP protocols with 3 retries if no ips are returned. This is the default behaviour of the lookup function.

import publicaddr

publicaddr.lookup()
{'ip4': 'x.x.x.x', 'ip6': 'x:x:x:x:x:x:x:x', 'provider': 'opendns',
'proto': 'dns', 'duration': '0.037'}

Configuration

This module can be configurated with environment variables

Variables Description
PUBLICADDR_DEBUG debug mode 1 or 0
PUBLICADDR_TIMEOUT timeout, default is 2s
PUBLICADDR_RETRIES retries, default is 3
PUBLICADDR_IPV6_ENABLED enable ipv6 with 1 or 0 to disable
PUBLICADDR_LOOKUP_HTTPS lookup with HTTPS protocol (1 or 0 to disable)
PUBLICADDR_LOOKUP_DNS lookup with DNS protocol (1 or 0 to disable)
PUBLICADDR_LOOKUP_STUN lookup with STUN protocol (1 or 0 to disable)

Specific lookups

Lookup for public IP with specific protocol

Lookup for your public IPs from random DNS providers with specific protocol.

import publicaddr

publicaddr.lookup(providers=publicaddr.DNS, retries=2)
{'ip4': 'x.x.x.x', 'ip6': 'x:x:x:x:x:x:x:x', 'provider': 'opendns',
'proto': 'dns', 'duration': '0.037'}

Default constants for transport protocol:

  • publicaddr.HTTPS
  • publicaddr.DNS
  • publicaddr.STUN

Get IPv4 or IPv6 only

Get your public IPv4 with default provider (Google with DNS protocol).

import publicaddr

publicaddr.get(ip=publicaddr.IPv4)
{'ip': 'x.x.x.x', 'duration': '0.025'}

Default constants for IP version:

  • publicaddr.IPv4
  • publicaddr.IPv6

Get IP with specific provider

Example to use the provider Cloudflare instead of the default one.

import publicaddr

myip = publicaddr.get(provider=publicaddr.CLOUDFLARE, proto=publicaddr.DNS)
{'ip': 'x:x:x:x:x:x:x:x', 'duration': '0.020'}

Default constants for providers:

  • publicaddr.CLOUDFLARE
  • publicaddr.GOOGLE
  • publicaddr.OPENDNS
  • publicaddr.AKAMAI
  • publicaddr.IPIFY
  • publicaddr.ICANHAZIP
  • publicaddr.MATRIX
  • publicaddr.FRAMASOFT
  • publicaddr.IFCONFIG_ME

For developpers

Run from source

sudo apt install python3-venv
python3 -m venv venv
source venv/bin/activate
python3 -m pip install -r requirements.txt
python3 example.py

Custom configuration

See the default configuration file

Run test units

python3 -m unittest discover tests/

Metadata

Release files for publicaddr 1.0.0

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

Source distribution (sdist)

Source distribution for publicaddr 1.0.0
File Size Uploaded
publicaddr-1.0.0.tar.gz 10.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for publicaddr 1.0.0
File Interpreter ABI Platform
publicaddr-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 27.3 kB

Release files / publicaddr-1.0.0.tar.gz

Download URL publicaddr-1.0.0.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
49ca254d952aaf66ab042f601a5ae525a5c0597f07f18fab664d88e8d86113b5
BLAKE2b-256 checksum
How to use checksums
80e5c9e74198a8a840e2db1aeba6435a88b559c3a727b90fc37f16810bb8c76b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.

Transparency log

Release files / publicaddr-1.0.0-py3-none-any.whl

Download URL publicaddr-1.0.0-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7558a07247419b5f0449e7247dda238d80a931ea5c6a1e203c1550fb2fda52c8
BLAKE2b-256 checksum
How to use checksums
116db5e29e181be310de68796dfd396dda6f5d2f798640cff4924713b4502a24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.19.0

2 release files

0.18.0

2 release files

0.17.0

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.14.2

2 release files

0.14.1

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.12.1

2 release files

0.12.0

2 release files

0.11.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

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