Skip to main content

ip-country

An offline tool to get country by IP

Requirements

  • Python >= 3.6

  • IP2Location™ LITE IP-COUNTRY-REGION-CITY Database

Installation

  1. Download IP2Location database for IPv4 from https://lite.ip2location.com/database/ip-country-region-city

  2. Install library:

pip install ip_country

Usage

>>> from pprint import pprint
>>> from ip_country import IPCountry
>>> ip = IPCountry('/path/to/ipdb.csv')
>>> ip_data = ip.get_ip_data('13.73.96.0')
>>> pprint(ip_data)
{'city_name': 'Melbourne',
 'country_code': 'AU',
 'country_name': 'Australia',
 'error': None,
 'ip': '13.73.96.0',
 'region_name': 'Victoria'}

>>> ip_data = ip.get_ip_data('blah.73.96.0')
>>> pprint(ip_data)
{'error': "Only decimal digits permitted in 'blah' in 'blah.73.96.0'",
 'ip': 'blah.73.96.0'}

Metadata

Release files for ip-country 1.0.0

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

Built distribution (wheel)

Table of built distributions (wheels) for ip-country 1.0.0
File Interpreter ABI Platform
ip_country-1.0.0-py3-none-any.whl Python 3 none any Details

Release files / ip_country-1.0.0-py3-none-any.whl

Download URL ip_country-1.0.0-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d3cee970d88fd55314dc9c7af47ddb491ee791c52bb9d789912c8e3207b409e
BLAKE2b-256 checksum
How to use checksums
64b789fb475397fbcf3f5d90537c839d25476c99fdd791afa1db5c4c2b66be45
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/40.8.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.3

Security for ip-country 1.0.0

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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file No provenance

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