IP Geolocation API
Get country, city, coordinates, ASN, and network information for any IP address.
Last updated Dec 1, 2024
The IP Geolocation API returns location and network information for IP addresses including country, city, coordinates, timezone, and ASN data.
Endpoint
GET https://api.requestguard.com/v1/ip/geolocation
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ip | string | No | The IP address to query (IPv4 or IPv6). If omitted, returns data for the request IP. |
When the ip parameter is omitted:
- Uses the requester’s IP address automatically
- Returns instant results with full geolocation data
- Includes city-level precision:
city,region,postalCode,latitude,longitude,timezone
When the ip parameter is provided:
- Returns geolocation data for the specified IP
- May have slightly higher latency
Response
Example (with IP parameter)
{
"success": true,
"data": {
"ip": "8.8.8.8",
"country": "US",
"countryName": "United States",
"continent": "North America",
"isEU": false,
"datacenter": "google",
"locationHint": "LAX",
"asn": 15169,
"asName": "GOOGLE, US",
"bgpPrefix": "8.8.8.0/24",
"hostname": "dns.google",
"_meta": {
"queriedAt": "2024-12-01T12:00:00.000Z",
"responseTime": 85
}
}
}
Example (without IP parameter - own IP)
{
"success": true,
"data": {
"ip": "203.0.113.45",
"country": "DE",
"countryName": "Germany",
"continent": "Europe",
"isEU": true,
"city": "Frankfurt am Main",
"region": "Hesse",
"regionCode": "HE",
"postalCode": "60313",
"latitude": "50.11550",
"longitude": "8.68420",
"timezone": "Europe/Berlin",
"colo": "FRA",
"locationHint": "FRA",
"asn": 3320,
"asName": "DTAG Internet service provider operations",
"_meta": {
"queriedAt": "2024-12-01T12:00:00.000Z",
"responseTime": 0
}
}
}
Response Fields
| Field | Type | Description |
|---|---|---|
ip | string | The queried IP address |
country | string | ISO 3166-1 alpha-2 country code |
countryName | string | Full country name |
continent | string | Continent name |
isEU | boolean | Whether the country is in the EU |
city | string | City name (own IP only) |
region | string | Region/state name (own IP only) |
regionCode | string | Region/state code (own IP only) |
postalCode | string | Postal/ZIP code (own IP only) |
latitude | string | Latitude coordinate (own IP only) |
longitude | string | Longitude coordinate (own IP only) |
timezone | string | IANA timezone (own IP only) |
colo | string | Edge location code (own IP only) |
datacenter | string | Detected cloud/datacenter provider |
locationHint | string | Location code |
asn | number | Autonomous System Number |
asName | string | AS organization name |
bgpPrefix | string | BGP announced prefix (CIDR) |
hostname | string | Reverse DNS hostname (PTR record) |
_meta | object | Query metadata |
Example Requests
Own IP (instant)
curl "https://api.requestguard.com/v1/ip/geolocation"
Specific IP Lookup
curl "https://api.requestguard.com/v1/ip/geolocation?ip=8.8.8.8"
IPv6 Lookup
curl "https://api.requestguard.com/v1/ip/geolocation?ip=2001:4860:4860::8888"
Example Response (European IP)
{
"success": true,
"data": {
"ip": "185.100.87.209",
"country": "RO",
"countryName": "Romania",
"continent": "Europe",
"isEU": true,
"asn": 200651,
"asName": "FLOKINET, IS",
"bgpPrefix": "185.100.87.0/24",
"_meta": {
"queriedAt": "2024-12-01T12:00:00.000Z",
"responseTime": 92
}
}
}
Error Responses
Invalid IP
{
"success": false,
"error": {
"code": "INVALID_IP",
"message": "Invalid IP address format"
}
}
Private IP
{
"success": false,
"error": {
"code": "PRIVATE_IP",
"message": "Cannot lookup private IP address"
}
}
Rate Limits
| Plan | Requests per minute |
|---|---|
| Free | 10 |
| Pro | 100 |
| Enterprise | Unlimited |
Use Cases
- Geographic Access Control: Restrict access by country
- EU/GDPR Compliance: Detect EU visitors for compliance
- CDN Routing: Route users to nearest datacenter
- Analytics: Understand visitor geography
- Fraud Detection: Flag unexpected geolocations