- C#
- Dart
- Go
- Java
- JavaScript
- Kotlin
- PHP
- Python
- Ruby
- Scala
- Swift
The Insights API client is part of the To use the Insights client, import these namespaces:To create an instance of the client:
Algolia.Search package.
To install this package, run:Command line
dotnet add package Algolia.Search
C#
using Algolia.Search.Clients;
using Algolia.Search.Http;
using Algolia.Search.Models.Insights;
C#
var client = new InsightsClient(
new InsightsConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
);
The Insights API client is part of the To use the Insights client, add this import to your files:To create an instance of the client:
algoliasearch package.
To install this package, run:Command line
dart pub add algoliasearch
Dart
import 'package:algolia_client_insights/algolia_client_insights.dart';
Dart
final client = InsightsClient(
appId: 'ALGOLIA_APPLICATION_ID',
apiKey: 'ALGOLIA_API_KEY',
region: 'ALGOLIA_APPLICATION_REGION');
The Insights API client is part of the To use the Insights client, add this import to your files:To create an instance of the client:Make sure to use the region that matches your Algolia application’s analytics region:
algoliasearch-client-go package.
To install it, run:Command line
go get github.com/algolia/algoliasearch-client-go
Go
import "github.com/algolia/algoliasearch-client-go/v4/algolia/insights"
Go
client, err := insights.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", insights.US)
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
insights.US for the United States or insights.DE for Europe.
You can check your analytics region in the Infrastructure > Analytics section of the Algolia dashboard.The Insights API client is part of the or to your To use the Insights client, add these imports to your files:To create an instance of the client:Replace
algoliasearch package.
You can add this package to your pom.xml file for Maven:pom.xml
<dependency>
<groupId>com.algolia</groupId>
<artifactId>algoliasearch</artifactId>
<version>4.25.0</version>
</dependency>
build.gradle file for Gradle:build.gradle
implementation 'com.algolia:algoliasearch:4.25.0'
Java
import com.algolia.api.InsightsClient;
import com.algolia.config.*;
Java
InsightsClient client = new InsightsClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION");
ALGOLIA_APPLICATION_ID_REGION with your Algolia application’s analytics region: us for the United States or de for Europe.
You can check your analytics region in the Infrastructure > Analytics section of the Algolia dashboard.The Insights API client is part of the To use this client, run:
@algolia/client-insights package.
To install this package, run:Command line
npm install @algolia/client-insights
JavaScript
import { insightsClient } from "@algolia/client-insights";
const client = insightsClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY");
To send events from your front- or backend,
consider using the
search-insights library instead.
It comes with many helper methods for sending specific event types
and managing the user token.The Insights API client is part of the To use the Insights client, add this import to your files:To create an instance of the client:Replace
algoliasearch-scala package.
You can add this package to your build.gradle.kts file:build.gradle.kts
implementation("com.algolia:algoliasearch-client-kotlin:3.28.0")
// You also need to add a KTOR engine as dependency, for example:
implementation("io.ktor:ktor-client-java:$ktor_version")
Kotlin
import com.algolia.client.api.InsightsClient
import com.algolia.client.configuration.*
import com.algolia.client.transport.*
Kotlin
val client = InsightsClient(appId = "ALGOLIA_APPLICATION_ID", apiKey = "ALGOLIA_API_KEY", region = "ALGOLIA_APPLICATION_REGION")
ALGOLIA_APPLICATION_ID_REGION with your Algolia application’s analytics region: us for the United States or de for Europe.
You can check your analytics region in the Infrastructure > Analytics section of the Algolia dashboard.The Insights API client is part of the To use the Insights client, add this import to your files:To create an instance of the client:Replace
algoliasearch-client-php package.
To install this package, run:Command line
composer require algolia/algoliasearch-client-php
PHP
use Algolia\AlgoliaSearch\Api\InsightsClient;
PHP
$client = InsightsClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY', 'ALGOLIA_APPLICATION_REGION');
ALGOLIA_APPLICATION_ID_REGION with your Algolia application’s analytics region: us for the United States or de for Europe.
You can check your analytics region in the Infrastructure > Analytics section of the Algolia dashboard.The Insights API client is part of the To use the Insights client, add this import to your files:To create an instance of the client:Replace The client supports the The method names are the same for synchronous and asynchronous methods.
algoliasearch package.
You can install this package with pip:Command line
pip install 'algoliasearch>=4,<5'
Python
from algoliasearch.insights.client import InsightsClientSync
from json import loads
Python
# In an asynchronous context, you can use InsightsClient instead, which exposes the exact same methods.
client = InsightsClientSync(
"ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION"
)
ALGOLIA_APPLICATION_ID_REGION with your Algolia application’s analytics region: us for the United States or de for Europe.
You can check your analytics region in the Infrastructure > Analytics section of the Algolia dashboard.Async code
To use the Insights client in async environments, add these imports instead:Python
import asyncio
from algoliasearch.insights.client import InsightsClient
async with statement to automatically close open connections.Python
async def run():
async with InsightsClient(ALGOLIA_APPLICATION_ID, ALGOLIA_API_KEY) as client:
# client.search(...)
The Insights API client is part of the To use the Insights client, add this import to your files:To create an instance of the client:Replace
algolia gem.
To install this gem, run:Command line
gem install algolia
Ruby
require "algolia"
Ruby
client = Algolia::InsightsClient.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
ALGOLIA_APPLICATION_ID_REGION with your Algolia application’s analytics region: us for the United States or de for Europe.
You can check your analytics region in the Infrastructure > Analytics section of the Algolia dashboard.The Insights API client is part of the To use the Insights client, add these imports to your files:To create an instance of the client:Replace
algoliasearch-scala package.
You can add this package to your build.sbt file:build.sbt
// For Scala 3:
libraryDependencies += "com.algolia" %% "algoliasearch-scala_3" % "2.27.0"
// For Scala 2:
libraryDependencies += "com.algolia" %% "algoliasearch-scala_2" % "2.27.0"
Scala
import algoliasearch.api.InsightsClient
import algoliasearch.config.*
Scala
val client = InsightsClient(
appId = "ALGOLIA_APPLICATION_ID",
apiKey = "ALGOLIA_API_KEY",
region = Option("ALGOLIA_APPLICATION_REGION")
)
ALGOLIA_APPLICATION_ID_REGION with your Algolia application’s analytics region: us for the United States or de for Europe.
You can check your analytics region in the Infrastructure > Analytics section of the Algolia dashboard.The Insights API client is part of the To use the Insights client, add this import to your files:To create an instance of the client:Make sure to use the region that matches your Algolia application’s analytics region:
algoliasearch-client-swift package.
You can add this package to your Package.swift file:Package.swift
// swift-tools-version: 5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Algolia API clients",
platforms: [
.macOS(.v11)
],
dependencies: [
.package(
url: "https://github.com/algolia/algoliasearch-client-swift.git", from: "9.28.0")
],
targets: [
.executableTarget(
name: "Algolia API clients",
dependencies: [
.product(name: "Insights", package: "algoliasearch-client-swift")
]
)
]
)
Swift
import Insights
Swift
let client = try InsightsClient(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY", region: .us)
region.us for the United States and region.de for Europe.
You can check your analytics region in the Infrastructure > Analytics section of the Algolia dashboard.Analytics region
The Insights API client requires specifying your Algolia application’s analytics region to properly route requests to the correct data center. ReplaceALGOLIA_APPLICATION_REGION with your application’s analytics region:
usfor the United Statesdefor Europe