This is a Python client and command line interface (CLI) for the ipdata.co IP Geolocation API. ipdata offers a fast, highly-available API to enrich IP Addresses with Location, Company, Threat Intelligence and numerous other data attributes.
Note that you need an API Key to use this package. You can get a free one with a 1,500 daily request limit by Signing up here.
Visit our Documentation for more examples and tutorials.
pip install ipdata
from ipdata import ipdatafrom pprint import pprint# Create an instance of an ipdata object. Replace `test` with your API Keyipdata = ipdata.IPData('test')response = ipdata.lookup()pprint(response)
from ipdata import ipdatafrom pprint import pprint# Create an instance of an ipdata object. Replace `test` with your API Keyipdata = ipdata.IPData('test')response = ipdata.lookup('69.78.70.144')pprint(response)
from ipdata import ipdatafrom pprint import pprint# Create an instance of an ipdata object. Replace `test` with your API Keyipdata = ipdata.IPData('test')response = ipdata.lookup('8.8.8.8', select_field='organisation')pprint(response)
Response
{'organisation': 'Google LLC', 'status': 200}
from ipdata import ipdatafrom pprint import pprint# Create an instance of an ipdata object. Replace `test` with your API Keyipdata = ipdata.IPData('test')response = ipdata.lookup('8.8.8.8',fields=['ip','organisation','country_name'])pprint(response)
Response
{'country_name': 'United States','ip': '8.8.8.8','organisation': 'Google LLC','status': 200}
from ipdata import ipdatafrom pprint import pprint# Create an instance of an ipdata object. Replace `test` with your API Keyipdata = ipdata.IPData('test')response = ipdata.bulk_lookup(['8.8.8.8','1.1.1.1'])pprint(response)
A list of all the fields returned by the API is maintained at Response Fields
A list of possible errors is available at Status Codes
To run all tests
python -m unittest