Skip to main content

The simplest possible way to get IP geolocation information in Python.

https://raw.githubusercontent.com/whois-api-llc/python-simple-geoip/master/images/geoip.png python-simple-geoip Release python-simple-geoip Build

Meta

Prerequisites

To use this library, you’ll need to create a free GeoIPify account: https://geoipify.whoisxmlapi.com/

If you haven’t done this yet, please do so now.

Installation

To install simple-geoip using pypi, simply run:

$ pip install simple-geoip

In the root of your project directory.

Usage

Once you have simple-geoip installed, you can use it to easily find the physical location of a given IP address.

This library gives you access to all sorts of geographical location data that you can use in your application in any number of ways.

from simple_geoip import GeoIP

geoip = GeoIP("your-api-key");

try:
    data = geoip.lookup("8.8.8.8")
except ConnectionError:
    # If you get here, it means you were unable to reach the geoipify
    # service, most likely because of a network error on your end.
except ServiceError:
    # If you get here, it means geoipify is having issues, so the request
    # couldn't be completed :(
except:
    # Something else happened (non-geoipify) related. Maybe you hit CTRL-C
    # while the program was running, the kernel is killing your process, or
    # something else all together.

print(data)

Here’s the sort of data you might get back when performing a geoip lookup request:

{
  "ip": "8.8.8.8",
  "location": {
    "country": "US",
    "region": "California",
    "city": "Mountain View",
    "lat": 37.40599,
    "lng": -122.078514,
    "postalCode": "94043",
    "timezone": "-08:00"
  }
}

By default, this library handles retrying failed HTTP requests for you. For instance: if the GeoIPify API service is currently down or having issues, your request will be retried up to three consecutive times before failing.

Changelog

All library changes in descending order.

Version 0.1.1

August 4, 2020

WhoisXML API Tech Support has fixed issues due to obsolete commands. It is now Python 3.8 compatible, and has been also tested with Python 3.6 and 2.7.

Version 0.1.0

Released April 26, 2018.

  • First release!

Metadata

Release files for simple-geoip 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simple-geoip 0.1.1
File Size Uploaded
simple-geoip-0.1.1.tar.gz 5.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for simple-geoip 0.1.1
File Interpreter ABI Platform
simple_geoip-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.8 kB

Release files / simple-geoip-0.1.1.tar.gz

Download URL simple-geoip-0.1.1.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f5d11ddacd1e4582d5762eebb43b05de9bc7ca4350f7070c84e0f3a4467a21a4
BLAKE2b-256 checksum
How to use checksums
e7edacce078f76344ea1d2e6649542e0b2c2d4bf79bbefb31413ac0bc007bb2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.9

Release files / simple_geoip-0.1.1-py3-none-any.whl

Download URL simple_geoip-0.1.1-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a3b38f846f6c232b7cbfff7d45ff36eda025ebb26bb4e8ca1346511601f5cea
BLAKE2b-256 checksum
How to use checksums
725cb347185728fe690afcac86a4f8d8969c83acf158ac2e260a33bf407f85f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page