We recently released a new version of our docs.

Install the Scala API client


With Maven, add the following dependency to your pom.xml file:


For snapshots, add the sonatype repository:


If you’re using sbt, add the following dependency to your build.sbt file:

libraryDependencies += "com.algolia" %% "algoliasearch-scala" % "[1,)"

For snapshots, add the sonatype repository:

resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"

Supported platforms

The API client only supports Scala 2.11 & 2.12.

Language-specific notes

WARNING: The JVM has an infinite cache on successful DNS resolution. As our hostnames points to multiple IPs, the load could be not evenly spread among our machines, and you might also target a dead machine.

You should change this TTL by setting the property networkaddress.cache.ttl. For example to set the cache to 60 seconds:

java.security.Security.setProperty("networkaddress.cache.ttl", "60");

For debug purposes you can enable debug logging on the API client. It’s using slf4j so it should be compatible with most java loggers. The logger is named algoliasearch.



The main goal of this client is to provide a human-accessible and readable DSL for using AlgoliaSearch.

The entry point of the DSL is the algolia.AlgoliaDSL object. This DSL is used in the execute method of algolia.AlgoliaClient.

As we want to provide human-readable DSL, there’s more than one way to use this DSL. For example, to get an object by its objectID:

client.execute { from index "index" objectId "myId" }

// or

client.execute { get / "index" / "myId" }


The execute method always returns a scala.concurrent.Future. Depending on the operation, it’s parametrized by a case class. For example:

val future: Future[Search] =
    client.execute {
        search into "index" query "a"

JSON as case class

Putting or getting objects from the API is wrapped into case class automatically with json4s.

If you want to get objects, search for them and unwrap the result:

case class Contact(firstname: String,
                   lastname: String,
                   followers: Int,
                   compagny: String)

val future: Future[Seq[Contact]] =
        .execute {
            search into "index" query "a"
        .map { search =>

If you want to get the full results (with _highlightResult, etc.):

case class EnhanceContact(firstname: String,
                          lastname: String,
                          followers: Int,
                          compagny: String,
                          objectID: String,
                          _highlightResult: Option[Map[String, HighlightResult]
                          _snippetResult: Option[Map[String, SnippetResult]],
                          _rankingInfo: Option[RankingInfo]) extends Hit

val future: Future[Seq[EnhanceContact]] =
        .execute {
            search into "index" query "a"
        .map { search =>

For indexing documents, pass an instance of your case class to the DSL:

client.execute {
    index into "contacts" `object` Contact("Jimmie", "Barninger", 93, "California Paint")