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.
api.extractip.com/geolocate
)jq
and diff
(installed by default on many systems)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"
}
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
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
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
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.
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.