This page documents an earlier version of the API client. For the latest version, see Install API clients (current).
- C#
- Go
- Java
- JavaScript
- Kotlin
- PHP
- Python
- Ruby
- Scala
- Swift
Latest version: The C# API client v6 supports .NET Standard versions 1.3 to 2.1.To install version 6 of the C#/.NET API clients,
add the The C#/.NET API clients are open source.
View the source code on GitHub.
Algolia.Search package from NuGet
as a dependency to your project.
For example:Report incorrect code
Copy
dotnet add package Algolia.Search --version 6.*
Latest version: To install version 3 of the Go API clients,
add the The Go API clients are open source.
View the source code on GitHub.
algoliasearch-client-go/v3 package as a dependency to your module.Report incorrect code
Copy
go get github.com/algolia/algoliasearch-client-go/v3
Latest version: The Java API client v3 requires Java 1.8 or later
for all modules except For Java 8 and later, use the Apache HTTP client.Replace For Java 8 and later,
use the Algolia Java API client with the Apache HTTP client:
algoliasearch-java-net,
which requires Java 11 or later.
Your JDK must support TLS v1.2 or later.The Java API clients are open source.
View the source code on GitHub.Maven
Add the following dependencies to yourpom.xml file.
For Java 11 and later, you can use the native HTTP client.Report incorrect code
Copy
<dependency>
<groupId>com.algolia</groupId>
<artifactId>algoliasearch-core</artifactId>
<version>VERSION</version>
</dependency>
<dependency>
<groupId>com.algolia</groupId>
<artifactId>algoliasearch-java-net</artifactId>
<version>VERSION</version>
</dependency>
Report incorrect code
Copy
<dependency>
<groupId>com.algolia</groupId>
<artifactId>algoliasearch-core</artifactId>
<version>VERSION</version>
</dependency>
<dependency>
<groupId>com.algolia</groupId>
<artifactId>algoliasearch-apache</artifactId>
<version>VERSION</version>
</dependency>
VERSION with the version you want to install.
You can find the available releases on Maven Central.You can also add all dependencies as a single uber-JAR (Java 8 and later):Report incorrect code
Copy
<dependency>
<groupId>com.algolia</groupId>
<artifactId>algoliasearch-apache-uber</artifactId>
<version>VERSION</version>
</dependency>
Gradle
Add the following dependencies to yourbuild.gradle file.For Java 11 and later,
you can use the native HTTP client with Algolia:Report incorrect code
Copy
dependencies {
// ...
implementation 'com.algolia:algoliasearch-core:VERSION'
implementation 'com.algolia:algoliasearch-java-net:VERSION'
}
Report incorrect code
Copy
dependencies {
// ...
implementation 'com.algolia:algoliasearch-core:VERSION'
implementation 'com.algolia:algoliasearch-apache:VERSION'
}
Manual installation
If you don’t use Maven or Gradle, you can download all JAR files:algoliasearch-corealgoliasearch-apachealgoliasearch-core-uberalgoliasearch-apache-uberalgoliasearch-java-net
Adobe Experience Manager and other OSGi platforms
OSGi platforms like Adobe Experience Manager require a single uber JAR as a dependency. If you want to integrate Algolia into such a platform, addalgoliasearch-apache-uber as a dependency.Latest version: To install version 4 of the JavaScript API clients,
add the For quick prototyping or exploration,
you can also include the algoliasearch package in a For including ES6 modules, use:The JavaScript API clients are open source.
View the source code on GitHub.
algoliasearch package as a dependency to your project.Report incorrect code
Copy
npm install algoliasearch@4
<script> tag from a content delivery network.jsDelivr is a third-party CDN.
Algolia doesn’t provide support for such third-party services.
HTML
Report incorrect code
Copy
<!-- search only version -->
<script
src="https://cdn.jsdelivr.net/npm/algoliasearch@4.25.2/dist/algoliasearch-lite.umd.js"
integrity="sha256-yi498VwhoNKaHUihPJ/PZvhJghXYiGgvQG8/P8BgddQ="
crossorigin="anonymous"
></script>
<!-- default version -->
<script
src="https://cdn.jsdelivr.net/npm/algoliasearch@4.25.2/dist/algoliasearch.umd.js"
integrity="sha256-ex4R2M5mIvkgno0J1Z8F3cNBhUCzpRvYX8pxsX8+JUI="
crossorigin="anonymous"
></script>
HTML
Report incorrect code
Copy
<script type="module">
// search only version
import algoliasearch from 'https://cdn.jsdelivr.net/npm/algoliasearch@4.25.2/dist/algoliasearch-lite.esm.browser.js';
// default version
import algoliasearch from 'https://cdn.jsdelivr.net/npm/algoliasearch@4.25.2/dist/algoliasearch.esm.browser.js';
</script>
Latest version: The Kotlin API clients version 2 support Kotlin 1.6 or later.
The client supports both Android and JVM projects.To install version 2 of the Kotlin API clients,
add the following dependencies to your The Kotlin API clients are open source.
View the source code on GitHub.
build.gradle.kts file:Kotlin
Report incorrect code
Copy
dependencies {
// for Gradle version 6.0 and later
implementation("com.algolia:algoliasearch-client-kotlin:ALGOLIA_VERSION")
// Choose one of the following HTTP clients
// For JVM:
implementation("io.ktor:ktor-client-apache:KTOR_VERSION")
implementation("io.ktor:ktor-client-java:KTOR_VERSION")
implementation("io.ktor:ktor-client-jetty:KTOR_VERSION")
// For JVM/Android
implementation("io.ktor:ktor-client-okhttp:KTOR_VERSION")
implementation("io.ktor:ktor-client-android:KTOR_VERSION")
implementation("io.ktor:ktor-client-cio:KTOR_VERSION")
}
-
Replace
ALGOLIA_VERSIONwith the version of the Kotlin API client v2 you want to install. You can find the released versions on Maven Central. -
Replace
KTOR_VERSIONwith the version of the Ktor client you want to use.
build.gradle.kts file:Kotlin
Report incorrect code
Copy
plugins {
// Replace with latest version from:
// https://kotlinlang.org/docs/serialization.html#add-plugins-and-dependencies
kotlin("plugin.serialization") version "2.2.0"
}
Latest version: The Algolia PHP API clients version 3 support PHP 7.2 or later.To install version 3 of the PHP API clients,
install the
algoliasearch-client-php package with composer.Report incorrect code
Copy
composer require algolia/algoliasearch-client-php:^3.0
Building Laravel apps?
Check the Laravel integration built on top of the PHP API client.
Building Symfony apps?
Check the Symfony integration built on top of the PHP API client.
Manual installation
- Download the client from GitHub and unpack the archive in your project directory.
- Inside the root directory of the client, run
./bin/install-dependencies-without-composer. - In your code, require the
autoload.phpmodule in the client’s root directory.
Latest version: The Python API clients version 3 support Python 3.4 or later.To install version 3 of the Python API clients,
add the The Python API clients are open source.
View the source code on GitHub.
algoliasearch package as a dependency to your project.Report incorrect code
Copy
pip install algoliasearch~=3.0
Building Django apps?
Check the Django integration built on top of the Python API client.
Latest version: The Ruby API clients version 2 support Ruby 2.2 or later.To install version 2 of the Ruby API clients,
add the The Ruby API clients are open source.
View the source code on GitHub.
algolia gem as a dependency to your project:Report incorrect code
Copy
bundle add algolia --version'~>2.0'
# or: gem install algolia -v '~>2.0'
Be sure to install the
algolia gem.
The algoliasearch gem installs version 1 of the Ruby API clients.
For more information, see Update the Ruby API client.Building Ruby on Rails apps?
Check the Ruby on Rails integration built on top of the Ruby API client.
Latest version: The Scala API clients version 1 support Scala 2.13, 2.12, or 2.11.With Maven, add the following dependency to your Replace With sbt, add the following dependency to your For snapshots, add the The Scala API clients are open source.
View the source code on GitHub.
pom.xml file:pom.xml
Report incorrect code
Copy
<dependency>
<groupId>com.algolia</groupId>
<artifactId>algoliasearch-scala_2.13</artifactId>
<version>[1,)</version>
</dependency>
algoliasearch-scala_2.13 with algoliasearch-scala_2.12 or algoliasearch-scala_2.11
if you need to support a different Scala version.For snapshots, add the sonatype repository:pom.xml
Report incorrect code
Copy
<repositories>
<repository>
<id>oss-sonatype</id>
<name>oss-sonatype</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
build.sbt file:build.sbt
Report incorrect code
Copy
libraryDependencies += "com.algolia" %% "algoliasearch-scala" % "[1.0,2.0["
sonatype repository:build.sbt
Report incorrect code
Copy
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
Latest version: The Algolia Swift API clients version 8 support Swift version 5.0 or later and supports iOS, macOS, tvOS, and watchOS platforms.To install version 8 of the Swift API clients,
add the following dependencies to your project.With the Swift Package Manager,
add the following dependencies to your With CocoaPods add the following to your With Carthage, add the following to your The Swift API clients are open source.
View the source code on GitHub.
Package.swift file:Swift
Report incorrect code
Copy
let package = Package(
dependencies: [
.package(
url: "https://github.com/algolia/algoliasearch-client-swift",
from: "8.0.0"
)
],
targets: [
// Add the client as dependency to your targets
.executableTarget(
name: "algolia-example",
dependencies: [
.product(
name:"AlgoliaSearchClient",
package: "algoliasearch-client-swift"
)
]
)
]
)
Podfile:Podfile
Report incorrect code
Copy
pod("AlgoliaSearchClient", "~> 8.0")
Cartfile:Cartfile
Report incorrect code
Copy
github "algolia/algoliasearch-client-swift" ~> 8.0.0
Test your installation
To test your installation, try running a short program that adds a record to a test index, searches your index, and prints the results.Create account
If you haven’t already, create an Algolia account
Copy code
Copy the following code into a new project or file.
Replace
ALGOLIA_APPLICATION_ID and ALGOLIA_API_KEY with values from your account.
Make sure to use an API key with addObject and search permissions.Report incorrect code
Copy
using System;
using System.Linq;
using System.Collections.Generic;
using Algolia.Search.Clients;
using Algolia.Search.Models.Search;
namespace HelloAlgolia
{
// a simple record in your index
class Record
{
public string Name { get; set; }
public string ObjectID { get; set; }
public override string ToString()
{
return $"Name: {Name}, ObjectID: {ObjectID}";
}
}
class Program
{
static void Main(string[] args)
{
// Connect and authenticate with your Algolia app
var client = new SearchClient(
"ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY"
);
// Create a new index and add a record
var index = client.InitIndex("test_index");
var record = new Record{ ObjectID = "1", Name = "test_record" };
index.SaveObject(record).Wait();
// Search the index and print the results
var results = index.Search<Record>(new Query("test_record"));
Console.WriteLine(results.Hits.ElementAt(0).ToString());
}
}
}
In production, use environment variables for your credentials.