Documentazione dell'API di geolocalizzazione IP
API JSON gratuita per geolocalizzazione IP, ASN e dati di rischio. IPv4 e IPv6, HTTPS, CORS abilitato.
Guida rapida
Per provarla non serve registrarsi. Chiama l'endpoint qui sotto senza chiave per ottenere i dati del tuo IP (limite di 100 richieste al giorno).
curl https://iplookinfo.com/jsonAutenticazione
Crea una chiave API gratuita nella dashboard e inviala nell'header Authorization. Per test rapidi funziona anche il parametro di query token, ma evitalo in produzione perché gli URL finiscono nei log.
Authorization: Bearer ipl_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndpoint
- GET/api/v1/{ip}
- Cerca qualsiasi indirizzo IPv4 o IPv6.
- GET/api/v1/me
- Cerca l'IP del chiamante. Disponibile anche su /json.
- POST/api/v1/batch
- Cerca fino a 10.000 IP in un'unica richiesta (piani a pagamento). Ogni IP conta come una richiesta.
Parametri di query
lang — Lingua dei nomi di luogo: en, zh, es, pt, ru, ja. Predefinita en.
Risposta
L'oggetto risk è incluso solo nei piani Pro e Business.
{
"ip": "8.8.8.8",
"version": "IPv4",
"type": "unicast",
"bogon": false,
"network": "8.8.8.0/24",
"continent": { "code": "NA", "name": "North America" },
"country": { "code": "US", "name": "United States", "is_eu": false },
"region": null,
"city": null,
"postal": null,
"location": { "latitude": 37.751, "longitude": -97.822, "accuracy_radius_km": 1000, "time_zone": "America/Chicago" },
"asn": { "asn": 15169, "name": "Google LLC", "domain": "google.com", "route": "8.8.8.0/24" },
"isp": { "name": "Google", "organization": "Google", "is_mobile": false, "mobile_country_code": null, "mobile_network_code": null },
"risk": { "score": 60, "is_tor": false, "is_vpn": false, "is_datacenter": true, "provider": "Google Cloud" }
}Limiti di frequenza ed errori
Ogni risposta contiene gli header X-RateLimit-Limit, X-RateLimit-Remaining e X-RateLimit-Reset. Le quote si azzerano alle 00:00 UTC.
Gli errori usano un formato JSON coerente con un codice di stato HTTP:
HTTP/1.1 429 Too Many Requests
{ "error": { "code": "quota_exceeded", "message": "..." } }- 400 invalid_ip / bad_request
- 401 invalid_key
- 403 plan_required
- 413 too_many
- 429 rate_limited / quota_exceeded
Eccedenza
I piani a pagamento possono attivare l'eccedenza nella dashboard. Le richieste oltre la quota giornaliera vengono quindi servite e addebitate ogni 1.000, fino a un tetto di spesa mensile a tua scelta. Queste risposte contengono l'header X-Overage-Units.
Esempi di codice
cURL
curl -H "Authorization: Bearer $IPLOOKINFO_KEY" https://iplookinfo.com/api/v1/8.8.8.8
# Batch (paid plans)
curl -X POST -H "Authorization: Bearer $IPLOOKINFO_KEY" \
-H "Content-Type: application/json" \
-d '{"ips":["8.8.8.8","1.1.1.1"]}' https://iplookinfo.com/api/v1/batchJavaScript
const res = await fetch("https://iplookinfo.com/api/v1/8.8.8.8", {
headers: { Authorization: `Bearer ${process.env.IPLOOKINFO_KEY}` },
});
if (!res.ok) throw new Error((await res.json()).error.message);
const data = await res.json();
console.log(data.country?.code, data.city);Python
import os, requests
r = requests.get(
"https://iplookinfo.com/api/v1/8.8.8.8",
headers={"Authorization": f"Bearer {os.environ['IPLOOKINFO_KEY']}"},
timeout=5,
)
r.raise_for_status()
data = r.json()
print(data["country"]["code"], data["asn"]["name"])PHP
$ctx = stream_context_create(["http" => [
"header" => "Authorization: Bearer " . getenv("IPLOOKINFO_KEY"),
]]);
$data = json_decode(file_get_contents("https://iplookinfo.com/api/v1/8.8.8.8", false, $ctx), true);
echo $data["country"]["code"];Go
req, _ := http.NewRequest("GET", "https://iplookinfo.com/api/v1/8.8.8.8", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("IPLOOKINFO_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil { log.Fatal(err) }
defer resp.Body.Close()
var data map[string]any
json.NewDecoder(resp.Body).Decode(&data)