Getting Started
This is a Python client 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 you need an API Key to access the API. To get a key on the 1500 requests a day free tier, sign up at https://ipdata.co/registration.html. If you need higher volume, sign up for your preferred plan at https://ipdata.co/pricing.html.
Visit our Documentation for more information.
Installation
pip3 install ipdata
Usage
- Looking Up the Calling IP Address
from ipdata import IPData
from pprint import pprint
# Create an instance of an ipdata object. Replace `test` with your API Key
ipdata_lookup = IPData('test')
response = ipdata_lookup.lookup()
pprint(response)
- Looking Up any IP Address
from ipdata import IPData
from pprint import pprint
# Create an instance of an ipdata object. Replace `test` with your API Key
ipdata_lookup = IPData('test')
response = ipdata_lookup.lookup('69.78.70.144')
pprint(response)
Response
{'asn': 'AS6167',
'calling_code': '1',
'carrier': {'mcc': '310', 'mnc': '004', 'name': 'Verizon'},
'city': 'Farmersville',
'continent_code': 'NA',
'continent_name': 'North America',
'count': '1506',
'country_code': 'US',
'country_name': 'United States',
'currency': {'code': 'USD',
'name': 'US Dollar',
'native': '$',
'plural': 'US dollars',
'symbol': '$'},
'emoji_flag': '🇺🇸',
'emoji_unicode': 'U+1F1FA U+1F1F8',
'flag': 'https://ipdata.co/flags/us.png',
'ip': '69.78.70.144',
'is_eu': False,
'languages': [{'name': 'English', 'native': 'English'}],
'latitude': 33.1659,
'longitude': -96.3686,
'organisation': 'Cellco Partnership DBA Verizon Wireless',
'postal': '75442',
'region': 'Texas',
'region_code': 'TX',
'status': 200,
'threat': {'is_anonymous': False,
'is_bogon': False,
'is_known_abuser': False,
'is_known_attacker': False,
'is_proxy': False,
'is_threat': False,
'is_tor': False},
'time_zone': {'abbr': 'CDT',
'current_time': '2019-04-28T17:56:59.246755-05:00',
'is_dst': True,
'name': 'America/Chicago',
'offset': '-0500'}}
- Getting only one field
from ipdata import IPData
from pprint import pprint
# Create an instance of an ipdata object. Replace `test` with your API Key
ipdata_lookup = IPData('test')
response = ipdata.lookup('8.8.8.8', select_field='organisation')
pprint(response)
Response
{'organisation': 'Google LLC', 'status': 200}
- Getting a number of specific fields
from ipdata import IPData
from pprint import pprint
# Create an instance of an ipdata object. Replace `test` with your API Key
ipdata_lookup = 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}
- Bulk Lookups
from ipdata import IPData
from pprint import pprint
# Create an instance of an ipdata object. Replace `test` with your API Key
ipdata_lookup = IPData('test')
response = ipdata.bulk_lookup(['8.8.8.8','1.1.1.1'])
pprint(response)
Response
{'response': [{'asn': 'AS15169',
'calling_code': '1',
'city': None,
'continent_code': 'NA',
'continent_name': 'North America',
'count': '1506',
'country_code': 'US',
'country_name': 'United States',
'currency': {'code': 'USD',
'name': 'US Dollar',
'native': '$',
'plural': 'US dollars',
'symbol': '$'},
'emoji_flag': '🇺🇸',
'emoji_unicode': 'U+1F1FA U+1F1F8',
'flag': 'https://ipdata.co/flags/us.png',
'ip': '8.8.8.8',
'is_eu': False,
'languages': [{'name': 'English', 'native': 'English'}],
'latitude': 37.751,
'longitude': -97.822,
'organisation': 'Google LLC',
'postal': None,
'region': None,
'region_code': None,
'threat': {'is_anonymous': False,
'is_bogon': False,
'is_known_abuser': False,
'is_known_attacker': False,
'is_proxy': False,
'is_threat': False,
'is_tor': False},
'time_zone': {'abbr': 'CDT',
'current_time': '2019-04-28T18:02:48.035425-05:00',
'is_dst': True,
'name': 'America/Chicago',
'offset': '-0500'}},
{'asn': 'AS13335',
'calling_code': '61',
'city': None,
'continent_code': 'OC',
'continent_name': 'Oceania',
'count': '1506',
'country_code': 'AU',
'country_name': 'Australia',
'currency': {'code': 'AUD',
'name': 'Australian Dollar',
'native': '$',
'plural': 'Australian dollars',
'symbol': 'AU$'},
'emoji_flag': '🇦🇺',
'emoji_unicode': 'U+1F1E6 U+1F1FA',
'flag': 'https://ipdata.co/flags/au.png',
'ip': '1.1.1.1',
'is_eu': False,
'languages': [{'name': 'English', 'native': 'English'}],
'latitude': -33.494,
'longitude': 143.2104,
'organisation': 'Cloudflare, Inc.',
'postal': None,
'region': None,
'region_code': None,
'threat': {'is_anonymous': False,
'is_bogon': False,
'is_known_abuser': False,
'is_known_attacker': False,
'is_proxy': False,
'is_threat': False,
'is_tor': False},
'time_zone': {'abbr': 'AEST',
'current_time': '2019-04-29T09:02:48.036287+10:00',
'is_dst': False,
'name': 'Australia/Sydney',
'offset': '+1000'}}],
'status': 200}
Available Fields
A list of all the fields returned by the API is maintained at Response Fields
Errors
A list of possible errors is available at Status Codes
Tests
To run all tests
python3 test_ipdata.py
Metadata
Release files for ipdata 2.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ipdata-2.8-py3-none-any.whl | Python 3 | none | any | Details for ipdata-2.8-py3-none-any.whl |
Release files / ipdata-2.8-py3-none-any.whl
| Download URL | ipdata-2.8-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cad407fa7c9585665ff8ff2298df1e55be69e29bad526ccb934f4ecb7fa00ad6
|
|
BLAKE2b-256 checksum How to use checksums |
5d892ffa31d3cf485d8a2440a9194fe99f9b20d9c5212c1a918a7094970f61d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7
|
Security for ipdata 2.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.