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:

Authorizations:
(appIdapiKey)
Request Body schema: application/json
required
Array of baseTrendingItemsQuery (object) or baseTrendingFacetsQuery (object) or baseRecommendationsQuery (object) (recommendationsRequest)

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

Array
One of
facetName
string (facetName)

Facet name for trending models.

facetValue
string

Facet value for trending models.

model
string (trendingItemsModel)
Value: "trending-items"

Trending items model.

object (searchParamsObject)
object (searchParamsObject)
indexName
required
string (indexName)

Algolia index name.

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.

maxRecommendations
integer
Default: 0

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

Responses

Request samples

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

Response samples

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

Get a Recommend rule

Return a Recommend rule.

Authorizations:
(appIdapiKey)
path Parameters
indexName
required
string
Example: myIndexName

Index on which to perform the request.

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

Unique record (object) identifier.

Responses

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.

Authorizations:
(appIdapiKey)
path Parameters
indexName
required
string
Example: myIndexName

Index on which to perform the request.

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

Unique record (object) identifier.

Responses

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.

Authorizations:
(appIdapiKey)
path Parameters
indexName
required
string
Example: myIndexName

Index on which to perform the request.

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

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

Responses

Response samples

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

List Recommend rules

Authorizations:
(appIdapiKey)
path Parameters
indexName
required
string
Example: myIndexName

Index on which to perform the request.

model
required
string (recommendModels)
Enum: "related-products" "bought-together" "trending-facets" "trending-items"
Request Body schema: application/json
query
string (parameters_query)
Default: ""

Full-text query.

context
string

Restricts responses to the specified contextual rule.

page
integer (parameters_page) >= 0

Requested page (the first page is page 0).

hitsPerPage
integer (parameters_hitsPerPage) [ 1 .. 1000 ]
Default: 20

Maximum number of hits per page.

enabled
boolean or null
Default: null

Restricts responses to enabled rules. When absent (default), all rules are retrieved.

requestOptions
Array of objects

Request options to send with the API call.

Responses

Request samples

Content type
application/json
{
  • "query": "",
  • "context": "mobile",
  • "page": 0,
  • "hitsPerPage": 20,
  • "enabled": null,
  • "requestOptions": "{timeouts:{read:20}}\n"
}

Response samples

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