Skip to main content

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.2.tar.gz (2.0 kB view details)

Uploaded Source

File details

Details for the file ipdata-2.2.tar.gz.

File metadata

  • Download URL: ipdata-2.2.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ipdata-2.2.tar.gz
Algorithm Hash digest
SHA256 e8957dda5248e270af35526ac6a66d0dd1ac3ce7db0f5c44b197d1d6054c209f
MD5 d1b262aa8563ae8705c16ec1f09c7c85
BLAKE2b-256 911e2b1cc7eeea5d25657eaabb3bc1ef45020a442d15d2d9ff3a6e55b2f1ce75

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page