Proxy Detection Service

Identify traffic origins and enhance security with JWT-based insights.

Your Connection Snapshot

Fetching your connection details...

This information is determined by analyzing the IP address your request originated from. Learn more.

Introduction

The proxy-detection.cname.cloud service provides real-time insights into the origin of your web traffic. By analyzing IP addresses and integrating Cloudflare's advanced security data, it generates a JSON Web Token (JWT) containing detailed information about the request origin.

This service now leverages multiple detection methods:

  • ASN (Autonomous System Number) database classification
  • Cloudflare's proprietary VPN detection
  • TOR exit node identification
  • Open proxy detection
  • Anonymizer service detection

Key Benefits

  • Enhanced Security: Flag and rate-limit suspicious traffic with greater accuracy
  • Fraud Prevention: Identify users attempting to mask their location
  • Content Personalization: Customize experiences based on network type
  • Regulatory Compliance: Meet regional restrictions with greater confidence
  • Flexible Token Lifetime: Control TTL duration via query parameter for the core API.

Advanced Detection

Utilizes multiple data sources to provide higher accuracy in proxy identification, reducing both false positives and negatives.

Customizable TTL

Set your preferred token expiration time with the ?ttl= parameter on the core API, or via options in load.js.

Cloudflare Integration

Leverages Cloudflare's proprietary detection capabilities for VPNs, TOR, open proxies, and anonymizers.

The core of the service is a simple GET endpoint. For client-side web applications, we also offer load.js, an optional JavaScript utility to simplify the integration of these tokens into your frontend requests.

Core API Service: /get & /getToken

The fundamental way to use the Proxy Detection Service is by making a GET request to its endpoints. The /get endpoint returns full JSON details, while /getToken (and /getToken.json) provide just the token.

GET https://proxy-detection.cname.cloud/get
GET https://proxy-detection.cname.cloud/getToken
GET https://proxy-detection.cname.cloud/getToken.json

Request (for all Core API endpoints)

You can customize the token's expiration time with a query parameter:

TTL Parameter

ttl (Number, Optional)

Desired Time-To-Live for the generated JWT, in seconds. If not provided, the server uses a default TTL of 300 seconds (5 minutes).

Valid range: 30 to 86400 seconds (30 seconds to 24 hours)

Examples:
  • .../get?ttl=600 (10-min token)
  • .../getToken?ttl=3600 (1-hour token)

Response (from /get)

On success, the /get service returns a JSON object containing all detection data and the JWT token:


{
  "ip": "203.0.113.42",
  "asn": 15169,
  "companyName": "GOOGLE",
  "ipType": "Hosting",
  "isProxy": false,
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." 
}
      
Note on Token Integrity: All detection results are cryptographically signed inside the token field.
Important: The client making the request to the API is the one whose IP information will be embedded.

JWT Payload

The decoded JWT (token field value) will contain claims providing insights. Always verify the JWT's signature on your backend.

Example decoded payload with enhanced detection:


{
  "ip": "203.0.113.42",      // Client's IP Address
  "asn": 15169,              // Autonomous System Number
  "companyName": "GOOGLE",   // ASN Organization name
  "ipType": "Hosting",       // IP Type classification (Residential, VPN, Hosting, etc.)
  "isProxy": false,          // Boolean or null: true if proxy/VPN/Tor, false if not, null if uncertain
  "iat": 1678886400,         // Issued At timestamp
  "exp": 1678886700          // Expiration timestamp
}
      
Note: The isProxy field can be null (uncertain). Handle true, false, and null.

IP Type Classification

The ipType field can contain values like:

Residential
Home
Hosting
Data Center
CDN
CDN
VPN
VPN
TOR
TOR
OpenProxy
Public Proxy
Anonymizer
Anonymizer
Unknown
Unclassified

Token-Only Endpoints

The /getToken endpoint returns only the JWT token as plain text. The /getToken.json endpoint returns the JWT token in a JSON wrapper: {"token": "YOUR_JWT"}.

GET https://proxy-detection.cname.cloud/getToken?ttl=600
Content-Type: text/plain
Response: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

GET https://proxy-detection.cname.cloud/getToken.json?ttl=600
Content-Type: application/json
Response: {"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."}

Benefits of Direct API Usage

Client-Side Helper: load.js

For client-side web applications, load.js offers a convenient way to manage JWTs from the Proxy Detection API. It handles fetching, caching (in memory and localStorage), and respecting token Time-To-Live (TTL).

Note: The following guide describes load.js. Instantiation is synchronous, and token fetching is on-demand via the getToken() method. Automatic AJAX patching is now off by default.

How It Works

Usage

  1. Include the Script: Ensure load.js is available in your project.
    <script src="https://proxy-detection.cname.cloud/load.js" defer></script>
  2. Instantiate and Configure: In your JavaScript, create an instance of ProxyDetection, passing configuration options.
    // Example: In your main application script
    document.addEventListener('DOMContentLoaded', () => {
      const pdInstance = ProxyDetection({
        tokenRequestTtlSeconds: 600, // Request 10-minute tokens
        logConsoleMethod: 'info',    // 'none', 'log', 'info', 'debug'
        verboseLogging: false,
        patchGlobalAjax: false       // Default, explicitly shown
        // tokenEndpointBase: 'https://your-custom-proxy.com/get' // Optional: if self-hosting
      });
    
      // Now you can use pdInstance.getToken() when needed
    });
  3. Get and Use Tokens: Call pdInstance.getToken() when you need a token. This returns a Promise.
    // Example: Fetching a token to include in a header
    async function makeApiCallWithToken() {
      if (!window.pdInstance) { // Assuming pdInstance is made available globally or via module
        console.error("ProxyDetection instance not ready.");
        return;
      }
      try {
        const token = await pdInstance.getToken();
        if (token) {
          const response = await fetch('/api/some-data', {
            headers: {
              'X-Proxy-Token': token // Or your preferred header name
            }
          });
          const data = await response.json();
          console.log("Data with token:", data);
        } else {
          console.warn("No proxy token obtained. Making call without it or handling error.");
          // Potentially make the call without the token or show an error
        }
      } catch (error) {
        console.error("Error getting proxy token or making API call:", error);
      }
    }
    
  4. Manual AJAX Injection (if patchGlobalAjax: false): You are responsible for integrating the token into your requests. This is common when using libraries like HTMX or having fine-grained control.
    // Example with HTMX (see full HTMX example below)
    // In an HTMX event like htmx:configRequest:
    // e.detail.headers['YOUR-TOKEN-HEADER-NAME'] = await pdInstance.getToken(); 
    
  5. Using Automatic AJAX Patching (if patchGlobalAjax: true): If you enable automatic patching, load.js will attempt to replace a placeholder in your URLs.
    1. Set patchGlobalAjax: true during instantiation.
    2. Add your chosen placeholder (default: {PROXY_TOKEN}) to URLs in your AJAX calls or relevant HTML attributes that might trigger network requests via JavaScript (e.g., if a script dynamically sets an image src).
      // If patchGlobalAjax: true
      // fetch('/api/data?param=value&securityToken={PROXY_TOKEN}'); 
      // The {PROXY_TOKEN} will be replaced.
      // The placeholder string can be configured via options.placeholderQueryPart.
      

Configuration Options (Passed as an Object)

Configure ProxyDetection by passing an options object during instantiation:

const pd = ProxyDetection({ /* your options here */ });
Option KeyTypeDefaultDescription
tokenRequestTtlSecondsNumber300Requested JWT TTL in seconds (e.g., 600 for 10 minutes). This is passed to the token endpoint.
logConsoleMethodString'none'Logging level for the library: 'none', 'log', 'info', 'debug'.
verboseLoggingBooleanfalseSet to true for more detailed internal debug logs.
patchGlobalAjaxBooleanfalseIf true, attempts to patch global fetch and XMLHttpRequest to replace a URL placeholder with a token.
placeholderQueryPartString'{PROXY_TOKEN}'The placeholder string to look for in URLs if patchGlobalAjax is true.
tokenEndpointBaseString'https://proxy-detection.cname.cloud/get'The base URL to fetch the token from. Change if self-hosting or using a different endpoint. Note: load.js expects a JSON response with a "token" field from this endpoint.
tokenStorageKeyString'proxyInterceptorToken'LocalStorage key for the token.
tokenExpiryStorageKeyString'proxyInterceptorTokenExpiry'LocalStorage key for token expiry.
tokenRequestedTtlStorageKeyString'proxyInterceptorTokenReqTTL'LocalStorage key for the TTL that was requested for the stored token.

Example Instantiation with Options:


const proxyDetect = ProxyDetection({
  tokenRequestTtlSeconds: 900,      // Request 15-minute tokens
  logConsoleMethod: 'info',         // Show informational logs
  patchGlobalAjax: true,            // Enable automatic URL token replacement
  placeholderQueryPart: '{MY_TOKEN}'  // Use a custom placeholder
});

// Later, when you need it:
// proxyDetect.getToken().then(token => { /* ... */ });

// Or if patchGlobalAjax is true:
// fetch('/some/api?key={MY_TOKEN}');
      

The load.js library provides more control, clearly separating instantiation from token acquisition, and making automatic AJAX patching an explicit choice.

Cloudflare Integration

Our proxy detection service now leverages Cloudflare's advanced security capabilities to provide more accurate and comprehensive detection of various proxy types.

Enhanced Detection Capabilities

  • VPN Detection
  • TOR Exit Node Detection
  • Open Proxy Detection
  • Anonymizer Service Detection

Live Examples

These examples demonstrate how to use load.js. Httpbin.org is used as a generic echo endpoint.

Note: For these examples, patchGlobalAjax is set to false (its default) unless specified, so token injection is done manually.

Initializing ProxyDetection for examples...

Test Core API Directly (No load.js)

Fetch a token directly from the main API endpoint:

Raw Response from /get:

Click a button.

Using pdInstance.getToken()

Manually fetch a token using an instance of ProxyDetection.

Token from getToken():

Click the button.

Examples: Integrating Token into Requests

1. Manual Header Injection with fetch

Response from httpbin (Fetch GET, manual header):

Click the button.

2. Using HTMX with Manual Header Injection

This example demonstrates adding the token as a header in HTMX requests.

Loading...

Response from httpbin (HTMX GET, manual header):

Click the HTMX button.

3. Example with patchGlobalAjax: true

This example will instantiate a separate ProxyDetection instance with patchGlobalAjax: true to demonstrate automatic URL placeholder replacement.

Response from httpbin (Fetch GET, patched URL):

Click the button.
Note: If you run this example, the global fetch will be temporarily patched by this specific instance. Other examples on this page use an unpatched instance.

4. See Your Current Token Info (from load.js cache)

Click to see details of the currently cached token by the main example instance.