The generated API clients are a work in progress, you can also find our stable clients on the Algolia documentation.

Skip to main content

Recommend API (1.0.0)

Download OpenAPI specification:Download

The Recommend API lets you generate recommendations with several AI models.

Note: You should use Algolia's libraries and tools to interact with the Recommend API. Using the HTTP endpoints directly is not covered by the SLA.

Recommend

Manage recommendations.

Get recommendations and trending items.

Returns results from either recommendation or trending models:

acl: ["search"]
Request Body schema: application/json
required
required
Array of trendingItemsQuery (object) or trendingFacetsQuery (object) or recommendationsQuery (object) or recommendedForYouQuery (object)

Request parameters depend on the model (recommendations or trending).

Array
One of
indexName
required
string

Index name.

facetName
string

Facet name for trending models.

facetValue
string

Facet value for trending models.

object
maxRecommendations
integer
Default: 0

Maximum number of recommendations to retrieve. If 0, all recommendations will be returned.

model
string
Value: "trending-items"

Trending items model.

object
threshold
integer [ 0 .. 100 ]

Recommendations with a confidence score lower than threshold won't appear in results.

Note: Each recommendation has a confidence score of 0 to 100. The closer the score is to 100, the more relevant the recommendations are.

Responses

Request samples

// Initialize the client
var client = new RecommendClient(new RecommendConfig("YOUR_APP_ID", "YOUR_API_KEY"));

// Call the API
var response = await client.GetRecommendationsAsync(
  new GetRecommendationsParams
  {
    Requests = new List<RecommendationsRequest>
    {
      new RecommendationsRequest(
        new RecommendationsQuery
        {
          IndexName = "indexName",
          ObjectID = "objectID",
          Model = Enum.Parse<RecommendationModels>("RelatedProducts"),
          Threshold = 42,
        }
      )
    },
  }
);

Response samples

Content type
application/json
{
  • "results": [
    ]
}

Get a Recommend rule.

Return a Recommend rule.

acl: ["settings"]
path Parameters
indexName
required
string
Example: YourIndexName

Name of the index on which to perform the operation.

model
required
string
Enum: "bought-together" "related-products" "trending-facets" "trending-items"
objectID
required
string
Example: 123

Unique record identifier.

Responses

Request samples

// Initialize the client
var client = new RecommendClient(new RecommendConfig("YOUR_APP_ID", "YOUR_API_KEY"));

// Call the API
var response = await client.GetRecommendRuleAsync(
  "indexName",
  Enum.Parse<RecommendModels>("RelatedProducts"),
  "objectID"
);

Response samples

Content type
application/json
{
  • "_metadata": {
    },
  • "objectID": "hide-12345",
  • "conditions": [
    ],
  • "consequence": {
    },
  • "description": "Display a promotional banner",
  • "enabled": true
}

Delete a Recommend rule.

Delete a Recommend rule.

acl: ["editSettings"]
path Parameters
indexName
required
string
Example: YourIndexName

Name of the index on which to perform the operation.

model
required
string
Enum: "bought-together" "related-products" "trending-facets" "trending-items"
objectID
required
string
Example: 123

Unique record identifier.

Responses

Request samples

// Initialize the client
var client = new RecommendClient(new RecommendConfig("YOUR_APP_ID", "YOUR_API_KEY"));

// Call the API
var response = await client.DeleteRecommendRuleAsync(
  "indexName",
  Enum.Parse<RecommendModels>("RelatedProducts"),
  "objectID"
);

Response samples

Content type
application/json
{
  • "taskID": 1514562690001,
  • "deletedAt": "2023-06-27T14:42:38.831Z"
}

Get a Recommend task's status.

Some operations, such as deleting a Recommend rule, will respond with a taskID value. Use this value here to check the status of that task.

acl: ["editSettings"]
path Parameters
indexName
required
string
Example: YourIndexName

Name of the index on which to perform the operation.

model
required
string
Enum: "bought-together" "related-products" "trending-facets" "trending-items"
taskID
required
integer <int64>
Example: 13235

Unique identifier of a task. Numeric value (up to 64bits).

Responses

Request samples

// Initialize the client
var client = new RecommendClient(new RecommendConfig("YOUR_APP_ID", "YOUR_API_KEY"));

// Call the API
var response = await client.GetRecommendStatusAsync(
  "indexName",
  Enum.Parse<RecommendModels>("RelatedProducts"),
  12345L
);

Response samples

Content type
application/json
{
  • "status": "notPublished"
}

List Recommend rules.

acl: ["settings"]
path Parameters
indexName
required
string
Example: YourIndexName

Name of the index on which to perform the operation.

model
required
string
Enum: "bought-together" "related-products" "trending-facets" "trending-items"
Request Body schema: application/json
context
string

Restricts responses to the specified contextual rule.

boolean or null
hitsPerPage
integer [ 1 .. 1000 ]
Default: 20

Maximum number of hits per page.

page
integer >= 0

Requested page of the API response.

query
string
Default: ""

Search query.

Responses

Request samples

// Initialize the client
var client = new RecommendClient(new RecommendConfig("YOUR_APP_ID", "YOUR_API_KEY"));

// Call the API
var response = await client.SearchRecommendRulesAsync(
  "indexName",
  Enum.Parse<RecommendModels>("RelatedProducts")
);

Response samples

Content type
application/json
{
  • "hits": [
    ],
  • "nbHits": 20,
  • "page": 0,
  • "nbPages": 1
}