Skip to main content

A Python library to fetch public and private IP addresses.

Reason this release was yanked:

Bugs with module

Project description

IP Fetcher

License: MIT PyPI - Version PyPI - Downloads

ip_fetcher is a Python library for retrieving public and private IP addresses, checking IP types, detecting proxies or VPNs, and saving/retrieving IPs to/from files. It also provides a command-line interface (CLI) for ease of use.

Features

  • Fetches Public IP Address: Retrieves the public IP address of the user.
  • Retrieves Private IP Address: Retrieves the private IP address of the user.
  • Checks IP Type: Determines if a given IP address is IPv4 or IPv6.
  • Detects Proxy or VPN: Checks if a given IP address is associated with a known proxy or VPN.
  • Saves IPs to a File: Stores public or private IP addresses in a file for later use.
  • Reads IPs from a File: Reads previously stored IP addresses from a file.
  • Command-Line Interface: Provides a CLI for quick access to the library's functionalities.

Installation

To install the package, use:

pip install ip_fetcher

Changelog

0.3.4 (2024-09-16)

  • Python 3.6+ Support: Updated compatibility to Python 3.6 or later.
  • Refactored f-strings: Changed f-strings to .format() to support older versions of Python (3.3+).
  • New IP Saving and Loading Feature: Added functionality to save public and private IP addresses to a file and read them back.
  • Improved Version Check: Automatically checks for the latest version on PyPI when the package is imported.

0.3.3 (2024-09-15)

  • Updated setup.py Requirements: Changed Python version requirement to >=3.9.7.
  • Improved CLI: Enhanced error handling and command functionality; fixed issues from versions 0.3.2 and 0.3.2.9.
  • Created Changelog Section: Added a changelog.

Usage

Here are some examples of how to use the ip_fetcher library:

Fetching the Public IP

To get your public IP address:

from ip_fetcher import get_public_ip

public_ip = get_public_ip()
print("Public IP: {}".format(public_ip))

Fetching the Private IP

To get your private IP address:

from ip_fetcher import get_private_ip

private_ip = get_private_ip()
print("Private IP: {}".format(private_ip))

Checking IP Type

To check if an IP address is IPv4 or IPv6:

from ip_fetcher import is_ipv4, is_ipv6

ip_address = "192.168.1.1"

if is_ipv4(ip_address):
    print("{} is an IPv4 address.".format(ip_address))
elif is_ipv6(ip_address):
    print("{} is an IPv6 address.".format(ip_address))
else:
    print("{} is not a valid IP address.".format(ip_address))

Checking for Proxy or VPN

To check if an IP address is associated with a proxy or VPN:

from ip_fetcher import check_ip_proxy_vpn

ip_address = "8.8.8.8"

proxy_data = check_ip_proxy_vpn(ip_address)
if proxy_data['is_proxy']:
    print("{} is associated with a proxy or VPN.".format(ip_address))
    print("Provider: {}".format(proxy_data['provider']))
else:
    print("{} is not associated with a proxy or VPN.".format(ip_address))

Saving IP Addresses to a File

You can save the public or private IP to a file for later use:

from ip_fetcher import get_public_ip, get_private_ip, store

public_ip = get_public_ip()
private_ip = get_private_ip()

# Save the IP addresses to a file
store(public_ip, "ip_addresses.txt")
store(private_ip, "ip_addresses.txt")

print("IP addresses saved to ip_addresses.txt")

Reading IP Addresses from a File

You can load and display the saved IPs from a file:

from ip_fetcher import read

ips = read("ip_addresses.txt")
for ip in ips:
    print(ip)

Reading a Specific IP Address from a File

You can load and display a specific IP address from a file:

from ip_fetcher import read_specific

public_ip = read_specific("public_ip_address", "ip_addresses.txt")
if public_ip:
    print("Stored Public IP: {}".format(public_ip))
else:
    print("Public IP address not found in the file.")

Command-Line Interface (CLI)

After installing the package, you can use the command-line interface to access the library's functionalities directly from the terminal.

Fetch Public IP

ip-fetcher --public

Fetch Private IP

ip-fetcher --private

Fetch Both Public and Private IPs

ip-fetcher --public --private

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

ip_fetcher-0.3.4.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

ip_fetcher-0.3.4-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file ip_fetcher-0.3.4.tar.gz.

File metadata

  • Download URL: ip_fetcher-0.3.4.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.7

File hashes

Hashes for ip_fetcher-0.3.4.tar.gz
Algorithm Hash digest
SHA256 c1c3a4d1f42adbcf8df4b1e62d332ff9206e30bc02f12ac0c1d6ab1914e34534
MD5 dfe8d5ded4ad7a49f4c897c2969ba3fa
BLAKE2b-256 14a1ebac34ef4d167c56f80832c05370d9c3fe8213216cb19c2f0db791651848

See more details on using hashes here.

File details

Details for the file ip_fetcher-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: ip_fetcher-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.7

File hashes

Hashes for ip_fetcher-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 91707f280519e51f7f0e90095528cf3ee2c37d5de3468866faddfa53b292f1c9
MD5 599171f78a4898f13188938d079b32ee
BLAKE2b-256 9cbdcfeeb47f5856631e57b62b555d95470cf768ba1be534ee6763bda75c11bd

See more details on using hashes here.

Supported by

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