Skip to main content

Fast cloud-provider IP detection (AWS, GCP, Azure, Cloudflare, DigitalOcean, Oracle)

Project description

py-cloudip

PyPI version Python versions CI License: MIT

Fast cloud-provider IP detection for Python. Identify whether an IP address belongs to AWS, GCP, Azure, Cloudflare, DigitalOcean, or Oracle Cloud via longest-prefix-match lookups over a Patricia/binary trie.

A Python port of js-cloudip and go-cloudip, backed by the daily-updated cloudip-db MessagePack database.

  • Fast — binary trie, IPv4 + IPv6, longest-prefix match.
  • Auto-updating — fetches fresh data from cloudip-db with SHA-256 verification.
  • Offline-capable — file cache plus an embedded database bundled in the wheel.
  • Zero config — works on first call; one tiny dependency (msgpack).

Install

pip install py-cloudip

Usage

import cloudip

cloudip.is_aws("52.94.76.1")        # True
cloudip.get_provider("34.64.0.1")   # "gcp"
cloudip.is_cloud_provider("1.1.1.1")  # True

r = cloudip.lookup("52.94.76.1")
# LookupResult(found=True, provider="aws", region="us-east-1", service="EC2",
#              cidr="52.94.76.0/22", ip_type="ipv4")
r.to_dict()
# {"found": True, "provider": "aws", "cidr": "52.94.76.0/22",
#  "ip_type": "ipv4", "region": "us-east-1", "service": "EC2"}

# Forward lookup: every CIDR for one or more providers
cloudip.get_ips("cloudflare")        # list[IPEntry]
cloudip.get_ips(["aws", "gcp"])

Provider checks

is_aws, is_gcp, is_azure, is_cloudflare, is_digitalocean, is_oracle, is_cloud_provider.

Metadata & updates

cloudip.version()        # "2026-06-05"
cloudip.range_count()    # 124455
cloudip.providers()      # ["aws", "gcp", "cloudflare", "azure", "digitalocean", "oracle"]
cloudip.check_update()   # CheckUpdateResult(has_update=..., info=VersionInfo(...))
cloudip.update()         # force refresh
cloudip.clear_cache()

Custom detector

detector = cloudip.new_detector(
    data_dir="./cache",            # None disables file caching; "" = default ~/.cache/py-cloudip
    auto_update_seconds=86400,     # background refresh (min 1h); 0 disables
    offline=False,                 # air-gapped mode
    verify_sha256=True,
    ttl_seconds=86400,
)
detector.lookup("52.94.76.1")
detector.close()                   # stop the background updater
# or: with cloudip.Detector(...) as d: ...

Offline / air-gapped

The cloudip.embedded module never touches the network — it uses only the database bundled in the package:

from cloudip import embedded
embedded.is_aws("52.94.76.1")   # uses bundled data only
embedded.age_days()             # how old the bundled data is

CLI

cloudip lookup 52.94.76.1
cloudip provider 34.64.0.1
cloudip get cloudflare
cloudip get aws,gcp
cloudip providers
cloudip version
cloudip check-update
cloudip update
cloudip clear-cache

(Also runnable as python -m cloudip.)

How it works

  1. Fetch version.json + cloudip.msgpack.gz from cloudip-db.
  2. Verify the SHA-256 of the decompressed MessagePack against version.json.
  3. Decode and build per-protocol tries for sub-millisecond lookups.
  4. On network failure, fall back to the on-disk cache, then the embedded database.

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

py_cloudip-0.1.6.tar.gz (780.4 kB view details)

Uploaded Source

Built Distribution

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

py_cloudip-0.1.6-py3-none-any.whl (783.7 kB view details)

Uploaded Python 3

File details

Details for the file py_cloudip-0.1.6.tar.gz.

File metadata

  • Download URL: py_cloudip-0.1.6.tar.gz
  • Upload date:
  • Size: 780.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for py_cloudip-0.1.6.tar.gz
Algorithm Hash digest
SHA256 ba7929db32dba06464814e4197debc18455bce9a5ddd36c029563f33fb0099b2
MD5 c4732b8e0b272dc56b17fa52e5ca709f
BLAKE2b-256 167de7a3427d8c857ae7fcbeda011e49653aa83e413145f7977e23cde02e8e52

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_cloudip-0.1.6.tar.gz:

Publisher: sync-data.yml on rezmoss/py-cloudip

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_cloudip-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: py_cloudip-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 783.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for py_cloudip-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d1022114ea7e051413eb0ec7541572612fbe0effd4c642442df295f61d1b551b
MD5 0f985a8c442c57af819a960a6a628ca4
BLAKE2b-256 3320edd9f3f05bdf428681cb721891f836caaa94a4836dbaa150439ecdbcaba0

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_cloudip-0.1.6-py3-none-any.whl:

Publisher: sync-data.yml on rezmoss/py-cloudip

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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