Skip to main content

IP2Location 8.6.2

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

  1. Python 2.2 and above

Installation

  1. Unzip the package.
  2. Execute python setup.py build
  3. 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:
  1. IP2Location API Key.
  2. Package (WS1 - WS24)
  3. Use HTTPS or HTTP
lookup Return the IP information in array.
  • country_code
  • country_name
  • region_name
  • city_name
  • latitude
  • longitude
  • zip_code
  • time_zone
  • isp
  • domain
  • net_speed
  • idd_code
  • area_code
  • weather_station_code
  • weather_station_name
  • mcc
  • mnc
  • mobile_brand
  • elevation
  • usage_type
  • continent
    • name
    • code
    • hemisphere
    • translations
  • country
    • name
    • alpha3_code
    • numeric_code
    • demonym
    • flag
    • capital
    • total_area
    • population
    • currency
      • code
      • name
      • symbol
    • language
      • code
      • name
    • idd_code
    • tld
    • translations
  • region
    • name
    • code
    • translations
  • city
    • name
    • translations
  • geotargeting
    • metro
  • country_groupings
  • time_zone_info
    • olson
    • current_time
    • gmt_offset
    • is_dst
    • sunrise
    • sunset
    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

    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

    Release files for IP2Location 8.6.2

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

    Source distribution (sdist)

    Source distribution for IP2Location 8.6.2
    File Size Uploaded
    IP2Location-8.6.2.tar.gz 9.3 kB Details

    Built distribution (wheel)

    Table of built distributions (wheels) for IP2Location 8.6.2
    File Interpreter ABI Platform
    IP2Location-8.6.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

    Total release size: 18.6 kB

    Release files / IP2Location-8.6.2.tar.gz

    Download URL IP2Location-8.6.2.tar.gz
    Size 9.3 kB
    Tags Source
    SHA-256 checksum
    How to use checksums
    adcb230ff5290b0b75622fc95683226d0ee5ce3709be58092dd4fd76f3c455e3
    BLAKE2b-256 checksum
    How to use checksums
    015fb42bc393d0f4a2ff909e258e5d259be4cbac7c0733bcf173936d43d71dbc
    Upload date
    Uploaded using Trusted Publishing?
    What is trusted publishing?
    No
    Uploaded via twine/1.15.0 pkginfo/1.7.0 requests/2.25.1 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/2.7.13

    Release files / IP2Location-8.6.2-py2.py3-none-any.whl

    Download URL IP2Location-8.6.2-py2.py3-none-any.whl
    Size 9.2 kB
    Tags Python 2 Python 3
    SHA-256 checksum
    How to use checksums
    0da40264ccd6541d9a65f780c2bfd7f0a8095455392383ca47ae8ae0f4a7af6f
    BLAKE2b-256 checksum
    How to use checksums
    d793513316a298f74fb54d73b848e6dc5292f75d95f42367808185a7e0571d8a
    Upload date
    Uploaded using Trusted Publishing?
    What is trusted publishing?
    No
    Uploaded via twine/1.15.0 pkginfo/1.7.0 requests/2.25.1 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/2.7.13

    Release history Release notifications | RSS feed

    8.10.5

    2 release files

    8.10.3

    2 release files

    8.10.2

    2 release files

    8.10.0

    2 release files

    8.9.0

    2 release files

    8.8.1

    2 release files

    8.8.0

    2 release files

    8.7.4

    2 release files

    8.7.3

    2 release files

    8.7.2

    2 release files

    8.7.1

    2 release files

    8.7.0

    2 release files

    8.6.4

    1 release file

    8.6.3

    1 release file

    This release

    8.6.2 This release

    2 release files

    8.6.1

    2 release files

    8.6.0

    2 release files

    8.5.1

    2 release files

    8.5.0

    2 release files

    8.4.1

    2 release files

    8.4.0

    2 release files

    8.3.0

    2 release files

    8.2.2

    2 release files

    8.2.1

    2 release files

    8.2.0

    2 release files

    8.1.0

    2 release files

    8.0.3

    2 release files

    8.0.2

    1 release file

    8.0.1

    1 release file

    8.0.0

    1 release file

    7.0.4

    1 release file

    7.0.3

    1 release file

    7.0.2

    7.0.0

    1 release file

    6.0.0

    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