Skip to main content

IPSpot: A Python Tool to Fetch the System's IP Address

Project description

IPSpot: A Python Tool to Fetch the System's IP Address


PyPI version built with Python3 GitHub repo size Discord Channel

Overview

IPSpot is a Python library for retrieving the current system's IP address and location information. It currently supports public and private IPv4 detection using multiple API providers with a fallback mechanism for reliability. Designed with simplicity and modularity in mind, IPSpot offers quick IP and geolocation lookups directly from your machine.

PyPI Counter
Github Stars
Branch main dev
CI
Code Quality CodeFactor

Installation

Source Code

PyPI

Usage

Library

Public IPv4

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

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

Public IPv6

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

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

> ipspot --version

0.7

Info

> ipspot --info

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

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



IPSpot is a Python library for retrieving the current system's IP address and location information.
It currently supports public and private IPv4 detection using multiple API providers with a fallback mechanism for reliability.
Designed with simplicity and modularity in mind, IPSpot offers quick IP and geolocation lookups directly from your machine.

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

Basic

> 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]

ℹ️ The default value: auto-safe

> 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]

ℹ️ The default value: auto-safe

> 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

> 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

Discord Channel

Show Your Support

Star This Repo

Give a ⭐️ if this project helped you!

Donate to Our Project

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

IPSpot Donation

Changelog

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

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

Unreleased

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

Changed

Removed

  • IPv4HTTPAdapter class
  • _get_json_ipv4_forced function

0.5 - 2025-10-17

Added

Changed

  • Test system modified
  • README.md updated

0.4 - 2025-06-09

Added

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
  • Support tnedi.me

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
  • --timeout argument

Changed

  • README.md updated
  • Requests header updated
  • Test system modified

0.1 - 2025-04-25

Added

  • Support ipinfo.io
  • Support ip-api.com
  • get_private_ipv4 function
  • get_public_ipv4 function
  • --info and --version arguments
  • --ipv4-api argument
  • --no-geo argument
  • Logo

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

ipspot-0.7.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ipspot-0.7-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file ipspot-0.7.tar.gz.

File metadata

  • Download URL: ipspot-0.7.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for ipspot-0.7.tar.gz
Algorithm Hash digest
SHA256 661969a53a7018e4720204897ee680f4ccedb98aeb0fdfac277e4fa4d38a5e89
MD5 56d89e8dd6436dc9494c90025f793622
BLAKE2b-256 815547846b4c2b4ceb923227309cec78a846659158279540a3495b4efc37478c

See more details on using hashes here.

File details

Details for the file ipspot-0.7-py3-none-any.whl.

File metadata

  • Download URL: ipspot-0.7-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for ipspot-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 6576f99e254c9ef6d0d20364b16c643c59decaeaf2acf8bcb98e10db266b5258
MD5 480f3ea18e757565b095e0dc50d0f5e7
BLAKE2b-256 15e9a7f24fcc130c60d19e2c6fcd246d9ecb7587a035a63975193ad5cc1d421f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page