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

# Alternative implementations

> Alternative implementations for Algolia's Guides.

If you aren't developing a React or JavaScript app,
you can integrate the Algolia Guides into your app with an API client.

## Installation

The Algolia Guides API Client package is available on the [npm](https://www.npmjs.com/package/@algolia/generative-experiences-api-client) registry.

<CodeGroup>
  ```sh npm theme={"system"}
  npm install @algolia/generative-experiences-api-client
  ```

  ```sh yarn theme={"system"}
  yarn add @algolia/generative-experiences-api-client
  ```
</CodeGroup>

## Usage

### Guide headlines

The `getHeadlines` method lets you retrieve different guides for your app.

```js JavaScript icon=code theme={"system"}
import { createClient } from "@algolia/generative-experiences-api-client";

const client = createClient({
  appId: "ALGOLIA_APPLICATION_ID",
  indexName: "INDEX_NAME",
  searchOnlyAPIKey: "ALGOLIA_API_KEY",
  region: "us",
});

client
  .getHeadlines({
    category: guidesCategory,
  })
  .then((response) => console.log(response));
```

You can dynamically generate headlines using the `getOrGenerateHeadlines` method by passing a `source` parameter.
For this method you must use an API key with the `search` and `addObject` [ACLs](/doc/guides/security/api-keys#access-control-list-acl).

<Check>
  Only use this method on your backend or if you provide a layer of authentication.
</Check>

```js JavaScript icon=code theme={"system"}
import { createClient } from "@algolia/generative-experiences-api-client";

const client = createClient({
  appId: "ALGOLIA_APPLICATION_ID",
  indexName: "INDEX_NAME",
  searchOnlyAPIKey: "ALGOLIA_API_KEY",
  writeAPIKey: "ALGOLIA_API_KEY",
  region: "us",
});

client
  .getOrGenerateHeadlines({
    category: guidesCategory,
    source: "generated",
  })
  .then((response) => console.log(response));
```

#### Parameters

<ParamField body="category" type="string" required>
  The category used for retrieving the headlines.
</ParamField>

<ParamField body="maxHeadlines" type="number" default={4}>
  The number of headlines to display (between 1 and 1000).
</ParamField>

<ParamField body="source" type="&#x22;index&#x22; | &#x22;generated&#x22; | &#x22;combined&#x22;" default="index">
  The source of the headlines.
</ParamField>

<ParamField body="tone" type="&#x22;natural&#x22; | &#x22;friendly&#x22; | &#x22;professional&#x22;" default="natural">
  The tone used by the model.
</ParamField>

<ParamField body="language_code" type="&#x22;en_US&#x22; | &#x22;de_DE&#x22; | &#x22;fr_FR&#x22;" default="en_US">
  The language code used for generating headlines.
</ParamField>

<ParamField body="custom_content" type="string">
  The customized instructions that the model should take into account for generating content,
  for example, to refine the focus of the article, add constraints, or adjust to a target audience.
</ParamField>

<ParamField body="keywords" type="string">
  A list of keywords that the model should highlight in the generated content.
</ParamField>

<ParamField body="onlyPublished" type="boolean" default={true}>
  Whether to only return headlines with generated content.
</ParamField>

### Guide content

The `getContent` method lets you retrieve the content of a guide.

```js JavaScript icon=code theme={"system"}
import { createClient } from "@algolia/generative-experiences-api-client";

const client = createClient({
  appId: "ALGOLIA_APPLICATION_ID",
  indexName: "INDEX_NAME",
  searchOnlyAPIKey: "ALGOLIA_API_KEY",
  region: "us",
});

client
  .getContent({
    objectID: guideID,
  })
  .then((response) => console.log(response));
```

You can dynamically generate the content of a guide using the `getOrGenerateContent` method by passing a `source` parameter.
For this method you must use an API key with the `search` and `addObject` [ACLs](/doc/guides/security/api-keys#access-control-list-acl).

<Note>
  Only use this method on your backend implementation or if you provide a layer of authentication.
</Note>

```js JavaScript icon=code theme={"system"}
import { createClient } from "@algolia/generative-experiences-api-client";

const client = createClient({
  appId: "ALGOLIA_APPLICATION_ID",
  indexName: "INDEX_NAME",
  searchOnlyAPIKey: "ALGOLIA_API_KEY",
  writeAPIKey: "ALGOLIA_API_KEY",
  region: "us",
});

client
  .getOrGenerateContent({
    objectID: guideID,
    source: "generated",
  })
  .then((response) => console.log(response));
```

#### Parameters

<ParamField body="objectID" type="string" required>
  The ID of the guide to retrieve.
</ParamField>

<ParamField body="source" type="&#x22;index&#x22; | &#x22;generated&#x22; | &#x22;combined&#x22;" default="index">
  The source of the guide content.
</ParamField>

<ParamField body="type" type="&#x22;shopping_guide&#x22; | &#x22;category_guide&#x22;" default="shopping_guide">
  If `source` is `generated`: the type of guide to generate.
</ParamField>

<ParamField body="tone" type="&#x22;natural&#x22; | &#x22;friendly&#x22; | &#x22;professional&#x22;" default="natural">
  The tone used by the model.
</ParamField>

<ParamField body="language_code" type="&#x22;en_US&#x22; | &#x22;de_DE&#x22; | &#x22;fr_FR&#x22;" default="en_US">
  The language code used for generating headlines.
</ParamField>

<ParamField body="custom_content" type="string">
  The customised instructions that the model should take into account for generating content,
  for example, to refine the focus of the article, add constraints, or adjust to a target audience.
</ParamField>

<ParamField body="keywords" type="string">
  A list of keywords that the model should highlight in the generated content.
</ParamField>

<ParamField body="onlyPublished" type="boolean" default={true}>
  Whether to only return headlines with generated content.
</ParamField>

### Gather feedback

The `vote` method lets you gather feedback for the guide's headlines or content.

<Note>
  This feature uses the Insights API to gather events related to Guides feedback.
  This requires a a [user token](/doc/guides/sending-events/concepts/usertoken).
</Note>

```js JavaScript icon=code theme={"system"}
import { createClient } from "@algolia/generative-experiences-api-client";

const client = createClient({
  appId: "ALGOLIA_APPLICATION_ID",
  indexName: "INDEX_NAME",
  searchOnlyAPIKey: "ALGOLIA_API_KEY",
  region: "us",
});

client.vote({
  objectID: guideID,
  voteType: "upvote",
  voteTarget: "content",
  userToken: userToken,
});
```

#### Parameters

<ParamField body="objectIDs" type="string" required>
  List of object IDs for which to gather feedback.
</ParamField>

<ParamField body="userToken" type="string" required>
  The user token for computing feedback.
</ParamField>

<ParamField body="voteType" type="string" required>
  The feedback type: `upvote` or `downvote`.
</ParamField>

<ParamField body="voteTarget" type="&#x22;content&#x22; | &#x22;headline&#x22;" default="content">
  The feedback target.
</ParamField>
