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

# Get trending facets

> Retrieve trending facet values for a specific facet attribute.

export const Legacy = ({title, href}) => {
  return <Note>

    This page documents an earlier version of the API client.
    For the latest version, see <a href={href}>{title}</a>.

    </Note>;
};

<Legacy title="Retrieve recommendations" href="/doc/libraries/sdk/methods/recommend/get-recommendations" />

**Required ACL:** `search`

<Note>
  This method is only available in the JavaScript API client.
</Note>

## Examples

```js JavaScript icon=code theme={"system"}
recommendClient
  .getTrendingFacets([
    {
      indexName: "INDEX_NAME",
      threshold: 80,
      facetName: "movie_genre",
    },
  ])
  .then(({ results }) => {
    console.log(results);
  })
  .catch((err) => {
    console.log(err);
  });
```

## Parameters

<ParamField body="requests" type="object[]" required>
  <Expandable>
    <ParamField body="facetName" type="string" required>
      The facet attribute to get recommendations for.
    </ParamField>

    <ParamField body="indexName" type="string" required>
      The name of the target index.
    </ParamField>

    <ParamField body="maxRecommendations" type="integer">
      The number of recommendations to retrieve.
      Depending on the available recommendations and the other request parameters,
      the actual number of hits may be lower than that.
      If `maxRecommendations` isn't provided or set to 0,
      all matching recommendations are returned, and no fallback request is performed.
    </ParamField>

    <ParamField body="threshold" type="number">
      Threshold for the recommendations confidence score (between 0 and 100).
      Only recommendations with a greater score are returned.
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="results" type="object[]">
  List of #{result}s in the order they were submitted, one per query.

  **Example:**

  ```jsonc JSON icon=braces theme={"system"}
  {
    "results": [
      {
        "hits": [
          {
            // ...,
            "_score": 32.72
          }
        ],
      },
    ]
  }
  ```

  <Expandable>
    <ResponseField name="_score" type="number">
      The confidence score of the recommended facet value, the closer it's to 100, the more relevant.
    </ResponseField>
  </Expandable>
</ResponseField>

### Response as JSON

This section shows the JSON response returned by the API.
Each API client wraps this response in language-specific objects, so the structure may vary.
To view the response, use the `getLogs` method.
Don't rely on the order of properties—JSON objects don't preserve key order.

```jsonc JSON icon=braces theme={"system"}
{
  "results": [
    {
      "exhaustiveNbHits": true,
      "exhaustiveTypo": true,
      "hits": [
        {
          "_score": 98,
          "facetName": "movie_genre",
          "facetValue": "adventure"
        },
        {
          "_score": 91.02,
          "facetName": "movie_genre",
          "facetValue": "action"
        },
        {
          "_score": 82,
          "facetName": "movie_genre",
          "facetValue": "thriller"
        }
      ],
      "hitsPerPage": 1000,
      "nbHits": 3,
      "nbPages": 1,
      "page": 0
    }
  ]
}
```
