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

ParameterTypeRequiredDescription
ipstringNoThe 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

FieldTypeDescription
ipstringThe queried IP address
countrystringISO 3166-1 alpha-2 country code
countryNamestringFull country name
continentstringContinent name
isEUbooleanWhether the country is in the EU
citystringCity name (own IP only)
regionstringRegion/state name (own IP only)
regionCodestringRegion/state code (own IP only)
postalCodestringPostal/ZIP code (own IP only)
latitudestringLatitude coordinate (own IP only)
longitudestringLongitude coordinate (own IP only)
timezonestringIANA timezone (own IP only)
colostringEdge location code (own IP only)
datacenterstringDetected cloud/datacenter provider
locationHintstringLocation code
asnnumberAutonomous System Number
asNamestringAS organization name
bgpPrefixstringBGP announced prefix (CIDR)
hostnamestringReverse DNS hostname (PTR record)
_metaobjectQuery 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

PlanRequests per minute
Free10
Pro100
EnterpriseUnlimited

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