A Python IP enrichment library
Project description
ENRICH IP (ipatel)
Overview
ipatel is a lightweight and efficient Python library and CLI tool for enriching IP addresses and ASNs with metadata such as:
- ASN (Autonomous System Number)
- Owner / AS Description
- Country Code
- IP Type (Public / Private / Invalid)
- IP Ranges for ASN
🔑 Features
- Works offline after downloading the IP-to-ASN database.
- Built-in support to auto-update the enrichment database.
- Friendly CLI with rich output formatting.
- Fully tested and modular codebase.
🚀 Quickstart Guide
Welcome to IPATEL — a fast and lightweight IP enrichment library.
This guide shows how to quickly get started with importing the library and using all core functions.
📦 Installation
pip install ipatel
✨ Basic Usage
import ipatel as ip
# Sample test inputs
test_ip = "8.8.8.8"
test_asn = 15169
🔍 IP Enrichment
Enrich an IP address with all available fields:
ip.enrich_ip(test_ip)
Returns:
{
'ip': '8.8.8.8',
'asn': 15169,
'country_code': 'US',
'owner': 'GOOGLE',
'ip_type': 'Public'
}
🧠 ASN Lookups
Get ASN record (raw dict):
ip.get_record(test_ip)
Get ASN number:
ip.get_asn(test_ip) # ➝ 15169
Get country code:
ip.get_country_code(test_ip) # ➝ "US"
Get AS owner/organization:
ip.get_owner(test_ip) # ➝ "GOOGLE"
Get all IP ranges owned by an ASN:
ip.get_ip_ranges_for_asn(test_asn)
🛠️ Utilities
Convert IP to integer:
ip.ip_to_int("8.8.8.8") # ➝ 134744072
Convert integer to IP:
ip.int_to_ip(134744072) # ➝ "8.8.8.8"
Detect IP type (public/private/reserved):
ip.get_ip_type("127.0.0.1") # ➝ "Loopback"
🔄 Database Handling
Download the latest IP-to-ASN database:
ip.download_ip2asn_db()
Ensure local DB is fresh:
ip.ensure_ip2asn_db()
🧪 Full Test Script
You can try this all together:
def run_tests():
ip.ensure_ip2asn_db()
print(ip.enrich_ip("8.8.8.8"))
if __name__ == "__main__":
run_tests()
📝 Notes
- All functions are safe for both IPv4 inputs.
- Private, reserved, and loopback IPs are handled gracefully.
📚 See Also
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ipatel-0.1.0.tar.gz.
File metadata
- Download URL: ipatel-0.1.0.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94f31512b132e1d9220b1b29589102097c4956176778cd0ead82e96833c67877
|
|
| MD5 |
74c80706263f32f5759a83f1e16be746
|
|
| BLAKE2b-256 |
67f84576c21b7d15745effd59108d759861d5f9e384a026869195d721632243e
|
File details
Details for the file ipatel-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ipatel-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81271e44083a520f87afd8a362722c1c260acb5cf0d4dc4b3e828aa2636152aa
|
|
| MD5 |
0e57b2a8e0bf975f75b7373394ff072b
|
|
| BLAKE2b-256 |
461a42e0a4e8e3aa1610f27d9f18432e5dab1d99486414e54fa4dd1e07e43967
|