Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including ip2proxy-nodejs with all npm packages installed. Try it out:

var ip2proxyNodejs = require("ip2proxy-nodejs")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

ip2proxy-nodejs v2.2.0

IP2Proxy proxy detection component

IP2Proxy Node.js Module

This module allows user to query an IP address if it was being used as VPN anonymizer, open proxies, web proxies, Tor exits, data center, web hosting (DCH) range and search engine robots (SES). It lookup the proxy IP address from IP2Proxy BIN Data file. This data file can be downloaded at

  • Free IP2Proxy BIN Data: https://lite.ip2location.com
  • Commercial IP2Proxy BIN Data: https://www.ip2location.com/database/ip2proxy

Installation

To install this module type the following:


npm install ip2proxy-nodejs

Methods

Below are the methods supported in this class.

Method NameDescription
OpenOpen the IP2Proxy BIN data for lookup.
CloseClose and clean up the file pointer.
getPackageVersionGet the package version (1 to 8 for PX1 to PX8 respectively).
getModuleVersionGet the module version.
getDatabaseVersionGet the database version.
isProxyCheck whether if an IP address was a proxy. Returned value:
  • -1 : errors
  • 0 : not a proxy
  • 1 : a proxy
  • 2 : a data center IP address or search engine robot
getAllReturn the proxy information in an object.
getProxyTypeReturn the proxy type. Please visit IP2Location for the list of proxy types supported
getCountryShortReturn the ISO3166-1 country code (2-digits) of the proxy.
getCountryLongReturn the ISO3166-1 country name of the proxy.
getRegionReturn the ISO3166-2 region name of the proxy. Please visit ISO3166-2 Subdivision Code for the information of ISO3166-2 supported
getCityReturn the city name of the proxy.
getISPReturn the ISP name of the proxy.
getDomainReturn the domain name of the proxy.
getUsageTypeReturn the usage type classification of the proxy. Please visit IP2Location for the list of usage types supported.
getASNReturn the autonomous system number of the proxy.
getASReturn the autonomous system name of the proxy.
getLastSeenReturn the number of days that the proxy was last seen.

Usage


var ip2proxy = require("ip2proxy-nodejs");

if (ip2proxy.Open("./IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN.BIN") == 0) {
    ip = '199.83.103.79';
    
    console.log("GetModuleVersion: " + ip2proxy.getModuleVersion());
    console.log("GetPackageVersion: " + ip2proxy.getPackageVersion());
    console.log("GetDatabaseVersion: " + ip2proxy.getDatabaseVersion());
    
    // functions for individual fields
    console.log("isProxy: " + ip2proxy.isProxy(ip));
    console.log("ProxyType: " + ip2proxy.getProxyType(ip));
    console.log("CountryShort: " + ip2proxy.getCountryShort(ip));
    console.log("CountryLong: " + ip2proxy.getCountryLong(ip));
    console.log("Region: " + ip2proxy.getRegion(ip));
    console.log("City: " + ip2proxy.getCity(ip));
    console.log("ISP: " + ip2proxy.getISP(ip));
    console.log("Domain: " + ip2proxy.getDomain(ip));
    console.log("UsageType: " + ip2proxy.getUsageType(ip));
    console.log("ASN: " + ip2proxy.getASN(ip));
    console.log("AS: " + ip2proxy.getAS(ip));
    console.log("LastSeen: " + ip2proxy.getLastSeen(ip));
    
    // function for all fields
    var all = ip2proxy.getAll(ip);
    console.log("isProxy: " + all.Is_Proxy);
    console.log("ProxyType: " + all.Proxy_Type);
    console.log("CountryShort: " + all.Country_Short);
    console.log("CountryLong: " + all.Country_Long);
    console.log("Region: " + all.Region);
    console.log("City: " + all.City);
    console.log("ISP: " + all.ISP);
    console.log("Domain: " + all.Domain);
    console.log("UsageType: " + all.Usage_Type);
    console.log("ASN: " + all.ASN);
    console.log("AS: " + all.AS);
    console.log("LastSeen: " + all.Last_Seen);
}
else {
    console.log("Error reading BIN file.");
}
ip2proxy.Close();

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free