Skip to main content

IP2LOC

A tiny web server for ipv4 to geo location conversion

System Prerequisites

  • SQLite is available (SQLite is included by default in these systems.)
  • Only Python3 supported, >= 3.6 is preferred.

Quick Start

Installation & Run

pip install --user ip2loc-server
ip2loc

Now you have already started the server. Try

curl localhost:8080/ip2loc?ip=216.58.221.228
# {"ip": "216.58.221.228", "country_code": "NL", "country_name": "Netherlands", "region_name": "Noord-Holland", "city_name": "Amsterdam", "latitude": 52.37403, "longitude": 4.88969}
curl localhost:8080/url2loc?url=www.google.com
# {"ip": "216.58.221.228", "country_code": "NL", "country_name": "Netherlands", "region_name": "Noord-Holland", "city_name": "Amsterdam", "latitude": 52.37403, "longitude": 4.88969}
curl localhost:8080/url2loc?url=https://www.google.com
# {"ip": "216.58.221.228", "country_code": "NL", "country_name": "Netherlands", "region_name": "Noord-Holland", "city_name": "Amsterdam", "latitude": 52.37403, "longitude": 4.88969}

to test the server is working well. Run ip2loc -h for more helps.

Server Port

By default the server listens to port 8080, you could ONLY modify this in the configure file. (Arguments specified listening ports are not supported)

In addition multiple ports could be configured as

# multiple listening port example
PORTS = (8080, 8081, 8082,)

Paths

I deliberately do not list the data, configure and log paths in this README file, for the reason that the default paths are all relative paths which are not easy to be described clearly.

To find these useful path info, run

ip2loc --showpath

Track the Latest Data

All the data used in this project is from https://lite.ip2location.com/database/ip-country-region-city-latitude-longitude.

For the reason that the data on this site are updated monthly, you need track the latest data manually.

  • Download "IPV4CSV" and remember the current version of data IP2LocationSiteSnapshot

  • Run ip2loc --loaddata --dataver="current version" --csv="CSV/DATA/PATH/NAME.CSV" or ip2loc --loaddata --dataver="current version" --zip="ZIP/DATA/PATH/NAME.ZIP"

How This Works

Briefly: Binary search of ordered ip data

See https://lite.ip2location.com/database/ip-country-region-city-latitude-longitude for details of data structure.

Contact Me

zhenninglang@163.com

Release files for ip2loc-server 0.0.1

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

Source distribution (sdist)

Source distribution for ip2loc-server 0.0.1
File Size Uploaded
ip2loc_server-0.0.1.tar.gz 42.2 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for ip2loc-server 0.0.1
File Interpreter ABI Platform
ip2loc_server-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 84.4 MB

Release files / ip2loc_server-0.0.1.tar.gz

Download URL ip2loc_server-0.0.1.tar.gz
Size 42.2 MB
Tags Source
SHA-256 checksum
How to use checksums
2d8b0c69babe6dac16764e79a6a767250fd7abdc911db4e75586cd832d4facb8
BLAKE2b-256 checksum
How to use checksums
c5bc53aa8207c9b4690d51f95d107996f20298b08a9fee3604ede858b38f7f25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.13.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5

Release files / ip2loc_server-0.0.1-py3-none-any.whl

Download URL ip2loc_server-0.0.1-py3-none-any.whl
Size 42.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
f88b37ac7eaa153b734cc06242056c1ec23243141317359ed4d04a46f4c9709f
BLAKE2b-256 checksum
How to use checksums
c1769b495aacf1a591155219ac6ccf25bb5516ba3e80b8ef47207ea528e41902
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.13.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

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