implydata / hostbook

Scala GeoIP lookups

Version Matrix

hostbook

This is a Scala library that helps you do GeoIP lookups with the MaxMind GeoIP databases.

import io.imply.hostbook.GeoLookup
import java.io.File

object Example
{
  def main(args: Array[String]) {
    val file = new File("geodb")
    val geo = GeoLookup.fromFreeDownloadableDatabase(file)
    val result = geo.lookup("206.190.36.45")
    println(s"IP is from ${result.cityName.orNull}, ${result.regionName.orNull}, ${result.countryName.orNull}.")
  }
}