- C#
- Dart
- Go
- Java
- JavaScript
- Kotlin
- PHP
- Python
- Ruby
- Scala
- Swift
Latest version: Install version 7 of the C#/.NET API clients by adding the The C#/.NET API clients are open source and generated from OpenAPI specifications.
Algolia.Search package from NuGet.
For example:Report incorrect code
Copy
dotnet add package Algolia.Search --version "7.*"
Building ASP.NET apps?
Check the additional information about dependency injection.
Latest version: Install version 1 the Dart API clients by adding the The Dart API clients are open source and generated from OpenAPI specifications.
algoliasearch package as a dependency to your project.Report incorrect code
Copy
dart pub add algoliasearch:'^1.0'
Latest version: Install version 4 of the Go API clients by adding the The Go API clients are open source and generated from OpenAPI specifications.
algoliasearch-client-go package as a dependency to your module.Report incorrect code
Copy
go get github.com/algolia/algoliasearch-client-go/v4
Latest version: Install version 4 of the Java API clients by adding the following dependencies to your project.
For Maven, add the following dependencies to your For Gradle, add the following dependencies to your Replace
pom.xml file:pom.xml
Report incorrect code
Copy
<dependency>
<groupId>com.algolia</groupId>
<artifactId>algoliasearch</artifactId>
<version>VERSION</version>
</dependency>
build.gradle file:build.gradle
Report incorrect code
Copy
dependencies {
implementation 'com.algolia.algoliasearch:VERSION'
}
VERSION with the version of the API clients you want to install.
You can find the available releases on Maven Central.If you don’t use Maven or Gradle,
you can download the JAR files.The Java API clients are open source and generated from OpenAPI specifications.Latest version: To install version 5 of the JavaScript API clients, add the The The JavaScript API clients are open source and generated from OpenAPI specifications.
algoliasearch package as a dependency to your project.Report incorrect code
Copy
npm install algoliasearch@5
algoliasearch package includes API clients for the Search API,
the Personalization API, the Analytics API, and the A/B testing API.
If you only need to access methods from a specific API, you can install API clients separately:Report incorrect code
Copy
# Search API
npm install @algolia/client-search
# Recommend API
npm install @algolia/recommend
# Analytics API
npm install @algolia/client-analytics
# A/B testing API
npm install @algolia/client-abtesting
# Ingestion API
npm install @algolia/ingestion
# Insights API
npm install @algolia/client-insights
# Monitoring
npm install @algolia/monitoring
# Personalization API
npm install @algolia/client-personalization
# Query Suggestions API
npm install @algolia/client-query-suggestions
# Usage API
npm install @algolia/client-usage
Latest version: To install version 3 of the Kotlin API clients, add the following
dependencies to your The Kotlin API clients are open source and generated from OpenAPI specifications.
build.gradle file:build.gradle
Report incorrect code
Copy
repositories {
mavenCentral()
}
dependencies {
implementation 'com.algolia:algoliasearch-client-kotlin:ALGOLIA_VERSION'
// You need to specify a Ktor engine suitable for your platform
runtimeOnly 'io.ktor:ktor-client-java:KTOR_VERSION'
}
-
Replace
ALGOLIA_VERSIONwith the version of the Kotlin API client 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. To learn more about the available engines, see Client engines.
build.gradle
Report incorrect code
Copy
repositories {
mavenCentral()
}
dependencies {
implementation platform("com.algolia:algoliasearch-client-kotlin-bom:ALGOLIA_VERSION")
// define dependencies without versions
implementation 'com.algolia:algoliasearch-client-kotlin'
runtimeOnly 'io.ktor:ktor-client-java'
}
Latest version: To install version 4 of the PHP API clients,
install the The PHP API clients are open source and generated from OpenAPI specifications.
algoliasearch-client-php package with with composer.Report incorrect code
Copy
composer require algolia/algoliasearch-client-php "^4.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.
Latest version: To install version 4 of the Python API clients, install the The Python API clients are open source and generated from OpenAPI specifications.
algoliasearch package.
The Python API clients support Python 3.8 or later.Report incorrect code
Copy
pip install "algoliasearch>=4,<5"
Building Django apps?
Check the Django integration built on top of the Python API client.
Latest version: To install version 3 of the Ruby API clients,
add the The Ruby API clients are open source and generated from OpenAPI specifications.
algolia gem as a dependency to your project.
The Ruby API clients support Ruby 2.2 or later.Report incorrect code
Copy
bundle add algolia --version='~>3.0'
# or: gem install algolia -v '~>3.0'
Building Ruby on Rails apps?
Check the Ruby on Rails integration built on top of the Ruby API client.
Latest version: To install version 2 of the Scala API clients,
add the following dependencies to your Replace
build.sbt file:build.sbt
Report incorrect code
Copy
libraryDependencies += "com.algolia" %% "algoliasearch-scala" % "VERSION"
VERSION with the version of the API clients you want to install.
You can find the available releases on Maven Central:The Scala API clients are open source and generated from OpenAPI specifications.Latest version: To install version 9 of the Swift API clients,
add the With CocoaPods, add the following to your With Carthage, add the following to your The Swift API clients are open source and generated from OpenAPI specifications.
algoliasearch-client-swift package as a dependency to your project.With the Swift Package Manager,
add the following dependencies to your Package.swift file:Swift
Report incorrect code
Copy
let package = Package(
// ...
dependencies: [
.package(url: "https://github.com/algolia/algoliasearch-client-swift.git", from: "9.0.0")
],
targets: [
.target(
// ...
dependencies: [
.product(name: "Search", package: "algoliasearch-client-swift")
]
)
]
)
Podfile:Podfile
Report incorrect code
Copy
pod("AlgoliaSearchClient", "~> 9.0.0")
Cartfile:Cartfile
Report incorrect code
Copy
github "algolia/algoliasearch-client-swift" ~> 9.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.1
Create account
If you haven’t already, create an Algolia account.
2
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 Algolia.Search.Clients;
using Algolia.Search.Models.Search;
var appID = "ALGOLIA_APPLICATION_ID";
// API key with `addObject` and `search` ACL
var apiKey = "ALGOLIA_API_KEY";
var indexName = "test-index";
var client = new SearchClient(appID, apiKey);
// Create a new record
var record = new Dictionary<string, string>
{
{ "objectID", "object-1" },
{ "name", "test record" },
};
// Add record to an index
var saveResp = await client.SaveObjectAsync(indexName, record);
// Wait until indexing is done
await client.WaitForTaskAsync(indexName, saveResp.TaskID);
// Search for 'test'
var searchResp = await client.SearchAsync<Object>(
new SearchMethodParams
{
Requests = new List<SearchQuery>
{
new SearchQuery(new SearchForHits { IndexName = indexName, Query = "test" })
}
}
);
Console.WriteLine(searchResp.ToJson());
In production, use environment variables for your credentials.
3
Run code
Run the code, depending on your development environment.If the command is successful,
you’ll see the API response as a native object in your programming language.
Report incorrect code
Copy
# For example:
dotnet run