Skip to main content

Official IP-Atlas API client — IP geolocation, ASN, VPN detection

Project description

ipatlas

Official Python client for the IP-Atlas API — IP geolocation, ASN lookup, VPN/proxy/Tor detection, batch lookup, and account management.

Install

pip install ipatlas

Requires Python 3.8+. Depends on requests.

Quickstart

Without an API key (free anonymous tier)

from ipatlas import IPAtlas

client = IPAtlas()

# Look up your own IP
me = client.lookup_self()
print(me["country"], me["org"])

# Look up a specific IP (anonymous is limited to 60 req/min)
result = client.lookup("8.8.8.8")
print(result["asn"], result["is_datacenter"])

With an API key

from ipatlas import IPAtlas

client = IPAtlas(api_key="ipa_live_...")

result = client.lookup("1.1.1.1")
print(result)

Batch lookup (up to 100 IPs)

from ipatlas import IPAtlas

client = IPAtlas(api_key="ipa_live_...")

batch = client.lookup_batch(["8.8.8.8", "1.1.1.1", "not-an-ip"])
for item in batch["results"]:
    if "error" in item:
        print(f"{item['ip']}: {item['error']}")
    else:
        print(item["ip"], item.get("country"), item.get("org"))

Responses come back in the same order as the input list. Each element is either a successful lookup dict or a per-IP error dict {"ip": ..., "error": "..."}. Request-level failures (auth, quota) raise IPAtlasError.

Account management

info = client.account()
print(f"Plan: {info['plan']}, used {info['monthly_used']}/{info['monthly_limit']} this month")

# Rotate the key (old one is revoked, new one returned once)
new = client.rotate_key()
print(new["api_key"])

Error handling

from ipatlas import IPAtlas, IPAtlasError

client = IPAtlas(api_key="ipa_live_...")

try:
    result = client.lookup("not-an-ip")
except IPAtlasError as e:
    print(f"API error {e.status_code}: {e.body}")

API

IPAtlas(api_key=None, base_url='https://api.ip-atlas.io')

Parameter Type Default Description
api_key str None API key sent as X-API-Key header
base_url str https://api.ip-atlas.io Override the API base URL

client.lookup(ip) -> dict

Returns geolocation + ASN + threat data for the given IPv4 or IPv6 address.

client.lookup_self() -> dict

Returns data for the caller's own IP address.

client.lookup_batch(ips) -> dict

Looks up up to 100 IPs in a single request. Returns {"results": [...]} where each element is in the same order as the input list.

client.account() -> dict

Returns the plan, key prefix, daily/monthly usage, and Stripe linkage for the bound API key.

client.rotate_key() -> dict

Revokes the current key and issues a replacement with the same plan. The new plaintext key is only returned once.

Links

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

ipatlas-0.1.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

ipatlas-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file ipatlas-0.1.0.tar.gz.

File metadata

  • Download URL: ipatlas-0.1.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for ipatlas-0.1.0.tar.gz
Algorithm Hash digest
SHA256 40e1e75cc64b4c0fd8ece51591d26d598b2065244180b61f1b23050def289cd0
MD5 389326d28144be1ef9841e31941bbfd0
BLAKE2b-256 287f8d64fc754bcab84e6a331cba75bb097bfc73643c60771f1ac2b7e3ad4b42

See more details on using hashes here.

File details

Details for the file ipatlas-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ipatlas-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for ipatlas-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06b3ca7148b981d7b926e8e6f1c3c27910dbb3cf225f43e2915d7674bff4cc3a
MD5 6444005e74ac0f9c7a0510c0797c5ea5
BLAKE2b-256 71a02df79128f818e98555472156e462fe2f9829b4856b104090194aa9f0fcba

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