Skip to main content

Utility to fetch your external IP address

Project description

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 and github.

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.


  • 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)


  • ipgetter2 usage
>>> from ipgetter2 import IPGetter
>>> getter = IPGetter()
>>> getter.get()
{v4:"", v6:"::"}
>>> getter.get_from("")
{v4:"", v6:"::"}
>>> getter.test()
Numbers of Servers : 46
[1/46] Testing :
[2/46] Testing :
[3/46] Testing :
[45/46] Testing :
[46/46] Testing :
8 server failed : ['', '', '', '', '', '', '', '']
{IPAddress(v4="", v6="::"): 26, IPAddress(v4="", v6="::"): 11, IPAddress(v4="", v6="::"): 1}
IP's : {v4:"", v6:"::"} = 26 ocurrencies
  • Emulated API interface of ipgetter library
>>> from ipgetter2 import ipgetter1 as ipgetter
>>> myip = ipgetter.myip()
>>> myip
>>> ipgetter.IPgetter().test()
Number of servers: 47
IP's : = 47 ocurrencies


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


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.

Project details

Download files

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

Source Distribution (22.8 kB view hashes)

Uploaded source

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 NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page