ipspot 0.8
IPSpot: Retrieve IPv4/IPv6 Addresses with Geolocation Data
License: MIT
Requires Python: >=3.7
Keywords: ip ipv4 ipv6 geo geolocation network location ipspot cli


<div align="center">
<img src="https://github.com/openscilab/ipspot/raw/main/otherfiles/logo.png" width="350">
<h1>IPSpot: Retrieve IPv4/IPv6 Addresses with Geolocation Data</h1>
<br/>
<a href="https://codecov.io/gh/openscilab/ipspot"><img src="https://codecov.io/gh/openscilab/ipspot/graph/badge.svg?token=XCFKASULS8"></a>
<a href="https://badge.fury.io/py/ipspot"><img src="https://badge.fury.io/py/ipspot.svg" alt="PyPI version"></a>
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/built%20with-Python3-green.svg" alt="built with Python3"></a>
<a href="https://github.com/openscilab/ipspot"><img alt="GitHub repo size" src="https://img.shields.io/github/repo-size/openscilab/ipspot"></a>
<a href="https://discord.gg/yyDV3T4cwU"><img src="https://img.shields.io/discord/1064533716615049236.svg" alt="Discord Channel"></a>
</div>			
				
## Overview	

<p align="justify">					
<b>IPSpot</b> is a Python library for retrieving the current system's IP data and detailed location information such as region, longitude, and latitude. It supports both public and private <b>IPv4</b> and <b>IPv6</b> detection through multiple API providers, using a fallback mechanism for improved reliability. It has a simple and modular design, making it easy to perform fast IP, geolocation, provider, and regional lookups directly from your machine.
</p>

<table>
	<tr>
		<td align="center">PyPI Counter</td>
		<td align="center"><a href="http://pepy.tech/project/ipspot"><img src="http://pepy.tech/badge/ipspot"></a></td>
	</tr>
	<tr>
		<td align="center">Github Stars</td>
		<td align="center"><a href="https://github.com/openscilab/ipspot"><img src="https://img.shields.io/github/stars/openscilab/ipspot.svg?style=social&label=Stars"></a></td>
	</tr>
</table>



<table>
	<tr> 
		<td align="center">Branch</td>
		<td align="center">main</td>	
		<td align="center">dev</td>	
	</tr>
	<tr>
		<td align="center">CI</td>
		<td align="center"><img src="https://github.com/openscilab/ipspot/actions/workflows/test.yml/badge.svg?branch=main"></td>
		<td align="center"><img src="https://github.com/openscilab/ipspot/actions/workflows/test.yml/badge.svg?branch=dev"></td>
	</tr>
</table>

<table>
	<tr> 
		<td align="center">Code Quality</td>
		<td align="center"><a href="https://app.codacy.com/gh/openscilab/ipspot/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade"><img src="https://app.codacy.com/project/badge/Grade/cb2ab6584eb443b8a33da4d4252480bc"/></a></td>
		<td align="center"><a href="https://www.codefactor.io/repository/github/openscilab/ipspot"><img src="https://www.codefactor.io/repository/github/openscilab/ipspot/badge" alt="CodeFactor"></a></td>
	</tr>
</table>


## Installation		

### Source Code
- Download [Version 0.8](https://github.com/openscilab/ipspot/archive/v0.8.zip) or [Latest Source](https://github.com/openscilab/ipspot/archive/dev.zip)
- `pip install .`				

### PyPI

- Check [Python Packaging User Guide](https://packaging.python.org/installing/)     
- `pip install ipspot==0.8`						


## Usage

### Library

#### Public IPv4

```pycon
>>> from ipspot import get_public_ipv4, IPv4API
>>> get_public_ipv4(api=IPv4API.IP_API_COM)
{'status': True, 'data': {'ip': 'xx.xx.xx.xx', 'api': 'ip-api.com'}}
>>> get_public_ipv4(api=IPv4API.IP_API_COM, geo=True, timeout=10)
{'data': {'country_code': 'GB', 'latitude': 50.9097, 'longitude': -1.4043, 'api': 'ip-api.com', 'country': 'United Kingdom', 'timezone': 'Europe/London', 'organization': '', 'region': 'England', 'ip': 'xx.xx.xx.xx', 'city': 'Southampton'}, 'status': True}
>>> get_public_ipv4(api=IPv4API.IP_API_COM, geo=True, timeout=10, max_retries=5, retry_delay=4, backoff_factor=1.2)
{'data': {'country_code': 'GB', 'latitude': 50.9097, 'longitude': -1.4043, 'api': 'ip-api.com', 'country': 'United Kingdom', 'timezone': 'Europe/London', 'organization': '', 'region': 'England', 'ip': 'xx.xx.xx.xx', 'city': 'Southampton'}, 'status': True}
```

#### Private IPv4

```pycon
>>> from ipspot import get_private_ipv4
>>> get_private_ipv4()
{'status': True, 'data': {'ip': '10.36.18.154'}}
```

#### Public IPv6

```pycon
>>> from ipspot import get_public_ipv6, IPv6API
>>> get_public_ipv6(api=IPv6API.IP_SB)
{'data': {'api': 'ip.sb', 'ip': 'xx:xx:xx:xx::xx'}, 'status': True}
>>> get_public_ipv6(api=IPv6API.IP_SB, geo=True, timeout=10)
{'data': {'latitude': 51.2993, 'region': None, 'city': None, 'country_code': 'DE', 'api': 'ip.sb', 'longitude': 9.491, 'country': 'Germany', 'organization': 'Hetzner Online', 'timezone': 'Europe/Berlin', 'ip': 'xx:xx:xx:xx::xx'}, 'status': True}
>>> get_public_ipv6(api=IPv6API.IP_SB, geo=True, timeout=10, max_retries=5, retry_delay=4, backoff_factor=1.2)
{'data': {'latitude': 51.2993, 'region': None, 'city': None, 'country_code': 'DE', 'api': 'ip.sb', 'longitude': 9.491, 'country': 'Germany', 'organization': 'Hetzner Online', 'timezone': 'Europe/Berlin', 'ip': 'xx:xx:xx:xx::xx'}, 'status': True}
```

#### Private IPv6

```pycon
>>> from ipspot import get_private_ipv6
>>> get_private_ipv6()
{'status': True, 'data': {'ip': 'fe80::e1bd:f78:b233:21c9'}}
```

### CLI

ℹ️ You can use `ipspot` or `python -m ipspot` to run this program

#### Version

```console
> ipspot --version

0.8
```

#### Info

```console
> ipspot --info

 ___  ____   ____                 _   
|_ _||  _ \ / ___|  _ __    ___  | |_ 
 | | | |_) |\___ \ | '_ \  / _ \ | __|
 | | |  __/  ___) || |_) || (_) || |_ 
|___||_|    |____/ | .__/  \___/  \__|
                   |_|                

__     __     ___       ___  
\ \   / / _  / _ \     ( _ ) 
 \ \ / / (_)| | | |    / _ \ 
  \ V /   _ | |_| | _ | (_) |
   \_/   (_) \___/ (_) \___/ 



IPSpot is a Python library for retrieving the current system's IP data and detailed location information such as region, longitude, and latitude.
It supports both public and private IPv4 and IPv6 detection through multiple API providers, using a fallback mechanism for improved reliability.
It has a simple and modular design, making it easy to perform fast IP, geolocation, provider, and regional lookups directly from your machine.

Repo : https://github.com/openscilab/ipspot

```

#### Basic

```console
> ipspot
Private IP:

  IPv4: 192.168.1.35

  IPv6: fe80::e1bd:f78:b233:21c9

Public IP and Location Info:

  IPv4:

    API: ipinfo.io
    City: Nuremberg
    Country: Germany
    Country Code: DE
    IP: xx.xx.xx.xx
    Latitude: 49.4527
    Longitude: 11.0783
    Organization: Hetzner Online GmbH
    Region: Bavaria
    Timezone: Europe/Berlin

  IPv6:

    API: ip.sb
    City: N/A
    Country: Germany
    Country Code: DE
    IP: xx:xx:xx:xx::xx
    Latitude: 51.2993
    Longitude: 9.491
    Organization: Hetzner Online
    Region: N/A
    Timezone: Europe/Berlin
```

#### IPv4 API

ℹ️ `ipv4-api` valid choices: [`auto-safe`, `auto`, `ip-api.com`, `ipinfo.io`, `ip.sb`, `ident.me`, `tnedi.me`, `ipapi.co`, `ipleak.net`, `my-ip.io`, `ifconfig.co`, `reallyfreegeoip.org`, `freeipapi.com`, `myip.la`, `ipquery.io`, `ipwho.is`, `wtfismyip.com`, `myip.wtf`, `db-ip.com`]

ℹ️ The default value: `auto-safe`

```console
> ipspot --ipv4-api="ipinfo.io"
Private IP:

  IPv4: 192.168.1.35

  IPv6: fe80::e1bd:f78:b233:21c9

Public IP and Location Info:

  IPv4:

    API: ipinfo.io
    City: Nuremberg
    Country: Germany
    Country Code: DE
    IP: xx.xx.xx.xx
    Latitude: 49.4527
    Longitude: 11.0783
    Organization: Hetzner Online GmbH
    Region: Bavaria
    Timezone: Europe/Berlin

  IPv6:

    API: ip.sb
    City: N/A
    Country: Germany
    Country Code: DE
    IP: xx:xx:xx:xx::xx
    Latitude: 51.2993
    Longitude: 9.491
    Organization: Hetzner Online
    Region: N/A
    Timezone: Europe/Berlin
```

#### IPv6 API

ℹ️ `ipv6-api` valid choices: [`auto-safe`, `auto`, `ip.sb`, `ident.me`, `tnedi.me`, `ipleak.net`, `my-ip.io`, `ifconfig.co`, `reallyfreegeoip.org`, `myip.la`, `freeipapi.com`, `wtfismyip.com`, `myip.wtf`]

ℹ️ The default value: `auto-safe`

```console
> ipspot --ipv6-api="ip.sb"
Private IP:

  IPv4: 192.168.1.35

  IPv6: fe80::e1bd:f78:b233:21c9

Public IP and Location Info:

  IPv4:

    API: ipinfo.io
    City: Nuremberg
    Country: Germany
    Country Code: DE
    IP: xx.xx.xx.xx
    Latitude: 49.4527
    Longitude: 11.0783
    Organization: Hetzner Online GmbH
    Region: Bavaria
    Timezone: Europe/Berlin

  IPv6:

    API: ip.sb
    City: N/A
    Country: Germany
    Country Code: DE
    IP: xx:xx:xx:xx::xx
    Latitude: 51.2993
    Longitude: 9.491
    Organization: Hetzner Online
    Region: N/A
    Timezone: Europe/Berlin
```

#### No Geolocation

```console
> ipspot --no-geo
Private IP:

  IPv4: 192.168.1.35

  IPv6: fe80::5c40:769f:22de:c196

Public IP:

  IPv4:

    API: tnedi.me
    IP: xx.xx.xx.xx

  IPv6:

    API: ip.sb
    IP: xx:xx:xx:xx::xx
```

## Issues & Bug Reports			

Just fill an issue and describe it. We'll check it ASAP!

- Please complete the issue template

You can also join our discord server

<a href="https://discord.gg/yyDV3T4cwU">
  <img src="https://img.shields.io/discord/1064533716615049236.svg?style=for-the-badge" alt="Discord Channel">
</a>

## Show Your Support
								
<h3>Star This Repo</h3>					

Give a ⭐️ if this project helped you!

<h3>Donate to Our Project</h3>	

If you do like our project and we hope that you do, can you please support us? Our project is not and is never going to be working for profit. We need the money just so we can continue doing what we do ;-)			

<a href="https://openscilab.com/#donation" target="_blank"><img src="https://github.com/openscilab/ipspot/raw/main/otherfiles/donation.png" height="90px" width="270px" alt="IPSpot Donation"></a>


# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.8] - 2026-02-05
### Added
- Support [wtfismyip.com](https://wtfismyip.com/json) IPv6 API
- Support [myip.wtf](https://myip.wtf/) IPv6 API
- Support [myip.wtf](https://myip.wtf/) IPv4 API
- Support [db-ip.com](https://api.db-ip.com/v2/free/self) IPv4 API
### Changed
- `README.md` updated
## [0.7] - 2025-12-09
### Added
- `--backoff-factor` argument
### Changed
- CLI messages updated
- `Python 3.14` added to `test.yml`
- Internal functions default values removed
- `README.md` updated
- Test system modified
- `ipspot_info` function renamed to `_print_ipspot_info`
- `display_ip_info` function renamed to `_print_report`
## [0.6] - 2025-11-18
### Added
- `ForceIPHTTPAdapter` class
- `_get_json_force_ip` function
- Support [ifconfig.co](https://ifconfig.co/json) IPv6 API
- Support [reallyfreegeoip.org](https://reallyfreegeoip.org/json/) IPv6 API
- Support [myip.la](https://api.myip.la/en?json) IPv6 API
- Support [freeipapi.com](https://freeipapi.com/api/json) IPv6 API
### Changed
- [freeipapi.com](https://freeipapi.com/api/json) IPv4 API bug fixed
- `README.md` updated
### Removed
- `IPv4HTTPAdapter` class
- `_get_json_ipv4_forced` function
## [0.5] - 2025-10-17
### Added
- `setup-warp` action
- Support [ipwho.is](https://ipwho.is/)
- Support [ipquery.io](http://api.ipquery.io/?format=json)
- Support [wtfismyip.com](https://wtfismyip.com/json)
- Support [ident.me](https://ident.me/json) IPv6 API
- Support [tnedi.me](https://tnedi.me/json) IPv6 API
- Support [ip.sb](https://api.ip.sb/geoip) IPv6 API
- Support [ipleak.net](https://ipleak.net/json/) IPv6 API
- Support [my-ip.io](https://www.my-ip.io/) IPv6 API
- `is_ipv6` function
- `get_private_ipv6` function
- `get_public_ipv6` function
- `IPv6API` enum
- `--ipv6-api` argument
### Changed
- Test system modified
- `README.md` updated
## [0.4] - 2025-06-09
### Added
- Support [ipapi.co](https://ipapi.co/json/)
- Support [ipleak.net](https://ipleak.net/json/)
- Support [my-ip.io](https://www.my-ip.io/)
- Support [ifconfig.co](https://ifconfig.co/json)
- Support [reallyfreegeoip.org](https://reallyfreegeoip.org/json/)
- Support [myip.la](https://api.myip.la/en?json)
- Support [freeipapi.com](https://freeipapi.com/api/json/)
- `AUTO_SAFE` mode
- `_get_json_standard` function
- `_get_json_ipv4_forced` function
- `--max-retries` argument
- `--retry-delay` argument
### Changed
- `IPv4API.IPAPI` renamed to `IPv4API.IP_API_COM`
- `IPv4API.IPINFO` renamed to `IPv4API.IPINFO_IO`
- `IPv4API.IPSB` renamed to `IPv4API.IP_SB`
- `IPv4API.IDENTME` renamed to `IPv4API.IDENT_ME`
- `IPv4API.TNEDIME` renamed to `IPv4API.TNEDI_ME`
- `get_public_ipv4` function modified
- `filter_parameter` function renamed to `_filter_parameter`
- `README.md` updated
## [0.3] - 2025-05-19
### Added
- `is_ipv4` function
- `is_loopback` function
- `IPv4HTTPAdapter` class
- Support [ident.me](https://ident.me/json)
- Support [tnedi.me](https://tnedi.me/json)
### Changed
- `get_private_ipv4` function modified
- `get_public_ipv4` function modified
- `_ipsb_ipv4` function modified
- `_ipapi_ipv4` function modified
- `_ipinfo_ipv4` function modified
- `functions.py` renamed to `utils.py` 
- CLI functions moved to `cli.py`
- IPv4 functions moved to `ipv4.py`
- Test system modified
## [0.2] - 2025-05-04
### Added
- Support [ip.sb](https://api.ip.sb/geoip)
- `--timeout` argument
### Changed
- `README.md` updated
- Requests header updated
- Test system modified
## [0.1] - 2025-04-25
### Added
- Support [ipinfo.io](https://ipinfo.io)
- Support [ip-api.com](https://ip-api.com)
- `get_private_ipv4` function
- `get_public_ipv4` function
- `--info` and `--version` arguments
- `--ipv4-api` argument
- `--no-geo` argument
- Logo

[Unreleased]: https://github.com/openscilab/ipspot/compare/v0.8...dev
[0.8]: https://github.com/openscilab/ipspot/compare/v0.7...v0.8
[0.7]: https://github.com/openscilab/ipspot/compare/v0.6...v0.7
[0.6]: https://github.com/openscilab/ipspot/compare/v0.5...v0.6
[0.5]: https://github.com/openscilab/ipspot/compare/v0.4...v0.5
[0.4]: https://github.com/openscilab/ipspot/compare/v0.3...v0.4
[0.3]: https://github.com/openscilab/ipspot/compare/v0.2...v0.3
[0.2]: https://github.com/openscilab/ipspot/compare/v0.1...v0.2
[0.1]: https://github.com/openscilab/ipspot/compare/3216fb7...v0.1