Display Visitor’s Proxy Using IP2Proxy Web Service

In this tutorial, we use the IP2Proxy™ Web Service to detect proxy details from the visitor’s IP address. Instead of loading the full database, you can also lookup IP address via our hosted web service.

IP2Proxy™ Web API uses a single web interface to perform the lookup logic. The protocol used is HTTP GET. You can test this API as easy as using a web browser.

api.ip2proxy.com/?ip=<ip_address>&key=<your_api_key>&package=<package>&format=<format>

 

PARAMETERS
Name Description
key (required) API key. Please use “demo” for evaluation.
ip (optional) IP address (IPv4) for lookup purpose. If not present, the server IP address will be used for the lookup.
package (optional) If not present, the web service will assume the PX1 package query. Valid value: PX1 | PX2 | PX3 | PX4 | PX5 | PX6 | PX7 | PX8
format (optional) If not present, json format will be returned as the search result. Valid value: json | xml

Below are the sample codes written in PHP to query and display user’s proxy information.

You are in local server!
';
        echo '';
    }
}else{
    echo 'IP Address parsing error!';
}
?>
Your IP address
Response:'."\n". $proxy['response'] . "\n
"; echo 'Country Code:'."\n". $proxy['countryCode'] . "\n
"; echo 'Country Name:'."\n". $proxy['countryName'] . "\n
"; echo 'Region Name:'."\n". $proxy['regionName'] . "\n
"; echo 'City Name:'."\n". $proxy['cityName'] . "\n
"; echo 'Internet Service Provider:'."\n". $proxy['isp'] . "\n
"; echo 'Is Proxy:'."\n". $proxy['isProxy'] . "\n
"; echo 'Proxy Type:'."\n". $proxy['proxyType'] . "\n
"; echo 'Domain:'."\n". $proxy['domain'] . "\n
"; echo 'Usage Type:'."\n". $proxy['usageType'] . "\n
"; echo 'ASN:'."\n". $proxy['asn'] . "\n
"; echo 'AS:'."\n". $proxy['as'] . "\n
"; echo 'Last Seen:'."\n". $proxy['lastSeen'] . "\n
"; }else{ echo 'IP Address parsing error!'; } ?>

 

Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    WebAPI()
End Sub
 
Private Sub WebAPI()
    Dim strQuery As String
    Dim IPAddress As String = HttpContext.Current.Request.UserHostAddress
    Dim Key As String = "demo"
    Dim serializer As New JavaScriptSerializer()
    Dim HttpWReq As HttpWebRequest
    Dim HttpWResp As Net.HttpWebResponse
 
    strQuery = "https://api.ip2proxy.com/?" & "ip=" & IPAddress & "&key=demo&package=PX8"
    HttpWReq = WebRequest.Create(strQuery)
    HttpWReq.Method = "GET"
    HttpWResp = HttpWReq.GetResponse()
 
    Dim reader As System.IO.StreamReader = New IO.StreamReader(HttpWResp.GetResponseStream())
    Dim content As String = reader.ReadToEnd
    Dim item As Object = serializer.Deserialize(Of Object)(content)
    Dim city As String = item("cityName")
    Dim countryc As String = item("countryCode")
    Dim countryn As String = item("countryName")
    Dim region As String = item("regionName")
    Dim isp As String = item("isp")
    Dim isproxy As String = item("isProxy")
    Dim proxytype As String = item("proxyType")
    Dim domain As String = item("domain")
    Dim usagetype As String = item("usageType")
    Dim asn as String = item("asn")
    Dim [as] as String = item("as")
    Dim lastseen as String = item("lastSeen")
    Dim res As String = item("response")
 
    Response.Write("Welcome Visitors from " + city + "
") Response.Write("Response: " + res + "
") Response.Write("Your IP address: " + IPAddress + "
") Response.Write("Country Code: " + countryc + "
") Response.Write("Country Name: " + countryn + "
") Response.Write("Region Name: " + region + "
") Response.Write("ISP: " + isp + "
") Response.Write("Is Proxy: " + isproxy + "
") Response.Write("Proxy Type: " + proxytype + "
") Response.Write("Domain: " + domain + "
") Response.Write("Usage Type: " + usagetype + "
") Response.Write("ASN: " + asn + "
") Response.Write("AS: " + [as] + "
") Response.Write("Last Seen: " + lastseen + "
") End Sub Sub Main() WebAPI() End Sub

 

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        WebAPI();
    }
 
    private void WebAPI()
    {
        string myIP = HttpContext.Current.Request.UserHostAddress;
        string strQuery;
        string key = "demo";
        HttpWebRequest HttpWReq;
        HttpWebResponse HttpWResp;
        strQuery = "https://api.ip2proxy.com/?" + "ip=" + myIP + "&key=demo&package=PX8";
        JavaScriptSerializer serializer = new JavaScriptSerializer();
        dynamic item = serializer.Deserialize(content);
        HttpWReq = (HttpWebRequest)WebRequest.Create(strQuery);
        HttpWReq.Method = "GET";
        HttpWResp = (HttpWebResponse)HttpWReq.GetResponse();
        System.IO.StreamReader reader = new System.IO.StreamReader(HttpWResp.GetResponseStream());
        string content = reader.ReadToEnd();
 
        string city = item["cityName"];
        string countryc = item["countryCode"];
        string countryn = item["countryName"];
        string region = item["regionName"];
        string isp = item["isp"];
        string isproxy = item["isProxy"];
        string proxytype = item["proxyType"];
        string domain = item["domain"];
        string usagetype = item["usageType"];
        string asn = item["asn"];
        string @as = item["as"];
        string lastseen = item["lastSeen"];
        string res = item["response"];
 
        //displaying the result
        Response.Write("Welcome Visitors from " + city + "
"); Response.Write("Response: " + res + "
"); Response.Write("Your IP address: " + myIP + "
"); Response.Write("Country Code: " + countryc + "
"); Response.Write("Country Name: " + countryn + "
"); Response.Write("Region Name: " + region + "
"); Response.Write("Internet Service Provider: " + isp + "
"); Response.Write("Is Proxy: " + isproxy + "
"); Response.Write("Proxy Type: " + proxytype + "
"); Response.Write("Domain: " + domain + "
"); Response.Write("Usage Type: " + usagetype + "
"); Response.Write("ASN: " + asn + "
"); Response.Write("AS: " + @as + "
"); Response.Write("Last Seen: " + lastseen + "
"); } }

 

import java.io.BufferedReader;
import java.io.IOException;
import java.net.URL;
import com.google.gson.Gson;
 
public class System
{
    public static void main(String[] args) throws Exception
    {
        Gson gson = new Gson();
        String myIP = Request.UserHostAddress;
        String json = readURL("https://api.ip2proxy.com/?" + "ip=" + myIP + "&key=demo&package=PX8");
        System.out.println(json);
 
        Map< String, Object > decoded = gson.fromJson(
            json,
            new TypeToken< Map< String, Object>>() {}.getType());
        System.out.println( decoded );
 
        //displaying the result
        Display disp = gson.fromJson(json, Display.class);
        System.out.println("Welcome Visitors from " + disp.cityName + "
"); System.out.println("Response: " + disp.response + "
"); System.out.println("Your IP address: " + myIP + "
"); System.out.println("Country Code: " + disp.countryCode + "
"); System.out.println("Country Name: " + disp.countryName + "
"); System.out.println("Region Name: " + disp.regionName + "
"); System.out.println("Internet Service Provider: " + disp.isp + "
"); System.out.println("Is Proxy: " + disp.isProxy + "
"); System.out.println("Proxy Type: " + disp.proxyType + "
"); System.out.println("Domain: " + disp.domain + "
"); System.out.println("Usage Type: " + disp.usageType + "
"); System.out.println("ASN: " + disp.asn + "
"); System.out.println("AS: " + disp.as + "
"); System.out.println("Last Seen: " + disp.lastSeen + "
"); } static class Display { String cityName; String countryCode; String countryName; String regionName; String isp; String isProxy; String proxyType; String domain; String usageType; String asn; String as; String lastSeen; String response; } }

 

 

Was this article helpful?

Related Articles