|
| 1 | +# IPData.info Python SDK — Free IP Geolocation & Threat Intelligence API |
| 2 | + |
| 3 | +[](https://pypi.org/project/ipdatainfo/) [](../../actions/workflows/ci.yml) [](./LICENSE) |
| 4 | + |
| 5 | +Official Python client for [**ipdata.info**](https://ipdata.info) — a free, |
| 6 | +fast IP geolocation, ASN, and threat-intelligence API. Look up country, city, |
| 7 | +ASN, timezone, currency, and security flags (proxy/VPN/Tor/hosting) for any IPv4 |
| 8 | +or IPv6 address. Powered by [ipdata.info](https://ipdata.info). |
| 9 | + |
| 10 | +## Get a free API key |
| 11 | + |
| 12 | +The public endpoint is **free — 50 requests/min, no signup, no key**. For higher |
| 13 | +rate limits and batch lookups, [**create a free API key at |
| 14 | +ipdata.info/register**](https://ipdata.info/register) and manage it in your |
| 15 | +[dashboard](https://ipdata.info/dashboard). |
| 16 | + |
| 17 | +## Install |
| 18 | + |
| 19 | +``` |
| 20 | +pip install ipdatainfo |
| 21 | +``` |
| 22 | + |
| 23 | +## Quickstart |
| 24 | + |
| 25 | +```python |
| 26 | +from ipdatainfo import Client |
| 27 | + |
| 28 | +# Free tier — no API key needed. For higher limits + batch, get a free key |
| 29 | +# at https://ipdata.info/register and use Client(api_key="..."). |
| 30 | +client = Client() |
| 31 | + |
| 32 | +info = client.lookup("8.8.8.8") |
| 33 | +print(info.city, info.country, info.asn_org) # Mountain View United States Google LLC |
| 34 | +``` |
| 35 | + |
| 36 | +## Methods |
| 37 | + |
| 38 | +| Method | What it returns | |
| 39 | +|--------|-----------------| |
| 40 | +| `lookup(ip="")` | Full geolocation record (own IP if omitted) | |
| 41 | +| `geo(ip)` | Geo subset (city/region/country/lat/lon/tz) | |
| 42 | +| `asn(ip)` | ASN + ISP/registry for an IP | |
| 43 | +| `batch(ips)` | Many IPs at once (**requires an API key**) | |
| 44 | +| `asn_detail(n)` | ASN detail incl. prefixes | |
| 45 | +| `asn_whois_history(n)` | ASN whois history | |
| 46 | +| `asn_changes()` | ASN change feed | |
| 47 | +| `threat_domain/threat_hash/threat_url(x)` | Threat-intel lookup (domain / file hash / URL) | |
| 48 | + |
| 49 | +Full response schema: [ipdata.info API docs](https://ipdata.info/docs) · |
| 50 | +[SDK contract](https://ipdata.info/docs/sdks). |
| 51 | + |
| 52 | +## Configuration |
| 53 | + |
| 54 | +```python |
| 55 | +from ipdatainfo import Client |
| 56 | + |
| 57 | +client = Client( |
| 58 | + api_key="KEY", # sent as X-Api-Key; switches to pro.ipdata.info |
| 59 | + base_url="https://ipdata.info", # override the host |
| 60 | + timeout=10.0, # seconds |
| 61 | +) |
| 62 | +``` |
| 63 | + |
| 64 | +Errors from non-2xx responses are raised as `ipdatainfo.IpDataError` with |
| 65 | +`.status` and `.message`. |
| 66 | + |
| 67 | +## Rate limits |
| 68 | + |
| 69 | +- Free (`ipdata.info`): 50 req/min, no key. |
| 70 | +- Paid (`pro.ipdata.info`): higher limits + `batch`, with an |
| 71 | + [API key](https://ipdata.info/register). |
| 72 | + |
| 73 | +## Other SDKs |
| 74 | + |
| 75 | +12 official SDKs — see the full list at |
| 76 | +[**ipdata.info/docs/sdks**](https://ipdata.info/docs/sdks): Python, Node.js, Go, |
| 77 | +PHP, Java, Rust, .NET, Kotlin, Swift, Dart, Bash, Objective-C. |
| 78 | + |
| 79 | +## License |
| 80 | + |
| 81 | +MIT © [ipdata.info](https://ipdata.info) |
0 commit comments