Python SDK
Official Python client. One call returns the full payload: geolocation, timezone, flag, currency, connection (ASN/ISP), security, and user-agent when present.
- Source: lavrox/SDK-IPWho-IP-Geolocation-Python
- PyPI:
ipwho-ip-geolocation-apiv2.0.0 - API key: ipwho.org/free-plan
Installation
Section titled “Installation”pip install ipwho-ip-geolocation-apiPython 3.8+, requests. Import path: from ipwho import IPWhoClient.
Quick start
Section titled “Quick start”import osfrom ipwho import IPWhoClient
client = IPWhoClient(api_key=os.environ["IPWHO_API_KEY"])
resp = client.lookup("8.8.8.8") # GET /ip/{ip}me = client.me() # GET /mebulk = client.bulk(["8.8.8.8", "1.1.1.1"]) # GET /bulk/{a,b,c}
print(resp.data.geo_location.country) # United Statesprint(resp.data.connection.asn_number) # 15169Migrating from v1
Section titled “Migrating from v1”| v1 | v2 |
|---|---|
from src import IPWho | from ipwho import IPWhoClient |
get_location(ip) / get_ip(ip) | lookup(ip) then resp.data.geo_location |
get_me() | me() |
| (missing) | bulk(ips) |
Methods
Section titled “Methods”lookup(ip)—GET /ip/{ip}me()—GET /mebulk(ips)—GET /bulk/{a,b,c}; rows ondata.response_array
Errors: InvalidIPError (404), RateLimitError (429), APIResponseError.