Package: ip2location-io
IP2Location.io Python SDKThis Python module enables user to query for an enriched data set, such as country, region, city, latitude & longitude, ZIP code, time zone, ASN, ISP, domain, net speed, IDD code, area code, weather station data, MNC, MCC, mobile brand, elevation, usage type, address type, advertisement category and proxy data with an IP address. It supports both IPv4 and IPv6 address lookup.In addition, this module provides WHOIS lookup api that helps users to obtain domain information, WHOIS record, by using a domain name. The WHOIS API returns a comprehensive WHOIS data such as creation date, updated date, expiration date, domain age, the contact information of the registrant, mailing address, phone number, email address, nameservers the domain is using and much more.This module requires API key to function. You may sign up for a free API key athttps://www.ip2location.io/pricing.Usage ExampleLookup IP Address Geolocation Dataimportip2locationio# Configures IP2Location.io API keyconfiguration=ip2locationio.Configuration('YOUR_API_KEY')ipgeolocation=ip2locationio.IPGeolocation(configuration)//Lookupipaddressgeolocationdata$ip2locationio->lookup('8.8.8.8','en');//ThelanguageparameterisonlyavailableforPlusandSecurityplanonly.Lookup Domain Informationimportip2locationio# Configures IP2Location.io API keyconfiguration=ip2locationio.Configuration('YOUR_API_KEY')domainwhois=ip2locationio.DomainWHOIS(configuration)# Lookup domain informationprint(domainwhois.lookup('example.com'))Convert Normal Text to Punycodeimportip2locationio# Configures IP2Location.io API keyconfiguration=ip2locationio.Configuration('YOUR_API_KEY')domainwhois=ip2locationio.DomainWHOIS(configuration)# Convert normal text to punycodeprint(domainwhois.getpunycode('tÃ¤st.de'))Convert Punycode to Normal Textimportip2locationio# Configures IP2Location.io API keyconfiguration=ip2locationio.Configuration('YOUR_API_KEY')domainwhois=ip2locationio.DomainWHOIS(configuration)# Convert punycode to normal textprint(domainwhois.getnormaltext('xn--tst-qla.de'))Get Domain Nameimportip2locationio# Configures IP2Location.io API keyconfiguration=ip2locationio.Configuration('YOUR_API_KEY')domainwhois=ip2locationio.DomainWHOIS(configuration)# Get domain name from URLprint(domainwhois.getdomainname('https://www.example.com/exe'))Get Domain Extensionimportip2locationio# Configures IP2Location.io API keyconfiguration=ip2locationio.Configuration('YOUR_API_KEY')domainwhois=ip2locationio.DomainWHOIS(configuration)# Get domain extension (gTLD or ccTLD) from URL or domain nameprint(domainwhois.getdomainextension('example.com'))Response ParameterIP Geolocation Lookup functionParameterTypeDescriptionipstringIP address.country_codestringTwo-character country code based on ISO 3166.country_namestringCountry name based on ISO 3166.region_namestringRegion or state name.city_namestringCity name.latitudedoubleCity latitude. Defaults to capital city latitude if city is unknown.longitudedoubleCity longitude. Defaults to capital city longitude if city is unknown.zip_codestringZIP/Postal code.time_zonestringUTC time zone (with DST supported).asnstringAutonomous system number (ASN).asstringAutonomous system (AS) name.ispstringInternet Service Provider or company's name.domainstringInternet domain name associated with IP address range.net_speedstringInternet connection type. DIAL = dial-up, DSL = broadband/cable/fiber/mobile, COMP = company/T1idd_codestringThe IDD prefix to call the city from another country.area_codestringA varying length number assigned to geographic areas for calls between cities.weather_station_codestringThe special code to identify the nearest weather observation station.weather_station_namestringThe name of the nearest weather observation station.mccstringMobile Country Codes (MCC) as defined in ITU E.212 for use in identifying mobile stations in wireless telephone networks, particularly GSM and UMTS networks.mncstringMobile Network Code (MNC) is used in combination with a Mobile Country Code (MCC) to uniquely identify a mobile phone operator or carrier.mobile_brandstringCommercial brand associated with the mobile carrier.elevationintegerAverage height of city above sea level in meters (m).usage_typestringUsage type classification of ISP or company.address_typestringIP address types as defined in Internet Protocol version 4 (IPv4) and Internet Protocol version 6 (IPv6).continent.namestringContinent name.continent.codestringTwo-character continent code.continent.hemispherearrayThe hemisphere of where the country located. The data in array format with first item indicates (north/south) hemisphere and second item indicates (east/west) hemisphere information.continent.translationobjectTranslation data based on the given lang code.country.namestringCountry name based on ISO 3166.country.alpha3_codestringThree-character country code based on ISO 3166.country.numeric_codestringThree-character country numeric code based on ISO 3166.country.demonymstringNative of the country.country.flagstringURL of the country flag image.country.capitalstringCapital of the country.country.total_areaintegerTotal area in km2.country.populationintegerPopulation of the country.country.currencyobjectCurrency of the country.country.languageobjectLanguage of the country.country.tldstringCountry-Code Top-Level Domain.country.translationobjectTranslation data based on the given lang code.region.namestringRegion or state name.region.codestringISO3166-2 code.region.translationobjectTranslation data based on the given lang code.city.namestringCity name.city.translationobjectTranslation data based on the given lang code.time_zone_info.olsonstringTime zone in Olson format.time_zone_info.current_timestringCurrent time in ISO 8601 format.time_zone_info.gmt_offsetintegerGMT offset value in seconds.time_zone_info.is_dstbooleanIndicate if the time zone value is in DST.time_zone_info.sunrisestringTime of sunrise. (hh:mm format in local time, i.e, 07:47)time_zone_info.sunsetstringTime of sunset. (hh:mm format in local time, i.e 19:50)geotargeting.metrostringMetro code based on zip/postal code.ads_categorystringThe domain category code based on IAB Tech Lab Content Taxonomy.ads_category_namestringThe domain category based on IAB Tech Lab Content Taxonomy. These categories are comprised of Tier-1 and Tier-2 (if available) level categories widely used in services like advertising, Internet security and filtering appliances.is_proxybooleanWhether is a proxy or not.proxy.last_seenintegerProxy last seen in days.proxy.proxy_typestringType of proxy.proxy.threatstringSecurity threat reported.proxy.providerstringName of VPN provider if available.{'ip':'8.8.8.8','country_code':'US','country_name':'United States of America','region_name':'California','city_name':'Mountain View','latitude':37.405992,'longitude':-122.078515,'zip_code':'94043','time_zone':'-07:00','asn':'15169','as':'Google LLC','isp':'Google LLC','domain':'google.com','net_speed':'T1','idd_code':'1','area_code':'650','weather_station_code':'USCA0746','weather_station_name':'Mountain View','mcc':'-','mnc':'-','mobile_brand':'-','elevation':32,'usage_type':'DCH','address_type':'Anycast','continent':{'name':'North America','code':'NA','hemisphere':['north','west'],'translation':{'lang':None,'value':None}},'district':'Santa Clara County','country':{'name':'United States of America','alpha3_code':'USA','numeric_code':840,'demonym':'Americans','flag':'https://cdn.ip2location.io/assets/img/flags/us.png','capital':'Washington, D.C.','total_area':9826675,'population':331002651,'currency':{'code':'USD','name':'United States Dollar','symbol':'$'},'language':{'code':'EN','name':'English'},'tld':'us','translation':{'lang':None,'value':None}},'region':{'name':'California','code':'US-CA','translation':{'lang':'','value':''}},'city':{'name':'Mountain View','translation':{'lang':None,'value':None}},'time_zone_info':{'olson':'America/Los_Angeles','current_time':'2023-05-03T01:09:59-07:00','gmt_offset':-25200,'is_dst':True,'sunrise':'06:10','sunset':'19:59'},'geotargeting':{'metro':'807'},'ads_category':'IAB19-11','ads_category_name':'Data Centers','is_proxy':False,'proxy':{'last_seen':2,'proxy_type':'DCH','threat':'-','provider':'-'}}Domain WHOIS Lookup functionParameterTypeDescriptiondomainstringDomain name.domain_idstringDomain name ID.statusstringDomain name status.create_datestringDomain name creation date.update_datestringDomain name updated date.expire_datestringDomain name expiration date.domain_ageintegerDomain name age in day(s).whois_serverstringWHOIS server name.registrar.iana_idstringRegistrar IANA ID.registrar.namestringRegistrar name.registrar.urlstringRegistrar URL.registrant.namestringRegistrant name.registrant.organizationstringRegistrant organization.registrant.street_addressstringRegistrant street address.registrant.citystringRegistrant city.registrant.regionstringRegistrant region.registrant.zip_codestringRegistrant ZIP Code.registrant.countrystringRegistrant country.registrant.phonestringRegistrant phone number.registrant.faxstringRegistrant fax number.registrant.emailstringRegistrant email address.admin.namestringAdmin name.admin.organizationstringAdmin organization.admin.street_addressstringAdmin street address.admin.citystringAdmin city.admin.regionstringAdmin region.admin.zip_codestringAdmin ZIP Code.admin.countrystringAdmin country.admin.phonestringAdmin phone number.admin.faxstringAdmin fax number.admin.emailstringAdmin email address.tech.namestringTech name.tech.organizationstringTech organization.tech.street_addressstringTech street address.tech.citystringTech city.tech.regionstringTech region.tech.zip_codestringTech ZIP Code.tech.countrystringTech country.tech.phonestringTech phone number.tech.faxstringTech fax number.tech.emailstringTech email address.billing.namestringBilling name.billing.organizationstringBilling organization.billing.street_addressstringBilling street address.billing.citystringBilling city.billing.regionstringBilling region.billing.zip_codestringBilling ZIP Code.billing.countrystringBilling country.billing.phonestringBilling phone number.billing.faxstringBilling fax number.billing.emailstringBilling email address.name_serversarrayName servers{'domain':'example.com','domain_id':'2336799_DOMAIN_COM-VRSN','status':'clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited','create_date':'1995-08-14T04:00:00Z','update_date':'2022-08-14T07:01:31Z','expire_date':'2023-08-13T04:00:00Z','domain_age':10124,'whois_server':'whois.iana.org','registrar':{'iana_id':'376','name':'RESERVED-Internet Assigned Numbers Authority','url':'http://res-dom.iana.org'},'registrant':{'name':'','organization':'','street_address':'','city':'','region':'','zip_code':'','country':'','phone':'','fax':'','email':''},'admin':{'name':'','organization':'','street_address':'','city':'','region':'','zip_code':'','country':'','phone':'','fax':'','email':''},'tech':{'name':'','organization':'','street_address':'','city':'','region':'','zip_code':'','country':'','phone':'','fax':'','email':''},'billing':{'name':'','organization':'','street_address':'','city':'','region':'','zip_code':'','country':'','phone':'','fax':'','email':''},'nameservers':['a.iana-servers.net','b.iana-servers.net']}LICENCESee the LICENSE file.