Skip to main content

GeoIP Client Package

This package provides a client for accessing geographic information about an IP address using the hostip.info API. It validates IP addresses and URLs, and handles JSON and HTML response formats.

Features

  • Validate IPv4 addresses and service URLs.
  • Retrieve geographic information such as country name, country code, city, latitude, and longitude using hostip.info API.
  • Handle responses in both JSON and HTML formats.

Installation

To install the package, clone the repository and install the necessary dependencies:

pip install hostip-client

Usage

Import the Client

from hostip_client.client import Client

Create a Client Instance

To create an instance of the Client, provide a valid IP address, service URL, and an optional format (either 'json' or 'html').

ip_address = "8.8.8.8"  # Replace with a valid IP address
client = Client(ip_address=ip_address)

Handling Exceptions

  • InvalidIpAddress: Raised when the provided IP address is not in a valid format.
  • InvalidServiceUrl: Raised when the service URL is not valid.
  • InvalidFormat: Raised if the format is not 'json' or 'html'.

Accessing Geographic Information

Once a Client instance is created, access the geographic information like so:

print("Country Name:", client.country_name)
print("Country Code:", client.country_code)
print("City:", client.city)
print("Latitude:", client.latitude)
print("Longitude:", client.longitude)

Configuration

  • Service URL: You can specify a different hostip.info service endpoint by passing a custom URL to hostip_url.
  • Format: Choose either json or html format by setting the use_format property during initialization.

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please submit a pull request or open an issue to discuss further.

Acknowledgments

This package uses the hostip.info API for geographic data.

Metadata

Release files for hostip-client 1.0.4

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

Source distribution (sdist)

Source distribution for hostip-client 1.0.4
File Size Uploaded
hostip_client-1.0.4.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hostip-client 1.0.4
File Interpreter ABI Platform
hostip_client-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 11.2 kB

Release files / hostip_client-1.0.4.tar.gz

Download URL hostip_client-1.0.4.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
cf45b12576fae7148bbd5aa68fa91a628b45e93ee946daba20f3ea78e8136e1a
BLAKE2b-256 checksum
How to use checksums
f707ab4d3ba37ff0321fca624e2cc9e6645947116d59a4773f585d9658b4e305
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2024.

Transparency log

Release files / hostip_client-1.0.4-py3-none-any.whl

Download URL hostip_client-1.0.4-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6134f1253e7b1c7f3a1933b1320288d1afe22f4ffd5557b64f0abbff5cbadb6
BLAKE2b-256 checksum
How to use checksums
625da50064e774ff009dab017ea878baf36cc55824bdc88ee1a758b88aa06713
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2024.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

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