This API provides access to Sypex Geo 2.2 databases. The databases available from https://sypexgeo.net/
Project description
Description
pysxgeo is an API that provides access to Sypex Geo (2.2) databases (country and city). The databases provides an information about geolocation by ip-address. For information about databases please visit sypexgeo.net.
Requirements
Python 3.x
Usage
Some examples:
>>> from pysxgeo import sxgeo
>>>
>>> ip = '52.0.183.139'
>>> db = '/path/to/db' # City or Country
>>> # AVAILABLE MODES: SXGEO_FILE, SXGEO_MEMORY, SXGEO_BATCH
>>> info = sxgeo.SxGeo(db_file=db, mode=sxgeo.SXGEO_BATCH)
>>> info.get_city(ip, full=True)
{'country': {'lon': -98.5, 'name_ru': 'США', 'name_en': 'United States',
'lat': 39.76, 'id': 225, 'iso': 'US'},
'region': {'id': 4142224, 'name_ru': 'Делавэр',
'name_en': 'Delaware', 'iso': 'US-DE'},
'city': {'name_ru': 'Уилмингтон', 'name_en': 'Wilmington',
'lat': 39.74595, 'id': 4145381, 'lon': -75.54659}
}
>>> get_country(ip)
'US'
>>> get_country_id(ip)
225
>>> # Quick usage. The answer depends of your database choice.
>>> info.get(ip)
{'city': {'name_en': 'Wilmington', 'lon': -75.54659,
'name_ru': 'Уилмингтон', 'id': 4145381, 'lat': 39.74595},
'country': {'iso': 'US', 'id': 225}}
>>> # Get db info:
>>> info.about()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file pysxgeo-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: pysxgeo-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21751dcf0c94394160f5ca83d17a7cc4b38d250516b367b9945a57a4af1ac5c7 |
|
MD5 | 75a738dc3b93f9b88313143da7a89b2f |
|
BLAKE2b-256 | 00f67a875e325abe85462597fff4d7bc40f50c0469ad5494541d3d852da5f771 |