GET/v1/ip
Locate an IP address
IP geolocation: continent, country, region, city, approximate coordinates, time zone and the country's primary
languages. City-level accuracy, suitable for localisation, defaults and analytics, not for pinpointing a person.
Data: IP Geolocation by DB-IP (db-ip.com), City Lite edition, CC BY 4.0, refreshed monthly. Leave ip empty only
when calling the API directly; through the gateway the API sees the gateway's address, so pass the visitor's ip.
PARAMETERS
- ipquery · string
- IPv4 or IPv6 address. Leave empty for the address the API sees the call from.
REQUEST
curl "https://api.geocode.net/v1/ip" \ -H "X-API-Key: YOUR_KEY"
import requests
r = requests.get("https://api.geocode.net/v1/ip", headers={"X-API-Key": "YOUR_KEY"})
print(r.status_code, r.headers.get("X-Gw-Remaining"))
print(r.json())
const r = await fetch("https://api.geocode.net/v1/ip", {
headers: { "X-API-Key": "YOUR_KEY" }
});
console.log(r.status, r.headers.get("X-Gw-Remaining"));
console.log(await r.json());
RESPONSE
200Successful Response
{
"ip": "8.8.8.8",
"continent": {
"code": "NA",
"name": "North America"
},
"country": {
"code": "US",
"name": "United States",
"is_eu": false
},
"region": {
"name": "California"
},
"city": "Mountain View",
"location": {
"lat": 37.422,
"lng": -122.085
},
"timezone": {
"name": "America/Los_Angeles",
"utc_offset": "-07:00"
},
"languages": [
"en",
"es"
],
"source": "IP Geolocation by DB-IP (https://db-ip.com), CC BY 4.0"
}