Proxy Detection Using IP Geolocation API with cURL
Proxy Detection Using ExtractIP Geolocation API with cURL
Introduction
Detecting proxy usage is essential for applications that rely on accurate IP geolocation. In this guide, we'll
demonstrate how to check for proxy usage by comparing two API requests to api.extractip.com/geolocate
: one made
directly and another routed through a proxy. We will also compare specific fields from the JSON responses to highlight
differences.
Prerequisites
- Access to the ExtractIP API (
api.extractip.com/geolocate
) - Basic knowledge of the command line
- An available proxy server (IP and port)
- Tools like
jq
anddiff
(installed by default on many systems)
Step-by-Step: Proxy Detection via cURL
1. Direct API Request (No Proxy)
First, send a direct request to your API to check the IP address from your machine:
curl -s "https://api.extractip.com/geolocate" > direct_response.json
Expected Response Example:
{
"exit_ip": "8.8.8.8",
"capital": "Washington",
"country_code": "US",
"country_name": "United States",
"country_region": "North America",
"country_neighbors": [
"CA",
"CU",
"MX"
],
"time_zone": "America/Los_Angeles",
"domain_name": ".us",
"domains": [
"dns.google."
],
"currency": "USD",
"call_codes": [
"+1"
],
"flag_url": "https://api.extractip.com/flags/3x2/US.svg"
}
2. API Request via Proxy
Next, route the request through a proxy server. Replace proxy_ip:proxy_port
with your proxy details:
curl -s "https://api.extractip.com/geolocate" --proxy http://proxy_ip:proxy_port > proxy_response.json
Comparing Results
Method 1: Using diff
To compare the entire responses:
diff direct_response.json proxy_response.json
This highlights differences line-by-line. For more concise output, use jq
to format:
jq -S . direct_response.json > direct_sorted.json
jq -S . proxy_response.json > proxy_sorted.json
diff direct_sorted.json proxy_sorted.json
Method 2: Comparing Specific Fields with jq
To focus on key fields like exit_ip
, country_name
, and domains
:
direct_ip=$(jq -r '.exit_ip' direct_response.json)
proxy_ip=$(jq -r '.exit_ip' proxy_response.json)
direct_country=$(jq -r '.country_name' direct_response.json)
proxy_country=$(jq -r '.country_name' proxy_response.json)
echo "Direct IP: $direct_ip ($direct_country)"
echo "Proxy IP: $proxy_ip ($proxy_country)"
if [ "$direct_ip" != "$proxy_ip" ]; then
echo "Proxy detected: IPs are different."
else
echo "No proxy detected: IPs are the same."
fi
Conclusion
By comparing direct and proxy responses, you can effectively detect proxy usage. Key differences in fields like exit_ip
,
country_name
, or domains
provide insights into potential anonymization. This method ensures robust proxy detection
using ExtractIP geolocation API.
Tags
Related articles
Verify your proxy connection using cURL
Get privacy related information about IP address
Localize prices on your website using IP geolocation to display them in visitors' local currencies.