ScalaHub

Scala Client for MaxMind Geo-IP

You are here

scala-maxmind-geoip is a Scala wrapper for the MaxMind Java Geo-IP library.

Besides the friendly Scala syntax, you get configurable LRU caching out of the box. And if you are using SBT there’s built-in automagical update to the latest MaxMind GeoLiteCity.dat and Java client library version.

Quick usage example:

1
2
3
4
5
6
7
val geoDbFile = new java.io.File(getClass.getResource("/maxmind/GeoLiteCity.dat").toURI())
val ipGeo = new IpGeo(dbFile = geoDbFile, lruCache = 100, memCache = false)

for (loc <- ipGeo.getLocation("204.232.175.78")) {
  println(loc.countryCode)   // US
  println(loc.countryName)   // United States
}

scala-maxmind-geoip is written by Alexander Dean from SnowPlow Analytics.