Skip to main content

IP geolocation and ASN lookup API client — ipfyi.com

Project description

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

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

ipfyi-0.1.1.tar.gz (461.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ipfyi-0.1.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file ipfyi-0.1.1.tar.gz.

File metadata

  • Download URL: ipfyi-0.1.1.tar.gz
  • Upload date:
  • Size: 461.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ipfyi-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7aa15133d6529eecaab4b6a4b515cceb347f5ea6f488c8bcb0fbfdf7c7f4d26f
MD5 aaff435ae80287f1f78baa49276d69e4
BLAKE2b-256 319303e2ca3cb58c7cd6d392e0b20efad7d13c7be8693d3db5c1b66253fea298

See more details on using hashes here.

File details

Details for the file ipfyi-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ipfyi-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ipfyi-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 634008cffb59a7bba8dd3b9633e274f6f9d7180c630efdd326f9155b6af43a5a
MD5 744d63faf2782dd074b06f6b5dc69acb
BLAKE2b-256 3d6be00fd8a2fe65e4a2916cfc6c0cfdab850f4e73b9e898f712d2afededa0a3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page