Skip to content

Python SDK

PyPI GitHub

Official Python client. One call returns the full payload: geolocation, timezone, flag, currency, connection (ASN/ISP), security, and user-agent when present.

Terminal window
pip install ipwho-ip-geolocation-api

Python 3.8+, requests. Import path: from ipwho import IPWhoClient.

import os
from 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 /me
bulk = client.bulk(["8.8.8.8", "1.1.1.1"]) # GET /bulk/{a,b,c}
print(resp.data.geo_location.country) # United States
print(resp.data.connection.asn_number) # 15169
v1v2
from src import IPWhofrom ipwho import IPWhoClient
get_location(ip) / get_ip(ip)lookup(ip) then resp.data.geo_location
get_me()me()
(missing)bulk(ips)
  • lookup(ip)GET /ip/{ip}
  • me()GET /me
  • bulk(ips)GET /bulk/{a,b,c}; rows on data.response_array

Errors: InvalidIPError (404), RateLimitError (429), APIResponseError.