This repo provides a Python client for the ipdata.co Free Geolocation API.
Installation
Run
pip install ipdata
Examples
from ipdata import ipdata
ip = ipdata.ipdata()
data = ip.lookup('1.1.1.1')
if data['status']==200:
for key in data['response']:
print('#', key, ':', data['response'][key])
else:
print(data['response'])
# ip : 1.1.1.1
# city : Research
# region : Victoria
# country_name : Australia
# country_code : AU
# continent_name : Oceania
# continent_code : OC
# latitude : -37.7
# longitude : 145.1833
# asn :
# organisation :
# postal : 3095
# currency : AUD
# currency_symbol : $
# calling_code : 61
# flag : https://ipdata.co/flags/au.png
# time_zone : Australia/Melbourne
To get a specific field, do
country = ip.lookup('1.1.1.1')['response']['country_name']
# 'Australia'
Using API keys
from ipdata import ipdata
apikey = 'myapikey'
ip = ipdata.ipdata(apikey=apikey)
data = ip.lookup('1.1.1.1')
if data['status']==200:
for key in data['response']:
print('#', key, ':', data['response'][key])
else:
print(data['response'])
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ipdata-2.6.tar.gz
(1.9 kB
view details)
File details
Details for the file ipdata-2.6.tar.gz.
File metadata
- Download URL: ipdata-2.6.tar.gz
- Upload date:
- Size: 1.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94206afef6e868b709ad4a9ac20de8de9b2c010fb88bde0bba5b69c412e95d7f
|
|
| MD5 |
8634b832c388023bcbf36c6063864497
|
|
| BLAKE2b-256 |
cce1597ccf10d0e98522452ab736d9892b514b2e379c572704abc8eb240f2c5d
|