Skip to main content
https://img.shields.io/pypi/v/ipgetter2.svg

Utility to fetch your external IP address.

This module is designed to fetch your external IP address from the internet.

It is used mostly when behind a NAT.

It picks your IP randomly from a server list to minimize request overhead on a single server

NOTICE: This library is try to act as a replacement of the ipgetter library, because that library has disappeared on pypi.org and github.

  • License: Apache-2.0

Why there another ipgetter library?

I found ipgetter disappeared at night of 2019-05-11. I don’t know precisely when it’s disappeared, and don’t know what’s going on.

So I write this library with same API interface for my projects that depends on it as a replacement, hope it will help people that ran into the same situation.

Features

  • Correctly detect webpage encoding by chardet

  • Control the timeout by library requests not by signal alarm (Alarm signal will cause problems)

  • Smart server fetch algorithm, the get() method will fetch at least 2 IP with the same value in 3 random servers (return the only one valid IP without checking if there have only one server responsed)

  • Support IPv6 either (Return both values if the server provided two of them)

Usage

  • ipgetter2 usage

>>> from ipgetter2 import IPGetter
>>> getter = IPGetter()
>>> getter.get()
{v4:"8.8.8.8", v6:"::"}
>>> getter.get_from("http://checkip.dyndns.org/plain")
{v4:"8.8.8.8", v6:"::"}
>>> getter.test()
Numbers of Servers : 46
[1/46] Testing : http://ip.dnsexit.com
[2/46] Testing : http://ifconfig.me/ip
[3/46] Testing : http://ipecho.net/plain
......
[45/46] Testing : http://httpbin.org/ip
[46/46] Testing : https://api.myip.com
8 server failed : ['http://checkip.dyndns.org/plain', 'http://www.canyouseeme.org/', 'http://whatsmyip.net/', 'http://www.ip-adress.com/', 'http://ip-lookup.net/', 'https://check.torproject.org/', 'https://www.privateinternetaccess.com/pages/whats-my-ip/', 'http://myexternalip.com/']
{IPAddress(v4="117.117.117.117", v6="::"): 26, IPAddress(v4="0.0.0.0", v6="::"): 11, IPAddress(v4="117.117.117.116", v6="::"): 1}
IP's : {v4:"117.117.117.117", v6:"::"} = 26 ocurrencies
  • Emulated API interface of ipgetter library

>>> from ipgetter2 import ipgetter1 as ipgetter
>>> myip = ipgetter.myip()
>>> myip
'8.8.8.8'
>>> ipgetter.IPgetter().test()
Number of servers: 47
IP's :
8.8.8.8 = 47 ocurrencies

Credits

This package was created with Cookiecutter and the PyPackageTemplate project template.

History

1.1.12 (2025-10-01)

  • Removed some broken urls

  • Fixed dns query failed might wait for a long time for continue

1.1.10 (2020-01-26)

  • Fixed AttributeError: ‘NoneType’ object has no attribute ‘upper’ when server reponse an empty result

1.1.9 (2019-08-26)

  • Fixed not working on python 3.5.x

  • Fixed tests failed on windows

1.1.7 (2019-05-25)

  • Added more servers, mostly from China

1.1.5 (2019-05-25)

  • Speed up get() by threading.Thread, send request simultaneously

1.1.1 (2019-05-22)

  • First release on PyPI.

Release files for ipgetter2 1.1.13

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

Source distribution (sdist)

Source distribution for ipgetter2 1.1.13
File Size Uploaded
ipgetter2-1.1.13.tar.gz 16.4 kB Details

Release files / ipgetter2-1.1.13.tar.gz

Download URL ipgetter2-1.1.13.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2e3d7ea38ae0809e83ec386fa89cb5e464417df10484c86eebd460feb67a84a5
BLAKE2b-256 checksum
How to use checksums
370c59c3a9f4ba5007970bd878f3b23a45aabca98c9ec0d7364ce407e846b9b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

1.1.13 This release

1 release file

1.1.10

1 release file

1.1.9

1 release file

1.1.8

1 release file

1.1.7

1 release file

1.1.6

1 release file

1.1.4

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

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