Get Recommendations API
Use this API to retrieve recommendations from an AddSearch Recommend block configured in your dashboard.
GET /v1/recommendations/index/{index_public_key}/block/{block_id}
- index_public_key: Your AddSearch index public key.
- block_id: The ID of the Recommend block for which you want recommendations.
See how to configure Recommend blocks in the AddSearch dashboard in the AddSearch Recommend documentation.
Optional Query Parameters
| Parameter | Description | Type | Notes |
|---|---|---|---|
| itemId | The ID of the item to fetch recommendations for | string | Typically, this ID corresponds to the currently viewed item and is extracted from the page source using a CSS selector. If your items use docid as an identifier, it might be the MD5 hash of the item's URL. |
Request Examples
Fetch global recommendations
To retrieve recommendations based on your global widget configuration with no specific item context, omit the itemId parameter:
https://api.addsearch.com/v1/recommendations/index/cfa10522e4ae6987c390ab72e9393908/block/8ddb0998-e38d-4e36-aaaa-214ca49c77bc
Fetch recommendations for a specific item
Include the itemId parameter set to the identifier of the item currently viewed by the user:
https://api.addsearch.com/v1/recommendations/index/cfa10522e4ae6987c390ab72e9393908/block/8ddb0998-e38d-4e36-bbbb-214ca49c77bc?itemId=nf5b7d8nd3325232c485ab72e9376234
Response
The API returns recommendations according to the configuration set in your Recommend block.
For details on the response format and fields, refer to the Search API response reference.