IPQS
Verifying Results

How to Verify Results

As security best practice, you should not trust any information in the client-side browser. To ensure that the user hasn't tampered with the results after passing through a JavaScript redirect. We offer a simple API that can retrieve the results server-side. Requests to this API and all reporting APIs will not consume an API lookup credit.

You'll need to use the Fetching Results code from the Device Fingerprint API documentation. This involves passing the device ID to your server via Ajax or appending the value to a hidden form element. Once you've successfully made the "Fetching Results" request, you can proceed to make a GET/POST request to the URL below. Replace "USER_IP_HERE" and "DEVICE_ID_HERE" with their respective values.

https://www.ipqualityscore.com/api/tracker/results/YOUR_API_KEY_HERE/USER_IP_HERE/DEVICE_ID_HERE

<?php
// Get the end user's IP.
$user_ip = $_SERVER['REMOTE_ADDR']; // $_SERVER['HTTP_CF_CONNECTING_IP'] if using cloudflare.

// Get the device ID from our device tracker request.
$device_id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
	
// Generate our URL.
$url = sprintf('https://www.ipqualityscore.com/api/tracker/results/%s/%s/%s', $api_key, $user_ip, $device_id);

// Get JSON result.
$json = file_get_contents($url);
	
// Decode the result
$result = json_decode($json, true);

if(isset($result['success']) && $result['success'] === true){
	if(isset($result['id'])){
		if($device_id === $result['id']){
			// Request was valid. You can also use $request['fraud_chance'] here.
		}
	}
} else {
	// Something went wrong.
}
# THIS SHOULD NEVER BE USED IN PRODUCTION AS IS!

# You may need to install Requests pip
# python -m pip install requests

from http.server import BaseHTTPRequestHandler, HTTPServer
import json
import requests

hostName = "localhost"
serverPort = 8080

class IPQS:
    key = "YOUR_API_KEY_HERE"

    def  device_fingerprint_verification(self, userIP: str, deviceID: str) -> dict:
        url = "https://www.ipqualityscore.com/api/tracker/results/%s/%s/%s" % (self.key)
        x = requests.get(url)
        return (json.loads(x.text))



class MyServer(BaseHTTPRequestHandler):
    """This is an example basic web server. we limited it to handle "/" path only."""

    def do_GET(self):
        if self.path == "/":
            ipqs = IPQS()
            print(ipqs.device_fingerprint_verification(self.client_address[0], "request_id"))
            self.send_response(200)
            self.send_header("Content-type", "text/html")
            self.end_headers()
            self.wfile.write(bytes("<body>", "utf-8"))

if __name__ == "__main__":        
    webServer = HTTPServer((hostName, serverPort), MyServer)
    print("Server started http://%s:%s" % (hostName, serverPort))

    try:
        webServer.serve_forever()
    except KeyboardInterrupt:
        pass

    webServer.server_close()
    print("Server stopped.")

Ready to eliminate fraud?

Start fighting fraud now with 1,000 Free Lookups!

We're happy to answer any questions or concerns.

Chat with our fraud detection experts any day of the week.

Call us at: (800) 713-2618