Python API client for IP address and network data. Look up IP geolocation, query ASN (Autonomous System Number) ownership, explore CIDR ranges, and retrieve BGP routing information — all from IPFYI, an IP intelligence platform for network engineers and security analysts.
IPFYI provides structured access to IP geolocation databases, ASN-to-organization mappings, prefix announcements, and network relationships — covering both IPv4 and IPv6 address spaces used by network operators, cybersecurity teams, and compliance platforms.
Look up IP addresses at ipfyi.com — check geolocation, browse ASNs, and explore network data.
- Install
- Quick Start
- What You Can Do
- Command-Line Interface
- MCP Server (Claude, Cursor, Windsurf)
- REST API Client
- API Reference
- Learn More About IP
- Also Available
- Network FYI Family
- License
pip install ipfyi # Core (zero deps)
pip install "ipfyi[cli]" # + Command-line interface
pip install "ipfyi[mcp]" # + MCP server for AI assistants
pip install "ipfyi[api]" # + HTTP client for ipfyi.com API
pip install "ipfyi[all]" # Everythingfrom ipfyi.api import IPFYI
with IPFYI() as api:
# Look up an IP address
info = api.lookup("8.8.8.8")
print(info["ip"]) # 8.8.8.8
print(info["asn"]) # AS15169
print(info["organization"]) # Google LLC
print(info["country"]) # United States
# Get ASN details
asn = api.get_asn("AS15169")
print(asn["name"]) # GOOGLE
print(asn["prefix_count"]) # Announced prefixes
# Search network data
results = api.search("cloudflare")The Internet Protocol uses two addressing schemes. IPv4 (32-bit, ~4.3 billion addresses) is nearly exhausted — IANA allocated the last /8 blocks in 2011. IPv6 (128-bit, 3.4 x 10^38 addresses) provides virtually unlimited address space but adoption varies by region.
| Protocol | Address Size | Format | Total Addresses |
|---|---|---|---|
| IPv4 | 32 bits | 192.168.1.1 | 4.3 billion |
| IPv6 | 128 bits | 2001:db8::1 | 3.4 x 10^38 |
| IPv4 Class | Range | Default Mask | Purpose |
|---|---|---|---|
| A | 1.0.0.0 - 126.255.255.255 | /8 | Large networks |
| B | 128.0.0.0 - 191.255.255.255 | /16 | Medium networks |
| C | 192.0.0.0 - 223.255.255.255 | /24 | Small networks |
| Private | 10.0.0.0, 172.16.0.0, 192.168.0.0 | Various | Internal use (RFC 1918) |
from ipfyi.api import IPFYI
with IPFYI() as api:
# Look up any IPv4 or IPv6 address
v4 = api.lookup("1.1.1.1")
print(f"IPv4: {v4['organization']}") # Cloudflare
v6 = api.lookup("2606:4700:4700::1111")
print(f"IPv6: {v6['organization']}") # CloudflareLearn more: IP Lookup · Glossary
An Autonomous System (AS) is a network under a single administrative domain, identified by a unique ASN. The Border Gateway Protocol (BGP) connects these autonomous systems, forming the routing fabric of the internet. Each AS announces its IP prefixes to peers, creating the global routing table.
| AS Type | Purpose | Examples |
|---|---|---|
| Stub | Single-homed end network | Small ISPs, enterprises |
| Multi-homed | Multiple upstream providers | Medium enterprises, CDNs |
| Transit | Carries traffic for other ASes | Tier 1/2 ISPs |
| Internet Exchange | Peering point | DE-CIX, AMS-IX, LINX |
from ipfyi.api import IPFYI
with IPFYI() as api:
# Look up ASN details
asn = api.get_asn("AS13335")
print(f"Name: {asn['name']}") # CLOUDFLARENET
print(f"Organization: {asn['organization']}") # Cloudflare, Inc.
print(f"Prefixes: {asn.get('prefix_count')}")
# List ASNs by country
asns = api.list_asns(country="united-states")Learn more: ASN Directory · Guides
IP geolocation maps an IP address to a physical location using a combination of RIR (Regional Internet Registry) allocation data, BGP routing tables, and active measurement. Accuracy varies — city-level is typically 50-80% accurate, country-level exceeds 99%.
| Accuracy Level | Typical Accuracy | Use Case |
|---|---|---|
| Country | 99%+ | Compliance, content licensing |
| Region/State | 80-90% | Regional content delivery |
| City | 50-80% | Local advertising, analytics |
| Postal code | 20-50% | Approximate location only |
from ipfyi.api import IPFYI
with IPFYI() as api:
# Geolocation data for an IP
info = api.lookup("8.8.8.8")
print(f"Country: {info['country']}")
print(f"Region: {info.get('region')}")
print(f"City: {info.get('city')}")
print(f"Latitude: {info.get('latitude')}")
print(f"Longitude: {info.get('longitude')}")Learn more: IP Geolocation · Glossary
CIDR (Classless Inter-Domain Routing) replaced classful addressing, allowing variable-length subnet masks. The notation IP/prefix (e.g., 10.0.0.0/8) specifies a network range. Understanding CIDR is fundamental for network planning, firewall rules, and IP allocation.
| CIDR | Subnet Mask | Hosts | Common Use |
|---|---|---|---|
| /8 | 255.0.0.0 | 16.7M | Large ISP allocation |
| /16 | 255.255.0.0 | 65,534 | Enterprise network |
| /24 | 255.255.255.0 | 254 | Small office/home |
| /32 | 255.255.255.255 | 1 | Single host route |
from ipfyi.api import IPFYI
with IPFYI() as api:
# Search for prefixes
results = api.search("10.0.0.0/8")
for r in results:
print(f"{r['prefix']}: {r.get('organization')}")Learn more: CIDR Calculator · API Documentation
pip install "ipfyi[cli]"
ipfyi lookup 8.8.8.8 # IP geolocation
ipfyi asn AS15169 # ASN details
ipfyi search "amazon" # Search networks
ipfyi my-ip # Your public IP infopip install "ipfyi[mcp]"{
"mcpServers": {
"ipfyi": {
"command": "uvx",
"args": ["--from", "ipfyi[mcp]", "python", "-m", "ipfyi.mcp_server"]
}
}
}from ipfyi.api import IPFYI
with IPFYI() as api:
info = api.lookup("8.8.8.8") # GET /api/v1/lookup/8.8.8.8/
asn = api.get_asn("AS15169") # GET /api/v1/asns/AS15169/
asns = api.list_asns(country="us") # GET /api/v1/asns/?country=us
results = api.search("cloudflare") # GET /api/v1/search/?q=cloudflarecurl -s "https://ipfyi.com/api/v1/lookup/8.8.8.8/"{
"ip": "8.8.8.8",
"asn": "AS15169",
"organization": "Google LLC",
"country": "United States",
"city": "Mountain View"
}Full API documentation at ipfyi.com/developers/.
| Function | Description |
|---|---|
api.lookup(ip) |
IP geolocation and ASN info |
api.get_asn(asn) |
ASN details (organization, prefixes) |
api.list_asns(country) |
List ASNs, optionally by country |
api.search(query) |
Search IPs, ASNs, and organizations |
- Browse: IP Lookup · ASN Directory
- Guides: Networking Guides · Glossary
- API: REST API Docs · OpenAPI Spec
| Platform | Install | Link |
|---|---|---|
| npm | npm install ipfyi |
npm |
| MCP | uvx --from "ipfyi[mcp]" python -m ipfyi.mcp_server |
Config |
Part of the FYIPedia open-source developer tools ecosystem — internet infrastructure, cables, domains, and protocols.
| Package | PyPI | npm | Description |
|---|---|---|---|
| cablefyi | PyPI | npm | Submarine cables, landing points, operators — cablefyi.com |
| tldfyi | PyPI | npm | TLD registry, domain extensions, WHOIS — tldfyi.com |
| ipfyi | PyPI | npm | IP geolocation, ASN lookup, CIDR ranges — ipfyi.com |
| protocolcodes | PyPI | npm | HTTP status codes, protocol references — statuscodefyi.com |
MIT
