npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ip2proxy-nodejs

v4.3.2

Published

IP2Proxy proxy detection component

Downloads

2,225

Readme

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

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

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 Name|Description| |---|---| |open|Open the IP2Proxy BIN data for lookup.| |openAsync|Open the IP2Proxy BIN data for lookup asynchronously.| |close|Close and clean up the file pointer.| |getPackageVersion|Get the package version (1 to 11 for PX1 to PX11 respectively).| |getModuleVersion|Get the module version.| |getDatabaseVersion|Get the database version.| |isProxy|Check 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| |isProxyAsync|Check 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| |getAll|Return the proxy information in an object.| |getAllAsync|Return the proxy information in an object asynchronously.| |getProxyType|Return the proxy type. Please visit IP2Location for the list of proxy types supported| |getProxyTypeAsync|Return the proxy type asynchronously. Please visit IP2Location for the list of proxy types supported| |getCountryShort|Return the ISO3166-1 country code (2-digits) of the proxy.| |getCountryShortAsync|Return the ISO3166-1 country code (2-digits) of the proxy asynchronously.| |getCountryLong|Return the ISO3166-1 country name of the proxy.| |getCountryLongAsync|Return the ISO3166-1 country name of the proxy asynchronously.| |getRegion|Return the ISO3166-2 region name of the proxy. Please visit ISO3166-2 Subdivision Code for the information of ISO3166-2 supported| |getRegionAsync|Return the ISO3166-2 region name of the proxy asynchronously. Please visit ISO3166-2 Subdivision Code for the information of ISO3166-2 supported| |getCity|Return the city name of the proxy.| |getCityAsync|Return the city name of the proxy asynchronously.| |getISP|Return the ISP name of the proxy.| |getISPAsync|Return the ISP name of the proxy asynchronously.| |getDomain|Return the domain name of the proxy.| |getDomainAsync|Return the domain name of the proxy asynchronously.| |getUsageType|Return the usage type classification of the proxy. Please visit IP2Location for the list of usage types supported.| |getUsageTypeAsync|Return the usage type classification of the proxy asynchronously. Please visit IP2Location for the list of usage types supported.| |getASN|Return the autonomous system number of the proxy.| |getASNAsync|Return the autonomous system number of the proxy asynchronously.| |getAS|Return the autonomous system name of the proxy.| |getASAsync|Return the autonomous system name of the proxy asynchronously.| |getLastSeen|Return the number of days that the proxy was last seen.| |getLastSeenAsync|Return the number of days that the proxy was last seen asynchronously.| |getThreat|Return the threat type of the proxy.| |getThreatAsync|Return the threat type of the proxy asynchronously.| |getProvider|Return the provider of the proxy.| |getProviderAsync|Return 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();

Asynchronous 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 Name|Description| |---|---| |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 Type|Description| |---|---| |VPN|Anonymizing VPN services| |TOR|Tor Exit Nodes| |PUB|Public Proxies| |WEB|Web Proxies| |DCH|Hosting Providers/Data Center| |SES|Search Engine Robots| |RES|Residential Proxies [PX10+]|

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|

Threat Type

|Threat Type|Description| |---|---| |SPAM|Spammer| |SCANNER|Security Scanner or Attack| |BOTNET|Spyware or Malware|