DEV Community

Daniel Igel
Daniel Igel

Posted on

Add geo-personalization with one IP lookup (IPv4/IPv6, batch)

Geo-personalization — currency, language, "stores near you" — usually means shipping a 60 MB GeoIP database and keeping it updated, or paying per-seat for an SDK. For most apps you just need country + city from an IP.

One GET does it, IPv4 and IPv6:

curl --request GET \
  --url 'https://ip-geolocation-api20.p.rapidapi.com/api/v1/geo?ip=8.8.8.8' \
  --header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY' \
  --header 'x-rapidapi-host: ip-geolocation-api20.p.rapidapi.com'
Enter fullscreen mode Exit fullscreen mode

Returns country, region, city, lat/lon, timezone. There's /api/v1/geo/me to resolve the caller's own IP (handy for edge functions) and /api/v1/geo/batch for bulk enrichment of logs or signups.

Free tier on RapidAPI: https://rapidapi.com/danieligel/api/ip-geolocation-api20

I built this so I didn't have to bundle MaxMind into every small project. What do you use IP geo for — personalization, fraud, analytics?

Top comments (0)