This is an entirely open source (Apache 2) IP to country database mapping built from public sources of data. It was created to avoid having to rely on 3rd party sources for basic country data.
The database is provided in the mmdb format. It is created with Cloudflare's Python MMDB encoder. The data is sourced from iptoasn.com.
Missing/unknown data could potentially be built from the RIR data but that is currently an open improvement.
The mmdb database is useable with any MaxMind mmdb reader. You can look into bindings for libmaxmind.
One such binding in Python is maxminddb. For example:
>>> import maxminddb
>>> reader = maxminddb.open_database('Geoacumen-Country.mmdb')
>>> reader.get('1.1.1.1')
{'country': {'iso_code': 'CN'}}
The database can be rebuilt using the latest data by installing dependencies
and running create.py
.
For example:
pip install --upgrade --force -r requirements.txt
python create.py
The database can be quickly tested with the read.py
script.
You can freely download the database with no attribution requirement. There are also additional wrapping libraries to make it easier to package the db into your applications:
There is no guarantee of correctness or validity of the data returned by this database. It should not be used in critical, high-accuracy applications. If you are relying on IP to location databases in any kind of critical operation, you should re-evaluate that decision.
If you run into a problem, you can file an issue on the Github issue tracker. However, if you run into any issues it is your responsibility as an open source user to help improve the quality of the code and database.