Reading Recommended Products

Once a JWT has been retrieved using the /authorize endpoint, you can retrieve recommended items for your Personalized Recommendations, Related Products and Frequently Bought Together ML Models. If an invalid JWT is used, the recommendations endpoint will return an error.

Get Recommendations Endpoint

GET https://service.morphlapis.com/recommendations/<account>/<model>/get

Request Headers Success Response Error Response
Authorization:
<token>
{
    "status": 1,
    "items": [
        {
            "sku": "*******",
            "name": ""*******",
            "brand": ""*******",
            "category": ""*******",
            "description": ""*******",
            "price": ""**.**",
            "original_price": "**.**",
            "image": "https://***",
            "url": "https://***"
        },
        ...
    ]
}
{
    status: 0, 
    error: "Error message"
}

In the above table:

  • <account> represents your unique account number, which can be retrieved from the MorphL Dashboard > API section.
  • <model> is the model's identifier. Allowed values are personalized_recommendations, related_products or bought_together.
  • <token> is the JWT returned by the /authorize endpoint.

The response contains a list of recommended products (items property). Each item has the following properties:

  • product sku, name, brand, category and description
  • price - current price of the item (including discount if the product has one)
  • original_price - original price of the item, before a discount was applied
  • image - link to the item's image
  • url - link to the item's details page.

In the section below you can see examples of retrieving predictions for each model type.

Retrieve recommendations for Personalized Recommendations ML model

GET https://service.morphlapis.com/recommendations/<account>/personalized_recommendations/get

Parameters:

Name Required Description
client_id Yes Unique ID for your users. For models that use Google Analytics or Google Analytics 360 data, this parameter represents the Google Analytics Client ID.
limit No How many recommendations should be returned. Value should be an integer number greater than 0.

Request / response format:

Request Headers Success Response Error Response
Authorization:
<token>
{
    "status": 1,
    "items": [
        {
            "sku": "*******",
            "name": ""*******",
            "brand": ""*******",
            "category": ""*******",
            "description": ""*******",
            "price": ""**.**",
            "original_price": "**.**",
            "image": "https://***",
            "url": "https://***"
        },
        ...
    ]
}
{
    status: 0, 
    error: "Error message"
}

Retrieve recommendations for Related Products ML model

GET https://service.morphlapis.com/recommendations/<account>/related_products/get

Parameters:

Name Required Description
item_sku Yes ID (SKU) for your product.
limit No How many recommendations should be returned. Value should be an integer number greater than 0.

Request / response format:

Request Headers Success Response Error Response
Authorization:
<token>
{
    "status": 1,
    "items": [
        {
            "sku": "*******",
            "name": ""*******",
            "brand": ""*******",
            "category": ""*******",
            "description": ""*******",
            "price": ""**.**",
            "original_price": "**.**",
            "image": "https://***",
            "url": "https://***"
        },
        ...
    ]
}
{
    status: 0, 
    error: "Error message"
}

Retrieve recommendations for Frequently Bought Together ML model

GET https://service.morphlapis.com/recommendations/<account>/bought_together/get

Parameters:

Name Required Description
item_sku Yes ID (SKU) for your product.
limit No How many recommendations should be returned. Value should be an integer number greater than 0.

Request / response format:

Request Headers Success Response Error Response
Authorization:
<token>
{
    "status": 1,
    "items": [
        {
            "sku": "*******",
            "name": ""*******",
            "brand": ""*******",
            "category": ""*******",
            "description": ""*******",
            "price": ""**.**",
            "original_price": "**.**",
            "image": "https://***",
            "url": "https://***"
        },
        ...
    ]
}
{
    status: 0, 
    error: "Error message"
}

Quick start example

Make request using curl:

$ JWT_TOKEN=eyJ0eXAiOi3erdf4iOiJIUzI1NiJ9.eyJpc3MiOiJtb3...
$ ACCOUNT=92726
$ ITEM_SKU=ML018312
$ LIMIT=2

$ curl \
  -X GET \
  -H "Authorization: $JWT_TOKEN" \
  https://service.morphlapis.com/recommendations/${ACCOUNT}/bought_together/get?item_sku=${ITEM_SKU}&limit=${LIMIT}

Example response:

{
    "status": 1,
    "items": [
        {
            "sku": "ML1000957",
            "name": "Notebook",
            "brand": "MorphL",
            "category": "Apparel",
            "description": "A6 format",
            "price": "3.99",
            "original_price": null,
            "image": "https://morphl.io/images/demo/recsys-widget/morphl-mini-notebook.png",
            "url": "https://morphl.io"
        },
        {
            "sku": "ML1003321",
            "name": "Hoodie",
            "brand": "MorphL",
            "category": "Apparel",
            "description": "Unisex",
            "price": "2.9",
            "original_price": "3.9",
            "image": "https://morphl.io/images/demo/recsys-widget/morphl-hoodie-logo.png",
            "url": "https://morphl.io"
        }
    ]
}