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.
  'RISK_DATA' => 1, // 0 = Off, 1 = Risk Score (0-100), 2 = Risk Score & Attack History.
  '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', 'CN'), // Specify an array of countries or isocodes to be blocked.
  'ALLOWED_COUNTRIES' => array('Azeroth', 'US') // Specify an array of countries or isocodes to be allowed.
);
  
$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 and the documentation here

  • Utilises the latest v2 proxycheck.io API
  • Supports our status response codes
  • Supports all our query flags
  • Supports our Dashboard API's
  • Maven repo for easy PCM importing into your projects

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

Node.js

neo773 has created a free Node.js Library for integrating the proxycheck.io v2 API with your projects, it supports Typescript.. You can view the latest version on npm here and view the project on GitHub here.

PLASMAchicken has created a free Node.js Library for integrating the proxycheck.io v2 API with your projects. You can view the latest version on npm here and view the project on GitHub here.

Python

WardPearce has created a free python wrapper for integrating the proxycheck.io v2 API with your projects. You can view the latest version on GitHub here with documentation here.

Roxana has created a free python-based CLI for proxycheck.io's v2 API available for FreeBSD, Unix, Windows, Mac and Linux. You can view the source code on GitHub here and the latest compiled releases on GitHub here.

proxycheck-cli also supports managing your CloudFlare firewall via their API allowing you to check IP's with proxycheck and then add them to your CloudFlare firewall if desired.

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: 19th of November 2024
19th of November 2024
Added a new python command line application written for proxycheck.io by Roxanna Schram.
27th of June 2023
A new node.js library written by neo773 was added to this page.
10th of November 2021
The page theme was updated to our new Glass theme for both light and dark modes.
20th of August 2021
Updated the Java example tab as the library shown there has been updated with full Dashboard support and new URL's
10th of November 2020
Added a python wrapper written by WardPearce which has full v2 API support.
20th of August 2019
Added a new library for Node.js written by PLASMAchicken. Has full support for our v2 API and our Dashboard API's
27th of June 2019
Updated the composer code example to feature all the new option parameters such as our RISK_DATA and ALLOWED_COUNTRIES options.
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 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.