SDKs overview

Algolia offers a suite of Software Development Kits (SDKs) and client libraries to enable developers to integrate its search and discovery services into their applications. These libraries are designed to provide a native development experience across various programming languages and platforms, abstracting the direct interaction with Algolia's REST API.

The SDKs cover core functionalities such as indexing data, performing search queries, managing indices, and configuring relevance. Beyond the foundational SDKs, Algolia also provides specialized UI libraries, collectively known as InstantSearch, which are tailored for frontend frameworks and mobile platforms. These InstantSearch libraries are built atop the core SDKs and aim to reduce the effort required to build interactive search user interfaces, handling aspects like pagination, faceting, and dynamic search results (Algolia InstantSearch overview).

The choice of SDK typically depends on the backend language used for data indexing and management, and the frontend framework or mobile platform targeted for the user interface. Developers can combine server-side SDKs for data operations with client-side or InstantSearch libraries for building the search experience.

Official SDKs by language

Algolia maintains official SDKs for a range of popular programming languages, ensuring compatibility and leveraging language-specific conventions. These SDKs are actively developed and supported by Algolia. The table below outlines the primary official SDKs, their corresponding package names, and typical installation commands.

Language Package/Library Installation Command Example Maturity
JavaScript algoliasearch (for Node.js & Browsers) npm install algoliasearch or yarn add algoliasearch Stable
Python algoliasearch pip install algoliasearch Stable
Ruby algoliasearch gem install algoliasearch Stable
PHP algolia/algoliasearch-client-php composer require algolia/algoliasearch-client-php Stable
Java algoliasearch-java Included in build tools like Maven/Gradle Stable
C# Algolia.Search dotnet add package Algolia.Search Stable
Go github.com/algolia/algoliasearch-client-go/v3 go get github.com/algolia/algoliasearch-client-go/v3 Stable
Swift InstantSearchClient (for iOS/macOS) Integrated via Swift Package Manager or CocoaPods Stable
Kotlin algoliasearch-client-kotlin (for Android/JVM) Included in build tools like Gradle Stable

In addition to these core client SDKs, Algolia offers InstantSearch UI libraries for popular frontend frameworks:

  • React: react-instantsearch-hooks
  • Vue: vue-instantsearch
  • Angular: angular-instantsearch
  • JavaScript (Vanilla): instantsearch.js
  • Mobile: instantsearch-ios (Swift), instantsearch-android (Kotlin)

Installation

Installation methods vary by language and ecosystem. The following provides common installation patterns for some of the most frequently used Algolia SDKs. Always refer to the official Algolia documentation for the most up-to-date and detailed instructions for your specific environment.

JavaScript (Node.js & Browser)

The JavaScript client is available via npm. It can be used in Node.js environments for server-side indexing or in browsers for client-side search operations.

npm install algoliasearch
# or
yarn add algoliasearch

Python

The Python SDK is distributed through pip, the standard package installer for Python.

pip install algoliasearch

PHP

For PHP projects, the SDK is managed via Composer.

composer require algolia/algoliasearch-client-php

Java

Java projects typically use Maven or Gradle for dependency management. Below is an example for Maven:

<dependency>
    <groupId>com.algolia</groupId>
    <artifactId>algoliasearch</artifactId>
    <version>4.14.0</version> <!-- Check for the latest version -->
</dependency>

C# (.NET)

The C# SDK is available as a NuGet package.

dotnet add package Algolia.Search
# or via NuGet Package Manager Console
Install-Package Algolia.Search

Quickstart example

This example demonstrates a basic search operation using the Algolia JavaScript SDK. It initializes the client, targets an index, and performs a search query. Replace YOUR_APP_ID, YOUR_SEARCH_API_KEY, and YOUR_INDEX_NAME with your actual Algolia credentials and index name, which you can find in your Algolia dashboard.

// For Node.js or browser with a bundler
import algoliasearch from 'algoliasearch';

const client = algoliasearch('YOUR_APP_ID', 'YOUR_SEARCH_API_KEY');
const index = client.initIndex('YOUR_INDEX_NAME');

// Perform a search query
index.search('apple', {
  hitsPerPage: 5,
}).then(({ hits }) => {
  console.log(hits);
}).catch(err => {
  console.error(err);
});

// Example of adding an object to the index (server-side operations require an Admin API Key)
// const adminClient = algoliasearch('YOUR_APP_ID', 'YOUR_ADMIN_API_KEY');
// const adminIndex = adminClient.initIndex('YOUR_INDEX_NAME');

// adminIndex.saveObject({
//   objectID: 'my-unique-id',
//   name: 'Apple iPhone 15',
//   description: 'Latest model smartphone',
//   price: 999.99
// }).then(({ objectID }) => {
//   console.log('Object saved:', objectID);
// }).catch(err => {
//   console.error(err);
// });

This snippet initializes the Algolia client with your application ID and search-only API key, then accesses a specific index. It demonstrates how to perform a simple text search and log the resulting hits. For indexing data or other administrative tasks, an Admin API key is required, and these operations should only be performed on the server-side for security reasons (Algolia API key management). The use of separate search-only and admin keys adheres to the principle of least privilege, a common security practice in API design (Google Cloud least privilege principle).

Community libraries

While Algolia provides a comprehensive set of official SDKs and InstantSearch libraries, the developer community sometimes contributes additional tools, wrappers, or integrations for less common languages, frameworks, or specific use cases. These community-maintained resources can offer alternative approaches or extend Algolia's functionality in ways not covered by the official offerings.

It's important to note that community libraries may not receive the same level of support or regular updates as official SDKs. Developers using community contributions should verify the project's activity, maintenance status, and compatibility with the latest Algolia API versions. Common places to discover such libraries include GitHub, language-specific package repositories, and developer forums. Algolia's own documentation sometimes highlights notable community projects, but the primary source for official and supported tools remains their core SDK documentation.

As of late 2024, Algolia's official SDK coverage is extensive, meaning the need for community-developed core client wrappers is less prevalent than for niche integrations or specialized UI components not covered by InstantSearch. For example, developers might find community-driven plugins for specific CMS platforms or custom frontend frameworks that integrate Algolia. Always check the official Algolia client documentation for recommended and supported libraries before opting for a community alternative.