ipquery
A Python library to query IP addresses using the ipquery.io API. This library allows you to easily retrieve detailed information about IP addresses, including ISP data, geolocation details, and risk analysis.
Features
- Query detailed information for a specific IP address.
- Fetch your own public IP address.
- Perform bulk queries for multiple IP addresses.
- Includes Pydantic models for easy data validation and parsing.
Installation
Install the package using pip:
pip install ipcore
Usage
Importing the Package
from ipapi.client import IPAPIClient
Query a Specific IP Address
Fetch information about a specific IP address:
Synchronously
from ipapi.client import IPAPIClient
client = IPAPIClient()
ip_info = client.query_ip("8.8.8.8")
print(ip_info)
Asychronously
from ipapi.client import AsyncIPAPIClient
async def main():
client = AsyncIPAPIClient()
ip_info = await client.query_ip("8.8.8.8")
print(ip_info)
if __name__ == "__main__":
import asyncio
asyncio.run(main())
Example Output:
IPInfo(ip='8.8.8.8', isp=ISPInfo(asn='AS15169', org='Google LLC', isp='Google LLC'),
location=LocationInfo(country='United States', country_code='US', city='Mountain View',
state='California', zipcode='94035', latitude=37.386, longitude=-122.0838, timezone='America/Los_Angeles', localtime='2024-11-09T12:45:32'),
risk=RiskInfo(is_mobile=False, is_vpn=False, is_tor=False, is_proxy=False, is_datacenter=True, risk_score=0))
Fetch Your Own Public IP Address
Retrieve your machine's public IP address:
ip = client.query_own_ip()
print(f"Your IP: {ip}")
Example Output:
Your IP: 203.0.113.45
Bulk Query Multiple IP Addresses
Fetch details for multiple IP addresses in a single request:
ips = ["8.8.8.8", "1.1.1.1"]
results = client.query_bulk(ips)
for ip_info in results:
print(ip_info)
Example Output:
IPInfo(ip='8.8.8.8', ...)
IPInfo(ip='1.1.1.1', ...)
Running Tests
If you want to run tests to verify functionality:
pytest tests/
Requirements
- Python 3.7+
- Pydantic 2.x
- httpx
License
This project is licensed under the MIT License. See the LICENSE file for more information.
Links
Metadata
Release files for ipcore 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ipcore-0.1.2.tar.gz | 3.6 kB | Without provenance | Details for ipcore-0.1.2.tar.gz |
Release files / ipcore-0.1.2.tar.gz
| Download URL | ipcore-0.1.2.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9dc6cbc7891976373164d058f097e9622631fbe7db426efbbff273c80e9eb496
|
|
BLAKE2b-256 checksum How to use checksums |
43d6f021b0cef11a4e59d73211d21197d433caf81ce3b8449c53eca96caa2083
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.13.0
|
Security for ipcore 0.1.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.