- About the IPQS APIs
- Proxy & VPN Detection API
- Email Verification API
- Phone Number Validation API
- Malicious URL Scanner API
- Device Fingerprint API
- Mobile Device Fingerprinting SDK
- Gaming Fraud Detection SDK
- Dark Web Leak API
- Malware File Scanner API
- Request List API
- Fraud Reporting API
- Account Management APIs
- Bulk Validation CSV
- Allowlist Blocklist APIs
- Plugins Platforms Integrations
- IP Reputation Database
- IP Address Abuse Feed
- Email Verification Database
-
Custom Integrations
- Getting Started
- Authentication
- Refresh Secret
- IP & Proxy Checks
- Email Verification Checks
- Phone Number Validity Checks
- Device Tracker
- List Device Trackers
- Device Tracker Statistics
- Login Tokens
- Overview Statistics
- Recent Proxy Statistics
- Recent Email Statistics
- Fraud Reporting
- Retrieve Requests by ID
- Country List API Documentation
- Release Notes
Usage
Third-party services and your own platform can access average fraud rates, total devices, and total page views based on the optional custom variables you pass, such as userID and transactionID. This API makes it easy to retrieve average fraud rates so your platform can perform the necessary business logic to mitigate any potential risk.
You can search for any custom tracking variable established in your account's custom tracking variables passed in the Startup.Store() function by attaching them to the API request, such as userID in the example below.
Note
The API accepts the country variable in the two-letter country code format (e.g., "US", "GB", and "FR"), and start_date and end_date are accepted in "YYYY-MM-DD" format.
Replace TRACKER_ID with your specific tracking variable, COUNTRY_CODE with the two-letter country code, YYYY-MM-DD with your start and end dates, and USER_ID with the specific user ID:
https://www.ipqualityscore.com/api/YOUR_API_KEY_HERE/TRACKER_ID/tracker/average?country=COUNTRY_CODE&start_date=YYYY-MM-DD&end_date=YYYY-MM-DD&userID=USER_ID
<?php
// Set the API Key.
$key = 'YOUR_API_KEY_HERE';
// We have a user ID we'd like to get averages for.
$user = 1234;
// We have a country for this user.
$country = 'US';
// Our device tracker ID.
$id = 4321;
// Create parameters array.
$parameters = array(
'userID' => $user,
'country' => $country
);
// Format our parameters.
$formatted_parameters = http_build_query($parameters);
// Create our API URL.
$url = sprintf(
'https://www.ipqualityscore.com/api/json/%s/%s/tracker/average?%s',
$key,
$id,
$formatted_parameters
);
// Fetch JSON API result.
$json = file_get_contents($url);
// Decode the result.
$result = json_decode($json, true);
// If request was successful.
if(isset($result['success']) && $result['success'] === true){
echo $result['fraud_average'];
} else {
echo '0.00';
}
?>
# 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 averages_api(self, vars: dict = {}) -> dict:
"""Method used to lookup Stats & Averages API
Args:
vars (dict, optional): Reffer to https://www.ipqualityscore.com/documentation/device-fingerprint-api/averages for variables.
You would add your custom tracking variables here as well
Returns:
dict: Returns json response in an array.
"""
url = "https://www.ipqualityscore.com/api/%s/tracker/average" % (self.key)
if bool(vars):
x = requests.get(url, params = vars)
else:
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 == "/":
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
self.wfile.write(bytes("<body>", "utf-8"))
ipqs = IPQS()
#Example using a custom Tracking such as UserID
#print(ipqs.averages_api({'UserID':1}))
print(ipqs.averages_api())
self.wfile.write(bytes("<p>This is an example do not simply copy paste.</p>", "utf-8"))
self.wfile.write(bytes("</body></html>", "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.")