> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Personalization API client

> Get user profiles built from your personalization strategy.

<Tabs>
  <Tab title="C#">
    The Personalization API client is part of the `Algolia.Search` package.
    To install this package, run:

    ```sh Command line icon=square-terminal theme={"system"}
    dotnet add package Algolia.Search
    ```

    To use the Personalization client, import these namespaces:

    ```cs C# icon=code theme={"system"}
    using Algolia.Search.Clients;
    using Algolia.Search.Http;
    using Algolia.Search.Models.Personalization;
    ```

    To create an instance of the client:

    ```cs C# icon=code theme={"system"}
    var client = new PersonalizationClient(
      new PersonalizationConfig(
        "ALGOLIA_APPLICATION_ID",
        "ALGOLIA_API_KEY",
        "ALGOLIA_APPLICATION_REGION"
      )
    );
    ```

    Replace `ALGOLIA_APPLICATION_REGION` with your Algolia application's analytics region: `us` for the United States or `eu` for Europe.
    You can check your analytics region in the [**Infrastructure > Analytics**](https://dashboard.algolia.com/account/infrastructure/analytics) section of the Algolia dashboard.
  </Tab>

  <Tab title="Dart">
    The Personalization API client is part of the `algoliasearch` package.
    To install this package, run:

    ```sh Command line icon=square-terminal theme={"system"}
    dart pub add algoliasearch
    ```

    To use the Personalization API client, add this import to your files:

    ```dart Dart icon=code theme={"system"}
    import 'package:algolia_client_personalization/algolia_client_personalization.dart';
    ```

    To create an instance of the client:

    ```dart Dart icon=code theme={"system"}
    final client =
      PersonalizationClient(
        appId: 'ALGOLIA_APPLICATION_ID',
        apiKey: 'ALGOLIA_API_KEY',
        region: 'ALGOLIA_APPLICATION_REGION'
    );
    ```
  </Tab>

  <Tab title="Go">
    The Personalization API client is part of the `algoliasearch-client-go` package.
    To install it, run:

    ```sh Command line icon=square-terminal theme={"system"}
    go get github.com/algolia/algoliasearch-client-go
    ```

    To use the Personalization client, add this import to your files:

    ```go Go icon=code theme={"system"}
    import "github.com/algolia/algoliasearch-client-go/v4/algolia/personalization"
    ```

    To create an instance of the client:

    ```go Go icon=code theme={"system"}
    client, err := personalization.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", personalization.US)
    if err != nil {
      // The client can fail to initialize if you pass an invalid parameter.
      panic(err)
    }
    ```

    Make sure to use the region that matches your Algolia application's analytics region:
    `personalization.US` for the United States or `personalization.EU` for Europe.
    You can check your analytics region in the [**Infrastructure > Analytics**](https://dashboard.algolia.com/account/infrastructure/analytics) section of the Algolia dashboard.
  </Tab>

  <Tab title="Java">
    The Personalization API client is part of the `algoliasearch` package.
    You can add this package to your `pom.xml` file for **Maven**:

    ```xml pom.xml icon=code-xml theme={"system"}
    <dependency>
      <groupId>com.algolia</groupId>
      <artifactId>algoliasearch</artifactId>
      <version>4.25.0</version>
    </dependency>
    ```

    or to your `build.gradle` file for **Gradle**:

    ```groovy build.gradle icon=braces theme={"system"}
    implementation 'com.algolia:algoliasearch:4.25.0'
    ```

    To use the Personalization client, add these imports to your files:

    ```java Java icon=code theme={"system"}
    import com.algolia.api.PersonalizationClient;
    import com.algolia.config.*;
    ```

    To create an instance of the client:

    ```java Java icon=code theme={"system"}
    PersonalizationClient client = new PersonalizationClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION");
    ```

    Replace `ALGOLIA_APPLICATION_REGION` with your Algolia application's analytics region: `us` for the United States or `eu` for Europe.
    You can check your analytics region in the [**Infrastructure > Analytics**](https://dashboard.algolia.com/account/infrastructure/analytics) section of the Algolia dashboard.
  </Tab>

  <Tab title="JavaScript">
    The personalization API client is part of the `algoliasearch` package.
    To install this package, run:

    ```sh Command line icon=square-terminal theme={"system"}
    npm install algoliasearch
    ```

    To use the personalization client:

    ```js JavaScript icon=code theme={"system"}
    import { algoliasearch } from "algoliasearch";

    const client = algoliasearch("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY");
    const personalizationClient = client.initPersonalization({ region: "ALGOLIA_APPLICATION_REGION" });
    ```

    Replace `ALGOLIA_APPLICATION_REGION` with your Algolia application's analytics region: `us` for the United States or `eu` for Europe.
    You can check your analytics region in the [**Infrastructure > Analytics**](https://dashboard.algolia.com/account/infrastructure/analytics) section of the Algolia dashboard.

    The `algoliasearch` package includes API clients for the Search, Recommend, Analytics, A/B testing, and Personalization API.
    If you *just* want to use the personalization API client, you can install its package on its own:

    ```sh Command line icon=square-terminal theme={"system"}
    npm install @algolia/client-personalization
    ```

    To use it, run:

    ```js JavaScript icon=code theme={"system"}
    import { personalizationClient } from "@algolia/client-personalization";

    const client = personalizationClient(
      "ALGOLIA_APPLICATION_ID",
      "ALGOLIA_API_KEY",
      "ALGOLIA_APPLICATION_REGION"
    );
    ```
  </Tab>

  <Tab title="Kotlin">
    The Personalization API client is part of the `algoliasearch-client-kotlin` package.
    You can add this package to your `build.gradle.kts` file:

    ```kt build.gradle.kts icon=braces theme={"system"}
    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")
    ```

    To use the Personalization client, add this import to your files:

    ```kt Kotlin icon=code theme={"system"}
    import com.algolia.client.api.PersonalizationClient
    import com.algolia.client.configuration.*
    import com.algolia.client.transport.*
    ```

    To create an instance of the client:

    ```kt Kotlin icon=code theme={"system"}
    val client = PersonalizationClient(appId = "ALGOLIA_APPLICATION_ID", apiKey = "ALGOLIA_API_KEY", region = "ALGOLIA_APPLICATION_REGION")
    ```

    Replace `ALGOLIA_APPLICATION_REGION` with your Algolia application's analytics region: `us` for the United States or `eu` for Europe.
    You can check your analytics region in the [**Infrastructure > Analytics**](https://dashboard.algolia.com/account/infrastructure/analytics) section of the Algolia dashboard.
  </Tab>

  <Tab title="PHP">
    The Personalization API client is part of the `algoliasearch-client-php` package.
    To install this package, run:

    ```sh Command line icon=square-terminal theme={"system"}
    composer require algolia/algoliasearch-client-php
    ```

    To use the Personalization client, add this import to your files:

    ```php PHP icon=code theme={"system"}
    use Algolia\AlgoliaSearch\Api\PersonalizationClient;
    ```

    To create an instance of the client:

    ```php PHP icon=code theme={"system"}
    $client = PersonalizationClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY', 'ALGOLIA_APPLICATION_REGION');
    ```

    Replace `ALGOLIA_APPLICATION_REGION` with your Algolia application's analytics region: `us` for the United States or `eu` for Europe.
    You can check your analytics region in the [**Infrastructure > Analytics**](https://dashboard.algolia.com/account/infrastructure/analytics) section of the Algolia dashboard.
  </Tab>

  <Tab title="Python">
    The Personalization API client is part of the `algoliasearch` package.
    You can install this package with `pip`:

    ```sh Command line icon=square-terminal theme={"system"}
    pip install 'algoliasearch>=4,<5'
    ```

    To use the Personalization client, add this import to your files:

    ```python Python icon=code theme={"system"}
    from algoliasearch.personalization.client import PersonalizationClientSync
    from json import loads
    ```

    To create an instance of the client:

    ```python Python icon=code theme={"system"}
    # In an asynchronous context, you can use PersonalizationClient instead, which exposes the exact same methods.
    client = PersonalizationClientSync(
        "ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION"
    )
    ```

    Replace `ALGOLIA_APPLICATION_REGION` with your Algolia application's analytics region: `us` for the United States or `eu` for Europe.
    You can check your analytics region in the [**Infrastructure > Analytics**](https://dashboard.algolia.com/account/infrastructure/analytics) section of the Algolia dashboard.

    ## Async code

    To use the Personalization client in **async** environments,
    add these imports instead:

    ```python Python icon=code theme={"system"}
    import asyncio
    from algoliasearch.personalization.client import PersonalizationClient
    ```

    The client supports the [`async with`](https://peps.python.org/pep-0492/#asynchronous-context-managers-and-async-with) statement to automatically close open connections.

    ```python Python icon=code theme={"system"}
    async def run():
        async with PersonalizationClient(ALGOLIA_APPLICATION_ID, ALGOLIA_API_KEY) as client:
            # client.search(...)
    ```

    The method names are the same for synchronous and asynchronous methods.
  </Tab>

  <Tab title="Ruby">
    The Personalization API client is part of the `algolia` gem.
    To install this gem, run:

    ```sh Command line icon=square-terminal theme={"system"}
    gem install algolia
    ```

    To use the Personalization client, add this import to your files:

    ```ruby Ruby icon=code theme={"system"}
    require "algolia"
    ```

    To create an instance of the client:

    ```ruby Ruby icon=code theme={"system"}
    client = Algolia::PersonalizationClient.create(
      "ALGOLIA_APPLICATION_ID",
      "ALGOLIA_API_KEY",
      "ALGOLIA_APPLICATION_REGION"
    )
    ```

    Replace `ALGOLIA_APPLICATION_REGION` with your Algolia application's analytics region: `us` for the United States or `eu` for Europe.
    You can check your analytics region in the [**Infrastructure > Analytics**](https://dashboard.algolia.com/account/infrastructure/analytics) section of the Algolia dashboard.
  </Tab>

  <Tab title="Scala">
    The Personalization API client is part of the `algoliasearch-scala` package.
    You can add this package to your `build.sbt` file:

    ```txt build.sbt icon=braces theme={"system"}
    // For Scala 3:
    libraryDependencies += "com.algolia" %% "algoliasearch-scala_3" % "2.27.0"
    // For Scala 2:
    libraryDependencies += "com.algolia" %% "algoliasearch-scala_2" % "2.27.0"
    ```

    To use the Personalization client, add these imports to your files:

    ```scala Scala icon=code theme={"system"}
    import algoliasearch.api.PersonalizationClient
    import algoliasearch.config.*
    ```

    To create an instance of the client:

    ```scala Scala icon=code theme={"system"}
    val client = PersonalizationClient(
      appId = "ALGOLIA_APPLICATION_ID",
      apiKey = "ALGOLIA_API_KEY",
      region = "ALGOLIA_APPLICATION_REGION"
    )
    ```

    Replace `ALGOLIA_APPLICATION_REGION` with your Algolia application's analytics region: `us` for the United States or `eu` for Europe.
    You can check your analytics region in the [**Infrastructure > Analytics**](https://dashboard.algolia.com/account/infrastructure/analytics) section of the Algolia dashboard.
  </Tab>

  <Tab title="Swift">
    The Personalization API client is part of the `algoliasearch-client-swift` package.
    You can add this package to your `Package.swift` file:

    ```swift Package.Swift icon=braces theme={"system"}
    // 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: "Personalization", package: "algoliasearch-client-swift")
          ]
        )
      ]
    )
    ```

    To use the Personalization client, add this import to your files:

    ```swift Swift icon=code theme={"system"}
    import Personalization
    ```

    To create an instance of the client:

    ```swift Swift icon=code theme={"system"}
    let client = try PersonalizationClient(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY", region: .us)
    ```

    Make sure to use the region that matches your Algolia application's analytics region:
    `region.us` for the United States and `region.eu` for Europe.
    You can check your analytics region in the [**Infrastructure > Analytics**](https://dashboard.algolia.com/account/infrastructure/analytics) section of the Algolia dashboard.
  </Tab>
</Tabs>

## Analytics region

The Personalization API client requires specifying your Algolia application's analytics region to properly route requests to the correct data center.

Replace `ALGOLIA_APPLICATION_REGION` with your application's analytics region:

* `us` for the United States
* `eu` for Europe

You can check your analytics region in the [**Infrastructure > Analytics**](https://dashboard.algolia.com/account/infrastructure/analytics) section of the Algolia dashboard.
