4.3.0 • Published 8 months ago

ip2proxy-nodejs v4.3.0

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

npm npm

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, search engine robots (SES) and residential (RES). It lookup the proxy IP address from IP2Proxy BIN Data file. This data file can be downloaded at

As an alternative, this module can also call the IP2Proxy Web Service. This requires an API key. If you don't have an existing API key, you can subscribe for one at the below:

https://www.ip2location.com/web-service/ip2proxy

Installation

To install this module type the following:

npm install ip2proxy-nodejs

QUERY USING THE BIN FILE

Methods

Below are the methods supported in this class.

Method NameDescription
openOpen the IP2Proxy BIN data for lookup.
openAsyncOpen the IP2Proxy BIN data for lookup asynchronously.
closeClose and clean up the file pointer.
getPackageVersionGet the package version (1 to 11 for PX1 to PX11 respectively).
getModuleVersionGet the module version.
getDatabaseVersionGet the database version.
isProxyCheck whether if an IP address was a proxy. Returned value:-1 : errors0 : not a proxy1 : a proxy2 : a data center IP address or search engine robot
isProxyAsyncCheck whether if an IP address was a proxy asynchronously. Returned value:-1 : errors0 : not a proxy1 : a proxy2 : a data center IP address or search engine robot
getAllReturn the proxy information in an object.
getAllAsyncReturn the proxy information in an object asynchronously.
getProxyTypeReturn the proxy type. Please visit IP2Location for the list of proxy types supported
getProxyTypeAsyncReturn the proxy type asynchronously. Please visit IP2Location for the list of proxy types supported
getCountryShortReturn the ISO3166-1 country code (2-digits) of the proxy.
getCountryShortAsyncReturn the ISO3166-1 country code (2-digits) of the proxy asynchronously.
getCountryLongReturn the ISO3166-1 country name of the proxy.
getCountryLongAsyncReturn the ISO3166-1 country name of the proxy asynchronously.
getRegionReturn the ISO3166-2 region name of the proxy. Please visit ISO3166-2 Subdivision Code for the information of ISO3166-2 supported
getRegionAsyncReturn the ISO3166-2 region name of the proxy asynchronously. Please visit ISO3166-2 Subdivision Code for the information of ISO3166-2 supported
getCityReturn the city name of the proxy.
getCityAsyncReturn the city name of the proxy asynchronously.
getISPReturn the ISP name of the proxy.
getISPAsyncReturn the ISP name of the proxy asynchronously.
getDomainReturn the domain name of the proxy.
getDomainAsyncReturn the domain name of the proxy asynchronously.
getUsageTypeReturn the usage type classification of the proxy. Please visit IP2Location for the list of usage types supported.
getUsageTypeAsyncReturn the usage type classification of the proxy asynchronously. Please visit IP2Location for the list of usage types supported.
getASNReturn the autonomous system number of the proxy.
getASNAsyncReturn the autonomous system number of the proxy asynchronously.
getASReturn the autonomous system name of the proxy.
getASAsyncReturn the autonomous system name of the proxy asynchronously.
getLastSeenReturn the number of days that the proxy was last seen.
getLastSeenAsyncReturn the number of days that the proxy was last seen asynchronously.
getThreatReturn the threat type of the proxy.
getThreatAsyncReturn the threat type of the proxy asynchronously.
getProviderReturn the provider of the proxy.
getProviderAsyncReturn the provider of the proxy asynchronously.

Usage

const {IP2Proxy} = require("ip2proxy-nodejs");

let ip2proxy = new IP2Proxy();

if (ip2proxy.open("./IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER.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));
	console.log("Threat: " + ip2proxy.getThreat(ip));
	console.log("Provider: " + ip2proxy.getProvider(ip));
	
	// function for all fields
	let all = ip2proxy.getAll(ip);
	console.log("isProxy: " + all.isProxy);
	console.log("proxyType: " + all.proxyType);
	console.log("countryShort: " + all.countryShort);
	console.log("countryLong: " + all.countryLong);
	console.log("region: " + all.region);
	console.log("city: " + all.city);
	console.log("isp: " + all.isp);
	console.log("domain: " + all.domain);
	console.log("usagetype: " + all.usageType);
	console.log("asn: " + all.asn);
	console.log("as: " + all.as);
	console.log("lastSeen: " + all.lastSeen);
	console.log("threat: " + all.threat);
	console.log("provider: " + all.provider);
}
else {
	console.log("Error reading BIN file.");
}
ip2proxy.close();

Asynchronously Usage

const {IP2Proxy} = require("ip2proxy-nodejs");

let ip2proxy = new IP2Proxy();

ip2proxy.openAsync("./IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER.BIN").then((status) => {
	if (status == 0) {
		ip = '199.83.103.79';
		ip2proxy.getAllAsync(ip).then(all => {
			console.log("isProxy: " + all.isProxy);
			console.log("proxyType: " + all.proxyType);
			console.log("countryShort: " + all.countryShort);
			console.log("countryLong: " + all.countryLong);
			console.log("region: " + all.region);
			console.log("city: " + all.city);
			console.log("isp: " + all.isp);
			console.log("domain: " + all.domain);
			console.log("usagetype: " + all.usageType);
			console.log("asn: " + all.asn);
			console.log("as: " + all.as);
			console.log("lastSeen: " + all.lastSeen);
			console.log("threat: " + all.threat);
			console.log("provider: " + all.provider);
		});
	}
	else {
		console.log("Error reading BIN.");
	}
});

QUERY USING THE IP2PROXY PROXY DETECTION WEB SERVICE

Methods

Below are the methods supported in this class.

Method NameDescription
open(apiKey, apiPackage, useSSL = true)Expects 2 or 3 input parameters:IP2Proxy API Key.Package (PX1 - PX11)Use HTTPS or HTTP
lookup(myIP, callback)Query IP address. This method returns an object containing the proxy info. countryCodecountryNameregionNamecityNameispdomainusageTypeasnaslastSeenthreatproxyTypeisProxyprovider
getCredit(callback)This method returns the web service credit balance in an object.

Usage

const {IP2ProxyWebService} = require("ip2proxy-nodejs");

let ws = new IP2ProxyWebService();

let ip = "8.8.8.8";
let apiKey = "YOUR_API_KEY";
let apiPackage = "PX11";
let useSSL = true;

ws.open(apiKey, apiPackage, useSSL);

ws.lookup(ip, (err, data) => {
	if (!err) {
		console.log(data);
		
		ws.getCredit((err, data) => {
			if (!err) {
				console.log(data);
			}
		});
	}
});

Proxy Type

Proxy TypeDescription
VPNAnonymizing VPN services
TORTor Exit Nodes
PUBPublic Proxies
WEBWeb Proxies
DCHHosting Providers/Data Center
SESSearch Engine Robots
RESResidential Proxies PX10+

Usage Type

Usage TypeDescription
COMCommercial
ORGOrganization
GOVGovernment
MILMilitary
EDUUniversity/College/School
LIBLibrary
CDNContent Delivery Network
ISPFixed Line ISP
MOBMobile ISP
DCHData Center/Web Hosting/Transit
SESSearch Engine Spider
RSVReserved

Threat Type

Threat TypeDescription
SPAMSpammer
SCANNERSecurity Scanner or Attack
BOTNETSpyware or Malware
4.3.0

8 months ago

4.2.3

9 months ago

4.2.2

1 year ago

4.2.1

2 years ago

4.2.0

2 years ago

4.1.0

2 years ago

4.0.0

3 years ago

3.1.0

3 years ago

3.0.0

4 years ago

2.3.0

4 years ago

2.2.0

4 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago