code examples / proxycheck.io

Below you'll find code examples written by both us and 3rd party developers which enable you to integrate the proxycheck.io API with your software and services. If you've written a publicly available implementation of the proxycheck.io API such as a code example, function, class or plugin please contact us and we'll be happy to include it below. You can find ready to use plugins on our plugins page.


PHP Code

If you don't want to use the Composer library at all and instead would prefer a basic function we have provided that here on our GitHub page.

Below is the install command for our composer library. You can find the instructions for using the library here on GitHub.

composer require proxycheck/proxycheck-php

Below is an example calling the library and retrieving the result of the query into an array.

// Get your visitors IP Address
// If you're using CloudFlare change $_SERVER["REMOTE_ADDR"] to $_SERVER["HTTP_CF_CONNECTING_IP"]
$ip = $_SERVER["REMOTE_ADDR"];

// Input your options for this query including your optional API Key and query flags.
$proxycheck_options = array(
  'API_KEY' => '######-######-######-######', // Your API Key.
  'ASN_DATA' => 1, // Enable ASN data response.
  'DAY_RESTRICTOR' => 7, // Restrict checking to proxies seen in the past # of days.
  'VPN_DETECTION' => 1, // Check for both VPN's and Proxies instead of just Proxies.
  'INF_ENGINE' => 1, // Enable or disable the real-time inference engine.
  'TLS_SECURITY' => 0, // Enable or disable transport security (TLS).
  'QUERY_TAGGING' => 1, // Enable or disable query tagging.
  'CUSTOM_TAG' => '', // Specify a custom query tag instead of the default (Domain+Page).
  'BLOCKED_COUNTRIES' => array('Wakanda', 'Mordor') // Specify an array of countries to be blocked.
);
  
$result_array = \proxycheck\proxycheck::check($ip, $proxycheck_options);

The above library supports all of our API features which includes all of our query flags and custom query tagging. We've also added library-side country blocking so you can use the API as a country blocking system aswell. You can view its dedicated page which includes full instructions here at packagist.org

If you don't want to use composer you can instead install the library yourself manually from our github page here where you will also find the instructions for using the library.

curl

Accessing our API through curl either by commandline or within a language such as PHP is very easy. All our API responses are in JSON so you will need to parse those responses but you can call our API from curl with the command below.

$ curl "http://proxycheck.io/v2/8.8.8.8"

When you do so you should receive a response like so:

{
    "8.8.8.8": {
        "proxy": "no",
        "provider": "GOOGLE - Google LLC, US"
    }
}
C# Code

Developer hollow87 has made available a nuget package for proxycheck.io at nuget.org available here thanks hollow87! - We've included some install commands for popular clients below for your convenience.

Install-Package ProxyCheck
dotnet add package ProxyCheck
paket add ProxyCheck

Java

DefianceCoding has created a free Java API and example classes for creating Java plugins and applets that integrates the proxycheck.io v2 API. You can view the latest version of PCDetectionAPI on GitHub here

  • Utilises the latest v2 proxycheck.io API
  • Supports our status response codes
  • Supports all our query flags

If you need support or have found a bug you can email DefianceCoding at [email protected] or on Discord here

Node.js

Accessing the API with Node.js is very easy as shown by the code snippet below.

const request = require('request')

request('http://proxycheck.io/v2/8.8.8.8', function(error, res, body) {
  console.log(JSON.parse(body))
})

When you do so you should receive a response like so:

{
    "8.8.8.8": {
        "proxy": "no",
        "provider": "GOOGLE - Google LLC, US"
    }
}
Python

Accessing the API with Python is very easy as shown by the code snippet below.

requests.get('http://proxycheck.io/v2/8.8.8.8')

When you do so you should receive a JSON response that you will need to parse like so:

{
    "8.8.8.8": {
        "proxy": "no",
        "provider": "GOOGLE - Google LLC, US"
    }
}
Ruby on Rails

Jonathan has been kind enough to create a gem for utilising the proxycheck.io API and you can find it on the rubygems.org website here thanks jonathan! - We've included the gem install command below for your convenience.

gem install proxycheck

Below we've included a simple way to query the API with Ruby.

require 'json'
require 'open-uri'

JSON.parse(open('http://proxycheck.io/v2/8.8.8.8').read)

When you do so you should receive a JSON response like so:

{
    "8.8.8.8": {
        "proxy": "no",
        "provider": "GOOGLE - Google LLC, US"
    }
}

Back
Last Update: 22nd of December 2018
22nd of December 2018
Updated the C# code example from hollow87 which now includes v2 API support in its latest 2.0.0 release.
24th of July 2018
Added a new Java tab which includes a new Java API from DefianceCoding.
1st of July 2018
Moved around the position of our Basic PHP Function so it's more visible for users who just want to use that instead of our Composer library.
9th of June 2018
Added composer install instructions to the PHP example code tab. Removed our basic PHP example and replaced it with a link to our PHP function.
2nd of January 2018
Most example code was updated to use the new v2 API and the CSS styling was updated.
10th of November 2017
New examples were added for curl, Node.js, Python and Ruby, layouts were also updated.
13th of September 2017
The page apperance was updated with a new tab view for the different examples, this is getting ready for a wider selection of examples coming soon. A C# example was also added.
26th of June 2017
Three new minecraft plugins were added to the page.
25th of May 2017
The PHP Example was updated to include our new query tagging feature.
7th of April 2017
A better PHP example utilising functions and curl on GitHub was linked to from this page.
1st of April 2017
Information about a 3rd party Minecraft plugin which uses our API was added to the page.