Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Lookup country code (iso 3166) by IP address.

Project description

travis coveralls pypibadge


Lookup country code (iso 3166) by IP address.


$ pip install ip2country


$ python install

How to use

First: Implement IStore Interface

You must implement IStore interface in ip2country/

There is a sample implementation in example/store. This implementation is stored all records on the system memory.

Second: Store the records

store = Store()
parser = Parser(store)
with open(RECORD_FILE) as fp:

See examples/ for more detail.

Third: Lookup the IPAddress

store = Store()
record = store.lookup(IP_ADDRESS)
if record is None:
    print('Record not found')
    print('{0} is allocated to {1}'.format(IP_ADDRESS,

See examples/ for more detail.

Run the tests

$ tox


ip2country is licensed under the MIT LICENSE. See ./LICENSE.rst.

Project details

Release history Release notifications

This version
History Node


History Node


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
ip2country-0.1.1-py2-none-any.whl (7.1 kB) Copy SHA256 hash SHA256 Wheel 2.7 May 20, 2014
ip2country-0.1.1-py3-none-any.whl (7.0 kB) Copy SHA256 hash SHA256 Wheel 3.3 May 20, 2014
ip2country-0.1.1.tar.gz (4.1 kB) Copy SHA256 hash SHA256 Source None May 20, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page