Skip to main content

API to access data from Sypex Geo IP database files from your Python code

Project description

http://github.com/idlesign/pysyge

release lic

What’s that

pysyge is an API to access data from Sypex Geo IP database files from your Python code.

For more information about Sypex Geo databases and their features please visit http://sypexgeo.net.

Direct DB links that might became broken over time:

Requirements

Python 2.7+, 3.2+

Attention

  1. This version of pysyge works with Sypex Geo DB version 2.2 or above.

The structure of a dictionary returned by GeoLocator.get_location() was preserved in a backward compatible manner as much as possible, yet it’s advised to update your code to use data from info sub dictionary.

  1. This version of pysyge works with UTF-8 Sypex Geo Databases. Texts returned by pysyge are UTF-8.

Quickstart

Download Geo IP database file from http://sypexgeo.net/ (example below uses SxGeoCityMax.dat file).

Application sample

# Import all we need from pysyge module.
from pysyge import GeoLocator, MODE_BATCH, MODE_MEMORY

# Create GeoLocator object to access API
# from 'SxGeoCityMax.dat' using fast memory mode.
geodata = GeoLocator('SxGeoCityMax.dat', MODE_BATCH | MODE_MEMORY)

# Let's get some meta information.
print('DB version %s (%s)' % (geodata.get_db_version(), geodata.get_db_date()))

# Request geo information for 77.88.21.3 IP address.
# Getting detailed information, including region info.
location = geodata.get_location('77.88.21.3', detailed=True)

# Print out some lyrics.
# Most interesting data is under `info` in `city`, `country` and `region` dictionaries
print('%s (%s) calling. All the circuits are busy.' % (
    location['info']['city']['name_en'], location['info']['country']['iso']))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysyge-0.3.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

pysyge-0.3.0-py2.py3-none-any.whl (8.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pysyge-0.3.0.tar.gz.

File metadata

  • Download URL: pysyge-0.3.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pysyge-0.3.0.tar.gz
Algorithm Hash digest
SHA256 64f7a581e691f0a4d8ec123d730e5ab8860e490b9a78a89b629410eb87cca914
MD5 8131776564d46b902b053a4e4fa60da6
BLAKE2b-256 4697739b5c32e655b90eaf2fd01355f89840ad80a1070f591ef068f3d31f5b3f

See more details on using hashes here.

File details

Details for the file pysyge-0.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pysyge-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 22a0098b35788711074cdae6483d706b2985a2597be10556d26bf323e69da4b7
MD5 5c0b5fc6ca60ea0b71e403ad75eadd39
BLAKE2b-256 024694d412ab26d898c4f0b78d49290cc3d076ac54716dab7724c35e21b339b0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page