This is an IP geolocation library that enables the user to find the country, region, city, latitude and longitude, ZIP code, time zone, ISP, domain name, area code, weather info, mobile info, elevation, usage type, address type and IAB category from an IP address. It supports both IPv4 and IPv6 lookup.
Project description
IP2Location 8.6.4
This is a IP2Location Python library that enables the user to find the country, region or state, city, latitude and longitude, 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, usage type, address type and IAB category by IP address or hostname originates from. The library reads the geo location information from IP2Location BIN data file.
Supported IPv4 and IPv6 address.
For more details, please visit: https://www.ip2location.com/developers/python
Requirements
- Python 2.2 and above
Installation
- Unzip the package.
- Execute python setup.py build
- Execute python setup.py install
or
To install this module type the following (for PyPI):
pip install IP2Location
Usage
You can check the sample.py file to learn more about usage.
BIN Database
Below is the description of the functions available in the BIN Database lookup.
Method Name | Description |
---|---|
open | Open the IP2Location BIN data for lookup. Default mode: File I/O. |
close | Close and clean up the file pointer. |
get_all | Return the geolocation information in array. |
get_country_short | Return the ISO3166-1 country code (2-digits) of the IP address. |
get_country_long | Return the ISO3166-1 country name of the IP address. |
get_region | Return the ISO3166-2 region name of the IP address. Please visit ISO3166-2 Subdivision Code for the information of ISO3166-2 supported |
get_city | Return the city name of the IP address. |
get_latitude | Return the city latitude of the IP address. |
get_longitude | Return the city longtitude of the IP address. |
get_isp | Return the ISP name of the IP address. |
get_domain | Return the domain name of IP address. |
get_zipcode | Return the zipcode of the city. |
get_timezone | Return the UTC time zone (with DST supported). |
get_netspeed | Return the Internet connection type. Please see Internet Connection Type for details. |
get_idd_code | Return the IDD prefix to call the city from another country. |
get_area_code | Return the area code of the city. |
get_weather_code | Return the nearest weather observation station code. |
get_weather_name | Return the nearest weather observation station name. |
get_mcc | Return the Mobile Country Codes (MCC). |
get_mnc | Return the Mobile Network Code (MNC). |
get_mobile_brand | Commercial brand associated with the mobile carrier. Please visit Mobile Carrier Coverage to view the coverage report. |
get_elevation | Return average height of city above sea level in meters (m). |
get_usage_type | Return the ISP's usage type of IP address. Please see Usage Type for details. |
get_address_type | Return the IP address type (A-Anycast, B-Broadcast, M-Multicast & U-Unicast) of IP address or domain name. |
get_category | Return the IAB content taxonomy category of IP address or domain name. You can get a full list of IAB content taxonomy category from here. |
Web Service
Below is the description of the functions available in the Web Service lookup.
Function Name | Description |
---|---|
Constructor | Expect 3 input parameters:
|
lookup | Return the IP information in array.
|
get_credit | Return remaining credit of the web service account. |
Testing
python sample.py
python test.py
python lookup.py <ip_address>
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.
Internet Connection Type
Internet Connection Type | Description |
---|---|
DIAL | Dial Up |
DSL | Broadband/Cable/Fiber/Mobile |
COMP | Company/T1 |
Usage Type
Usage Type | Description |
---|---|
COM | Commercial |
ORG | Organization |
GOV | Government |
MIL | Military |
EDU | University/College/School |
LIB | Library |
CDN | Content Delivery Network |
ISP | Fixed Line ISP |
MOB | Mobile ISP |
DCH | Data Center/Web Hosting/Transit |
SES | Search Engine Spider |
RSV | Reserved |
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
File details
Details for the file IP2Location-8.6.4-py2.py3-none-any.whl
.
File metadata
- Download URL: IP2Location-8.6.4-py2.py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 433c9111a99617316f49dc78f08eb0e18b20264211051fc9bbd5ec98baaccf45 |
|
MD5 | f04fc5b5e7877102454b1a3bc215a1a1 |
|
BLAKE2b-256 | f06848d083aadc78bdd6d0d260ac4d50acfa38bc052f4bc560caa06be6fd2d9e |