Ai resource (Shop API 19.3)

Note:

Use of the Ai Resource is currently only allowed in a closed beta, and this documentation is provided solely for advanced reference. Once generally available, the APIs will be part of the OCAPI integration layer, and intended to be used to build applications inline with those methods and standards.

Summary

Http Method Resource Description
POST /ai/activities/{activity} Tracks an activity with the given name. The only ones, supported right now are:
  • finishCheckout - requires products ID, price, quantity and the overall basket amount
GET /ai/product_recommendations/{recommender_name} Retunrs AI product recommendations based on the given input product or category ids.

Track Activity

Tracks an activity with the given name. The only ones, supported right now are:

Url

POST https://hostname:port/dw/shop/v19_3/ai/activities/{activity}

Formats

json, xml

Authentication

Name Description
JWT Authentication via Customer JWT token.

Request Document

ActivityRequest

Response Document

ActivityResult

Path Parameters

Parameter Type Description Constraints
activity String ID of the activity mandatory=true, nullable=false

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 CQuotientException

originalStatusCode (Integer)

responseBody (String)

If CQuotient retrieves an error response
404 ActivityNotFoundException

activity (String)

If no activity was found for the given ID

Sample

REQUEST:
POST /dw/shop/v19_3/ai/activities/finishCheckout HTTP/1.1
Host: example.com
Authorization:Bearer eyJfdiI6IjXXXXXX.eyJfdiI6IjEiLCJleHAXXXXXXX.-d5wQW4c4O4wt-Zkl7_fiEiALW1XXXX
Content-Type: application/json
{
  "product":[{
    "id": "sony-kdl-42v4100",
    "price": 3.91,
    "quantity": 1
  },{
    "id": "vizio-gv47lf",
    "price": 43.11,
    "quantity": 2
  }],
  "amount":89.12
}

# in case of success

RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 57

{
  "_v" : "19.3",
  "_type":"activity_result",
  "uuid" : "c02dij-as09dk23od-d23d0sdcwe-90kcwe"
}

Get Product Recommendations

Retunrs AI product recommendations based on the given input product or category ids.

Url

GET https://hostname:port/dw/shop/v19_3/ai/product_recommendations/{recommender_name}?products={String}&categories={String}&uuid={String}&expand={String}&inventory_ids={String}&currency={String}&all_images={Boolean}

Formats

json, xml

Authentication

Name Description
JWT Authentication via Customer JWT token.
None No authentication.

Response Document

ProductRecommendationsResult

Path Parameters

Parameter Type Description Constraints
recommender_name String The recommender name mandatory=true, maxLength=256, minLength=1, nullable=false

Query Parameters

Parameter Type Description Constraints
all_images Boolean The flag that indicates whether to retrieve the whole image model for the returned products.  
categories String A comma separated list of category ids to get the recommendations for  
currency String The currency mnemonic specified for price.  
expand String The expand parameter. A comma separated list with the allowed values (availability, bundled_products, links, promotions, options, images, prices, variations, set_products)  
inventory_ids String The optional inventory list ids, for which the availability should be shown.  
products String A comma separated list of product ids to get the recommendations for  
uuid String A uuid returned from the recommendation system maxLength=256, minLength=1

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 CQuotientException

originalStatusCode (Integer)

responseBody (String)

In case there was an error in communication with the recommendation system.
404 RecommenderNameNotFoundException

recommenderName (String)

In case the recommender name in the URL is unknown.

Sample

#
# Example - Get product recommendations for product "vizio-gv47lf"
#
REQUEST:
GET /dw/shop/v19_3/ai/product_recommendations/demo?products=vizio-gv47lf&expand=prices,images HTTP/1.1
Host: example.com
Accept: application/json

RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
{
    "_v":"19.3",
    "count" : 1,
    "data" : [ {
      "brand" : "Sony",
      "currency" : "USD",
      "id" : "sony-kdl-42v4100",
      "image_groups" : [ {
        "images" : [ {
          "alt" : {
            "en-US" : "Sony Bravia® V-Series 42\" LCD High Definition Television, , large"
          },
          "dis_base_link" : "https://image.demandware.com/dw/image/v2/zzzz_s01/on/demandware.static/-/Sites-electronics-catalog/default/dw11314a21/images/large/sony-kdl-42v4100.jpg",
          "link" : "https://example.com/on/demandware.static/-/Sites-electronics-catalog/default/dw11314a21/images/large/sony-kdl-42v4100.jpg",
          "title" : {
            "en-US" : "Sony Bravia® V-Series 42\" LCD High Definition Television, "
          }
        } ],
        "variation_attributes" : [ ],
        "view_type" : "large"
      }, {
        "images" : [ {
          "alt" : {
            "en-US" : "Sony Bravia® V-Series 42\" LCD High Definition Television, , medium"
          },
          "dis_base_link" : "https://image.demandware.com/dw/image/v2/zzzz_s01/on/demandware.static/-/Sites-electronics-catalog/default/dw6fbbaaf0/images/medium/sony-kdl-42v4100.jpg",
          "link" : "https:///example.com/on/demandware.static/-/Sites-electronics-catalog/default/dw6fbbaaf0/images/medium/sony-kdl-42v4100.jpg",
          "title" : {
            "en-US" : "Sony Bravia® V-Series 42\" LCD High Definition Television, "
          }
        } ],
        "variation_attributes" : [ ],
        "view_type" : "medium"
      }, {
        "images" : [ {
          "alt" : {
            "en-US" : "Sony Bravia® V-Series 42\" LCD High Definition Television, , small"
          },
          "dis_base_link" : "https://image.demandware.com/dw/image/v2/zzzz_s01/on/demandware.static/-/Sites-electronics-catalog/default/dw5e3b6f1e/images/small/sony-kdl-42v4100.jpg",
          "link" : "https://example.com/on/demandware.static/-/Sites-electronics-catalog/default/dw5e3b6f1e/images/small/sony-kdl-42v4100.jpg",
          "title" : {
            "en-US" : "Sony Bravia® V-Series 42\" LCD High Definition Television, "
          }
        } ],
        "variation_attributes" : [ ],
        "view_type" : "small"
      } ],
      "long_description" : {
        "en-US" : "This is HD done the Sony way. The 42\" KDL-42V4100 flat panel HDTV brings 1080p picture quality home with amazing, Sony-exclusive features like the XMB (Xross Media Bar®) with 3D graphics, DMex capability so you can add functionality to your TV, and picture quality technologies like ACE (Advanced Contrast Enhancer) and BRAVIA Engine 2™ that make images come alive. Add to that a sophisticated, piano black design and 24p capability for getting the most out of Blu-ray Disc™ and DVD movies, and you have a television that exceeds your expectations. There are also four HDMI™ inputs and three other HD-capable connections, so there is ample room for expansion."
      },
      "min_order_quantity" : 1,
      "name" : {
        "en-US" : "Sony Bravia® V-Series 42\" LCD High Definition Television"
      },
      "page_description" : {
        "en-US" : "V-Series features: Full HD 1080p, BRAVIA Engine 2™ digital video processing, Advanced Contrast Enhancer circuit (ACE), 24p True Cinema capable, enhanced XMB™ user interface, BRAVIA Sync capable, piano black gloss color "
      },
      "page_keywords" : {
        "en-US" : "Sony"
      },
      "page_title" : {
        "en-US" : "Sony Bravia® V-Series 42\" LCD High Definition Television"
      },
      "price" : 1000.00,
      "prices" : {
        "usd-sale-prices" : 1000.00
      },
      "primary_category_id" : "electronics-televisions-flat-screen",
      "short_description" : {
        "en-US" : "V-Series features: Full HD 1080p, BRAVIA Engine 2™ digital video processing, Advanced Contrast Enhancer circuit (ACE), 24p True Cinema capable, enhanced XMB™ user interface, BRAVIA Sync capable, piano black gloss color "
      },
      "step_quantity" : 1,
      "type" : {
        "item" : true,
        "option" : true
      },
      "c_dimDepth_s" : "12 inches",
      "c_dimHeight_s" : "29 inches",
      "c_dimWeight_s" : "63 lbs",
      "c_dimWidth_s" : "41 inches",
      "c_resolution_s" : "1920 x 1080",
      "c_tabDescription_s" : "V-Series features: Full HD 1080p, BRAVIA Engine 2™ digital video processing, Advanced Contrast Enhancer circuit (ACE), 24p True Cinema capable, enhanced XMB™ user interface, BRAVIA Sync capable, piano black gloss color",
      "c_tabDetails_s" : "This is HD done the Sony way. The 42\" KDL-42V4100 flat panel HDTV brings 1080p picture quality home with amazing, Sony-exclusive features like the XMB (Xross Media Bar®) with 3D graphics, DMex capability so you can add functionality to your TV, and picture quality technologies like ACE (Advanced Contrast Enhancer) and BRAVIA Engine 2™ that make images come alive. Add to that a sophisticated, piano black design and 24p capability for getting the most out of Blu-ray Disc™ and DVD movies, and you have a television that exceeds your expectations. There are also four HDMI™ inputs and three other HD-capable connections, so there is ample room for expansion.",
      "c_tvSignalFormat_s" : "1080p",
      "c_tvSize_s" : "42 inches",
      "c_tvType_s" : "0020"
    } ],
    "total": 1,
}