REST API - Recommendation events


Note

Starting with 7.10 our REST API is documented using Redoc accessible at docs.intershop.com.

URI

/recommendationcontexts/<context-id>/events

Http Method

POST

Short Description

Sends an event to the recommendation engine

Query Parameters

none

Example Requests

/recommendationcontexts/13157ff6-e645-49a6-ba46-7787563d7214/events

HTTP Status Codes

204 No Content (Successful)
400 Bad Request (invalid request data)
403 Forbidden (try to access an order from a different user - [OrderRecommendationEvent])
404 Not found (if Order for given OrderID not found - [OrderRecommendationEvent])

Description

If a recommendation service is configured this sends one of the following events to the recommendation engine:

  • ProductViewRecommendationEvent - The product with given ID [SKU] that has been viewed.
  • BasketRecommendationEvent - The items that have been added to the basket.
  • OrderRecommendationEvent - The items that have been ordered or the order with the given order number which were submitted.
  • SearchRecommendationEvent - A search with given search term has been processed
  • UserToSessionRecommendationEvent - Connects the current recommendation context with the given userid (after login). This event may affect the results of the recommendation requests.

The event can only be dispatched successfully if the installed Recommendation Engines support the event type and if the corresponding back office  preference in "Channel preferences / Recommendation Engines" is activated for the given event type.

The used <contextid> can be any alpha-numeric string. It will be used to distinguish between different users/customers.

Cartridge

app_sf_rest_recomm
Application

B2C Web Shop, SMB Web Shop

Product Version

7.5

Product To Version

 

Status

final

 

 

JSON

Request data format

application/json

Request related java object

com.intershop.component.recommendation.capi.rest.resource.EventRecommendationsListResource
com.intershop.component.recommendation.capi.rest.resourceobject.RecommendationEventRO
com.intershop.component.recommendation.capi.rest.resourceobject.ProductViewRecommendationEventRO
com.intershop.component.recommendation.capi.rest.resourceobject.BasketRecommendationEventRO
com.intershop.component.recommendation.capi.rest.resourceobject.OrderRecommendationEventRO
com.intershop.component.recommendation.capi.rest.resourceobject.SearchRecommendationEventRO
com.intershop.component.recommendation.capi.rest.resourceobject.UserRecommendationEventRO

Request data example

Send the "ProductViewRecommendationEvent":

{
    "type": "ProductViewRecommendationEvent",
    "productID": "123456"
}

Send the "BasketRecommendationEvent":

{
    "type": "BasketRecommendationEvent",
    "items": [
        {
            "type": "BasketLineItem",
            "productID": "3957286",
            "quantity": 2
        },
        {
            "type": "BasketLineItem",
            "productID": "M7972533",
            "quantity": 1
        },
        {
            "type": "BasketLineItem",
            "productID": "4555724",
            "quantity": 3
        }
    ]
}

Send the "OrderRecommendationEvent":

Alternative 1 - via OrderID:
The header must include a valid header value "Authorization" or "authentication-token" for the owner of the order.

{
    "type": "OrderRecommendationEvent",
    "orderID": "NvwKDgAbqUcAAAFHPnBiREkK"
}

Alternative 2 - via Items:
No authorization required

 {
    "type": "OrderRecommendationEvent",
    "items": [
        {
            "type": "BasketLineItem",
            "productID": "3957286",
            "quantity": 2
        },
        {
            "type": "BasketLineItem",
            "productID": "M7972533",
            "quantity": 1
        },
        {
            "type": "BasketLineItem",
            "productID": "4555724",
            "quantity": 3
        }
    ]
}

Send the "SearchRecommendationEvent":

{
    "type": "SearchRecommendationEvent",
    "searchTerm": "Acer"
}

Send the "UserToSessionRecommendationEvent":

{
    "type": "UserRecommendationEvent",
    "userID": "patricia"
}

Response data format

application/json

Response related java object

com.intershop.component.recommendation.capi.rest.resource.EventRecommendationsListResource

Response data example

No response data

XML

Request data format

text/xml

Request related java object

com.intershop.component.recommendation.capi.rest.resource.EventRecommendationsListResource
com.intershop.component.recommendation.capi.rest.resourceobject.RecommendationEventRO
com.intershop.component.recommendation.capi.rest.resourceobject.ProductViewRecommendationEventRO
com.intershop.component.recommendation.capi.rest.resourceobject.BasketRecommendationEventRO
com.intershop.component.recommendation.capi.rest.resourceobject.OrderRecommendationEventRO
com.intershop.component.recommendation.capi.rest.resourceobject.SearchRecommendationEventRO
com.intershop.component.recommendation.capi.rest.resourceobject.UserRecommendationEventRO

Request data example

Send the "ProductViewRecommendationEvent":

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProductViewRecommendationEvent type="ProductViewRecommendationEvent">
    <productID>123456</productID>
</ProductViewRecommendationEvent>

Send the "BasketRecommendationEvent":

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<BasketRecommendationEvent type="BasketRecommendationEvent">
    <BasketLineItems>
        <item type="BasketLineItem">
            <productID>3957286</productID>
            <quantity>2</quantity>
        </item>
        <item type="BasketLineItem">
            <productID>M7972533</productID>
            <quantity>1</quantity>
        </item>
        <item type="BasketLineItem">
            <productID>4555724</productID>
            <quantity>3</quantity>
        </item>
    </BasketLineItems>
</BasketRecommendationEvent>

Send the "OrderRecommendationEvent":

Alternative 1 - via OrderID:
The header must include a valid header value "Authorization" or "authentication-token" for the owner of the order.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OrderRecommendationEvent type="OrderRecommendationEvent">
    <orderID>NvwKDgAbqUcAAAFHPnBiREkK</orderID>
</OrderRecommendationEvent>

Alternative 2 - via Items:
No authorization required

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OrderRecommendationEvent type="OrderRecommendationEvent">
    <OrderedItems>
        <item type="BasketLineItem">
            <productID>3957286</productID>
            <quantity>2</quantity>
        </item>
        <item type="BasketLineItem">
            <productID>M7972533</productID>
            <quantity>1</quantity>
        </item>
        <item type="BasketLineItem">
            <productID>4555724</productID>
            <quantity>3</quantity>
        </item>
    </OrderedItems>
</OrderRecommendationEvent>

Send the "SearchRecommendationEvent":

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<SearchRecommendationEvent type="SearchRecommendationEvent">
    <searchTerm>Acer</searchTerm>
</SearchRecommendationEvent>

Send the "UserToSessionRecommendationEvent":

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<UserRecommendationEvent type="UserRecommendationEvent">
    <userID>patricia</userID>
</UserRecommendationEvent>

Response data format

text/xml

Response related java object

com.intershop.component.recommendation.capi.rest.resource.EventRecommendationsListResource

Response data example

No response data

Disclaimer

The information provided in the Knowledge Base may not be applicable to all systems and situations. Intershop Communications will not be liable to any party for any direct or indirect damages resulting from the use of the Customer Support section of the Intershop Corporate Web site, including, without limitation, any lost profits, business interruption, loss of programs or other data on your information handling system.

Customer Support
Knowledge Base
Product Resources
Tickets