Skip to content

fyipedia/ipfyi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ipfyi

PyPI version Python License: MIT Zero Dependencies

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.

ipfyi demo — IP geolocation, ASN lookup, and CIDR range analysis in Python

Table of Contents

Install

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]"         # Everything

Quick Start

from 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")

What You Can Do

IPv4 and IPv6 Address Spaces

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']}")  # Cloudflare

Learn more: IP Lookup · Glossary

ASN and BGP Routing

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

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 Notation and Subnetting

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

Command-Line Interface

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 info

MCP Server (Claude, Cursor, Windsurf)

pip install "ipfyi[mcp]"
{
    "mcpServers": {
        "ipfyi": {
            "command": "uvx",
            "args": ["--from", "ipfyi[mcp]", "python", "-m", "ipfyi.mcp_server"]
        }
    }
}

REST API Client

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=cloudflare

Example

curl -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/.

API Reference

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

Learn More About IP

Also Available

Platform Install Link
npm npm install ipfyi npm
MCP uvx --from "ipfyi[mcp]" python -m ipfyi.mcp_server Config

Network FYI Family

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

License

MIT

About

IP geolocation, ASN lookup, CIDR ranges — Python library & CLI. Zero dependencies.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages