Python API for IP2Location database. It can be used to identify visitor's geographical location, i.e. country, region, city, latitude, longitude, ZIP code, time zone, connection speed, ISP, domain name, IDD country code, area code, weather station code and name, mobile carrier, elevation and usage type information.
Project description
IP2Location Python Library
This IP2Location Python library enables user to find the country, region or state, city, latitude and longitude, US ZIP code, time zone, Internet Service Provider (ISP) or company name, domain name, net speed, area code, weather station code, weather station name, mobile country code (MCC), mobile network code (MNC) and carrier brand, elevation, and usage type by IP address or hostname originates from. The library reads the geo location information from IP2Location BIN data file. It has been optimized for speed and memory utilization. Developers can use this API to easily query the information for all IP2Location binary (BIN) databases by a given IP address. It supported IPv4 and IPv6 address.
This package can be used in many types of projects such as:
- select the geographically closest mirror
- analyze your web server logs to determine the countries of your visitors
- credit card fraud detection
- software export controls
- display native language and currency
- prevent password sharing and abuse of service
- geotargeting in advertisement
For more details, please visit: https://www.ip2location.com/developers/python
Installation
To install this module type the following:
pip install IP2Location
Usage
import os
import IP2Location
database = IP2Location.IP2Location(os.path.join("data", "IPV6-COUNTRY.BIN"))
rec = database.get_all("19.5.10.1")
print(rec.country_short)
print(rec.country_long)
print(rec.region)
print(rec.city)
print(rec.isp)
print(rec.latitude)
print(rec.longitude)
print(rec.domain)
print(rec.zipcode)
print(rec.timezone)
print(rec.netspeed)
print(rec.idd_code)
print(rec.area_code)
print(rec.weather_code)
print(rec.weather_name)
print(rec.mcc)
print(rec.mnc)
print(rec.mobile_brand)
print(rec.elevation)
print(rec.usage_type)
print("\nYou may download the DB24 sample BIN at https://www.ip2location.com/downloads/sample6.bin.db24.zip for full data display.")
Sample BIN Databases
- Download free IP2Location LITE databases at https://lite.ip2location.com
- Download IP2Location sample databases at https://www.ip2location.com/developers
IPv4 BIN vs IPv6 BIN
- Use the IPv4 BIN file if you just need to query IPv4 addresses.
- Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.
Support
Email: support@ip2location.com.
URL: https://www.ip2location.com
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
Built Distribution
Hashes for IP2Location-8.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d450a5ad96107ca57bb74578a25a51b34a3f12d204439b8faeef25193458167 |
|
MD5 | 93240455d732383b5b37d21f8b257e32 |
|
BLAKE2b-256 | b75fedf6e6e8c54cc187a33e460800c65bc076060111f77b1fc31272d2666ca8 |