1.0.4 • Published 8 months ago

ip2location-io-nodejs v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

npm npm

IP2Location.io Node.js SDK

This Node.js module enables user to query for an enriched data set, such as country, region, district, 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 at https://www.ip2location.io/pricing.

Installation

npm install ip2location-io-nodejs

Usage Example

Lookup IP Address Geolocation Data

import ip2locationio from "ip2location-io-nodejs";

// Configures IP2Location.io API key
let mykey = "YOUR_API_KEY";
let config = new ip2locationio.Configuration(mykey);

let ipl = new ip2locationio.IPGeolocation(config);

let myip = "8.8.8.8";
let lang = "en"; // language parameter is only available for Plus and Security plans

// Lookup ip address geolocation data
ipl.lookup(myip, lang)
  .then((data) => {
    // print the data in json format
    console.log(data)
  })
  .catch((error) => {
    // print the error
    console.log(error)
  });

Lookup Domain Information

import ip2locationio from "ip2location-io-nodejs";

// Configures IP2Location.io API key
let mykey = "YOUR_API_KEY";
let config = new ip2locationio.Configuration(mykey);

let whois = new ip2locationio.DomainWhois(config);

let mydomain = "locaproxy.com";

// Lookup domain information
whois.lookup(mydomain)
  .then((data) => {
    // print the data in json format
    console.log(data)
  })
  .catch((error) => {
    // print the error
    console.log(error)
  });

Convert Normal Text to Punycode

import ip2locationio from "ip2location-io-nodejs";

let config = new ip2locationio.Configuration();
let whois = new ip2locationio.DomainWhois(config);

// Convert normal text to punycode
console.log(whois.getPunycode("täst.de"));

Convert Punycode to Normal Text

import ip2locationio from "ip2location-io-nodejs";

let config = new ip2locationio.Configuration();
let whois = new ip2locationio.DomainWhois(config);

// Convert punycode to normal text
console.log(whois.getNormalText("xn--tst-qla.de"));

Get Domain Name

import ip2locationio from "ip2location-io-nodejs";

let config = new ip2locationio.Configuration();
let whois = new ip2locationio.DomainWhois(config);

// Get domain name from URL
console.log(whois.getDomainName("https://www.example.com/exe"));

Get Domain Extension

import ip2locationio from "ip2location-io-nodejs";

let config = new ip2locationio.Configuration();
let whois = new ip2locationio.DomainWhois(config);

// Get domain extension (gTLD or ccTLD) from URL or domain name
console.log(whois.getDomainExtension("example.com"));

Response Parameter

IP Geolocation Lookup function

ParameterTypeDescription
ipstringIP 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/T1
idd_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.
districtstringDistrict or county name.
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.
proxy.is_vpnbooleanAnonymizing VPN services.
proxy.is_torbooleanTor Exit Nodes.
proxy.is_data_centerbooleanHosting Provider, Data Center or Content Delivery Network.
proxy.is_public_proxybooleanPublic Proxies.
proxy.is_web_proxybooleanWeb Proxies.
proxy.is_web_crawlerbooleanSearch Engine Robots.
proxy.is_residential_proxybooleanResidential proxies.
proxy.is_spammerbooleanEmail and forum spammers.
proxy.is_scannerbooleanNetwork security scanners.
proxy.is_botnetbooleanMalware infected devices.
{
  "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": "es",
      "value": "Norteamérica"
    }
  },
  "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": "es",
      "value": "Estados Unidos de América (los)"
    }
  },
  "region": {
    "name": "California",
    "code": "US-CA",
    "translation": {
      "lang": "es",
      "value": "California"
    }
  },
  "city": {
    "name": "Mountain View",
    "translation": {
      "lang": null,
      "value": null
    }
  },
  "time_zone_info": {
    "olson": "America/Los_Angeles",
    "current_time": "2023-09-03T18:21:13-07:00",
    "gmt_offset": -25200,
    "is_dst": true,
    "sunrise": "06:41",
    "sunset": "19:33"
  },
  "geotargeting": {
    "metro": "807"
  },
  "ads_category": "IAB19-11",
  "ads_category_name": "Data Centers",
  "is_proxy": false,
  "proxy": {
    "last_seen": 3,
    "proxy_type": "DCH",
    "threat": "-",
    "provider": "-",
    "is_vpn": false,
    "is_tor": false,
    "is_data_center": true,
    "is_public_proxy": false,
    "is_web_proxy": false,
    "is_web_crawler": false,
    "is_residential_proxy": false,
    "is_spammer": false,
    "is_scanner": false,
    "is_botnet": false
  }
}

Domain WHOIS Lookup function

ParameterTypeDescription
domainstringDomain 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.
nameserversarrayName servers
{
    "domain": "locaproxy.com",
    "domain_id": "1710914405_DOMAIN_COM-VRSN",
    "status": "clientTransferProhibited https://icann.org/epp#clientTransferProhibited",
    "create_date": "2012-04-03T02:34:32Z",
    "update_date": "2021-12-03T02:54:57Z",
    "expire_date": "2024-04-03T02:34:32Z",
    "domain_age": 3863,
    "whois_server": "whois.godaddy.com",
    "registrar": {
        "iana_id": "146",
        "name": "GoDaddy.com, LLC",
        "url": "https://www.godaddy.com"
    },
    "registrant": {
        "name": "Registration Private",
        "organization": "Domains By Proxy, LLC",
        "street_address": "DomainsByProxy.com",
        "city": "Tempe",
        "region": "Arizona",
        "zip_code": "85284",
        "country": "US",
        "phone": "+1.4806242599",
        "fax": "+1.4806242598",
        "email": "Select Contact Domain Holder link at https://www.godaddy.com/whois/results.aspx?domain=LOCAPROXY.COM"
    },
    "admin": {
        "name": "Registration Private",
        "organization": "Domains By Proxy, LLC",
        "street_address": "DomainsByProxy.com",
        "city": "Tempe",
        "region": "Arizona",
        "zip_code": "85284",
        "country": "US",
        "phone": "+1.4806242599",
        "fax": "+1.4806242598",
        "email": "Select Contact Domain Holder link at https://www.godaddy.com/whois/results.aspx?domain=LOCAPROXY.COM"
    },
    "tech": {
        "name": "Registration Private",
        "organization": "Domains By Proxy, LLC",
        "street_address": "DomainsByProxy.com",
        "city": "Tempe",
        "region": "Arizona",
        "zip_code": "85284",
        "country": "US",
        "phone": "+1.4806242599",
        "fax": "+1.4806242598",
        "email": "Select Contact Domain Holder link at https://www.godaddy.com/whois/results.aspx?domain=LOCAPROXY.COM"
    },
    "billing": {
        "name": "",
        "organization": "",
        "street_address": "",
        "city": "",
        "region": "",
        "zip_code": "",
        "country": "",
        "phone": "",
        "fax": "",
        "email": ""
    },
    "nameservers": ["vera.ns.cloudflare.com", "walt.ns.cloudflare.com"]
}

LICENCE

See the LICENSE file.

1.0.4

8 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago