How to Test IP Geolocation APIs with cURL
cURL is the fastest way to test any API from your terminal. Here's how to use it effectively with IP geolocation endpoints.
Basic Request
curl https://geo.kamero.ai/api/geoReturns raw JSON with your IP, city, country, coordinates, timezone, and more.
Pretty Print with jq
curl -s https://geo.kamero.ai/api/geo | jq .The -s flag silences the progress bar, and jq . formats the JSON output with colors and indentation.
Extract Specific Fields
# Get just the city
curl -s https://geo.kamero.ai/api/geo | jq -r '.city'
# Get city and country
curl -s https://geo.kamero.ai/api/geo | jq -r '"(.city), (.country)"'
# Get coordinates
curl -s https://geo.kamero.ai/api/geo | jq '{lat: .latitude, lng: .longitude}'Measure Response Time
# Total time
curl -s -o /dev/null -w "Total: %{time_total}s\n" https://geo.kamero.ai/api/geo
# Detailed timing breakdown
curl -s -o /dev/null -w "DNS: %{time_namelookup}s\nConnect: %{time_connect}s\nTLS: %{time_appconnect}s\nFirst byte: %{time_starttransfer}s\nTotal: %{time_total}s\n" https://geo.kamero.ai/api/geoCheck Response Headers
curl -I https://geo.kamero.ai/api/geoThis shows the HTTP headers including CORS headers, content type, and cache directives.
Test CORS Preflight
curl -X OPTIONS https://geo.kamero.ai/api/geo \
-H "Origin: https://example.com" \
-H "Access-Control-Request-Method: GET" \
-v 2>&1 | grep -i "access-control"Save Response to File
# Save JSON response
curl -s https://geo.kamero.ai/api/geo -o location.json
# Append to log with timestamp
echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) $(curl -s https://geo.kamero.ai/api/geo)" >> geo_log.txtLoop for Monitoring
# Check every 30 seconds
while true; do
echo "$(date): $(curl -s https://geo.kamero.ai/api/geo | jq -r '.city')"
sleep 30
doneCompare Multiple APIs
# Time multiple geolocation APIs
for url in \
"https://geo.kamero.ai/api/geo" \
"https://ipapi.co/json/" \
"http://ip-api.com/json/"; do
time=$(curl -s -o /dev/null -w "%{time_total}" "$url")
echo "$url → ${time}s"
doneUse in Shell Scripts
#!/bin/bash
# Get visitor country and act on it
COUNTRY=$(curl -s https://geo.kamero.ai/api/geo | jq -r '.country')
case $COUNTRY in
US) echo "Connecting to US server..." ;;
EU|DE|FR|GB) echo "Connecting to EU server..." ;;
*) echo "Connecting to default server..." ;;
esac