Add Items To Cart

Add Items to Cart

POST https://graph.whisk.com/v1/:id/items

Add new items to an existing cart.

Path Parameters

NameTypeDescription

id

string

Unique cart identifier

Request Body

NameTypeDescription

items

array

An array of ShoppingCartItem objects, containing either Raw text or specific SKU of the store item.

combineItemts

boolean

Whether to combine the new items into the existing ones. Default value: true

{
  "id": "b35ababeefa0452ebd9bac430417254d",
  "retailer": {
    "id": "898003be304e49b084ac6224adc7ff53",
    "name": "Tesco",
    "displayName": "Tesco",
    "country": "GB",
    "currency": "GBP",
    "logo": {
      "url": "https://res.cloudinary.com/whisk/image/upload/whisk3/supermarket_select_dropdown/tesco-logo.png",
      "width": 134,
      "height": 36
    },
    "urls": {
      "signupUrl": "https://secure.tesco.com/account/en-GB/register",
      "forgotPasswordUrl": "https://secure.tesco.com/account/en-GB/forgotten-password",
      "trolleyUrl": "https://www.tesco.com/groceries/en-GB/slots"
    }
  },
  "items": [
    {
      "id": "28c47e7684704e73bce11b74300dc6b7",
      "sourceList": [
        {
          "name": "1 egg",
          "groupId": "f4e354c79e984fe6bad72a9f8e0e0de9"
        },
        {
          "name": "4 large eggs"
        },
        {
          "name": "4 eggs",
          "groupId": "a0316893c5404d689fe91f9f2adbebc3"
        }
      ],
      "product": {
        "sku": "299626009",
        "name": "Tesco 15 Eggs",
        "quantity": {
          "count": 1
        },
        "price": {
          "list": 1.19
        },
        "images": [
          {
            "url": "https://img.tesco.com/Groceries/pi/043/5057545736043/IDShot_540x540.jpg"
          }
        ],
        "url": "https://www.tesco.com/groceries/en-GB/products/299626009"
      },
      "combined": {
        "name": "9 egg"
      }
    },
    ...
    {
      "id": "0a33e8d087ce4de4a188e2f504a087ea",
      "sourceList": [
        {
          "name": "2 tsp rapeseed oil",
          "groupId": "a0316893c5404d689fe91f9f2adbebc3"
        }
      ],
      "product": {
        "sku": "281921684",
        "name": "Tesco Organic Rapeseed Oil 500Ml",
        "quantity": {
          "count": 1
        },
        "price": {
          "list": 1.5
        },
        "images": [
          {
            "url": "https://img.tesco.com/Groceries/pi/749/0000003243749/IDShot_540x540.jpg"
          }
        ],
        "url": "https://www.tesco.com/groceries/en-GB/products/281921684"
      }
    }
  ],
  "groups": [
    {
      "id": "a0316893c5404d689fe91f9f2adbebc3",
      "type": "Recipe",
      "displayName": "Omelette pancakes with tomato & pepper sauce",
      "recipe": {
        "id": "9773cb7eca5d11e7ae7e42010a9a0035",
        "name": "Omelette pancakes with tomato & pepper sauce",
        "description": "Healthy, low-calorie and gluten-free - these herby egg 'pancakes' will become your go-to favourite for a quick midweek meal",
        "ingredients": [
          {
            "text": "4 large eggs"
          },
          {
            "text": "handful basil leaves"
          },
          {
            "text": "2 tsp rapeseed oil, plus a little extra for the pancakes"
          },
          {
            "text": "1 yellow pepper, quartered, deseeded and thinly sliced"
          },
          {
            "text": "2 garlic cloves, thinly sliced"
          },
          {
            "text": "1 tbsp cider vinegar"
          },
          {
            "text": "400g can chopped tomatoes"
          },
          {
            "text": "wholemeal bread or salad leaves, to serve"
          }
        ],
        "images": [
          {
            "url": "https://www.bbcgoodfood.com/sites/default/files/styles/recipe/public/recipe_images/omelette-pancakes-with-tomato-pepper-sauce.jpg",
            "responsive": {
              "url": "https://whisk-res.cloudinary.com/image/upload/v1523012138/recipe/758058656142eaae402f1781e18c527c.jpg",
              "width": 500,
              "height": 454
            }
          }
        ],
        "videos": [],
        "source": {
          "name": "bbcgoodfood.com",
          "displayName": "BBC Good Food",
          "sourceRecipeUrl": "https://www.bbcgoodfood.com/recipes/omelette-pancakes-tomato-pepper-sauce",
          "license": "Fairuse",
          "image": {
            "url": "http://whisk-res.cloudinary.com/image/upload/v1527610208/publishers/logos/bbcgoodfood-logo.png",
            "responsive": {
              "url": "http://whisk-res.cloudinary.com/image/upload/v1527610208/publishers/logos/bbcgoodfood-logo.png",
              "width": 256,
              "height": 256
            }
          }
        },
        "numberOfServings": 2
      }
    },
    ...
  ],
  "created": 1532503799,
  "expiresIn": 1533108599,
  "labels": {
    "myId": "some value"
  }
}

Sample Request

curl -X POST "https://graph.whisk.com/v1/:id/items" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Token Access-Token>" \
  -d '{
    "items": [
      {
        "raw": {
          "name": "4 large eggs"
        }
      }
    ]
  }'

Combined Items

An automatic combination of items is enabled by default. All cart items will be recombined considering the new items. Use combineItems = false to disable it.

More about combined items here.

Parameters

ATTRIBUTE

TYPE

DESCRIPTION

id*

string

unique cart id

items

Raw text or specific SKU of a store item

combineItems

boolean

need to recombine cart items considering new items

ShoppingCartItem

ATTRIBUTE

TYPE

DESCRIPTION

storeItem

StoreItemValue

raw

RawItemValue

StoreItemValue

ATTRIBUTE

TYPE

DESCRIPTION

sku*

string

item identifier in Retailer

quantity

integer

number of items to checkout Default value: 1

source

CartItemSource

source for store product

RawItemValue

ATTRIBUTE

TYPE

DESCRIPTION

name*

string

raw item text. Example: 1 tbsp sugar

Response

ATTRIBUTE

TYPE

DESCRIPTION

id*

string

unique cart identifier

retailer*

Retailer

store details

items*

array [CartItemResponse]

matched products

groups*

array [CartGroupResponse]

ingredients can be grouped by recipe or another arbitrary group

created*

long

time of cart creation; in Unix timestamp format (seconds)

expiresIn

long

The time when cart will be expired; in Unix timestamp format (seconds)

CartItemResponse

ATTRIBUTE

TYPE

DESCRIPTION

id*

string

unique cart item identifier

sourceList*

array [CartItemSource]

list of original ingredients related to the current item

product

CartProductOption

store item

combined

array [CombinedProductsInfo]

information about combined items, if items were combined by a similar product

analysis

object

Analysis for cart item (category, product canonical name)

CartProductOption

ATTRIBUTE

TYPE

DESCRIPTION

sku*

string

store item identifier

name*

string

store item name

quantity*

CartProductQuantity

quantity of product items

price

CartItemPrice

price for the number of products

images*

array [ImageContainer]

url

string

link to the product page in the store

CartGroupResponse

ATTRIBUTE

TYPE

DESCRIPTION

id*

string

The unique cart group identifier

type*

enum

ingredients can be grouped by recipe or custom group Possible values: Recipe, Custom.

displayName*

string

group display name

recipe

RecipeDetails

recipe details

CartItemPrice

ATTRIBUTE

TYPE

DESCRIPTION

list*

double

list price

CartItemSource

ATTRIBUTE

TYPE

DESCRIPTION

name*

string

source item text

groupId

string

group identifier

CartProductQuantity

ATTRIBUTE

TYPE

DESCRIPTION

count*

integer

number of items

CombinedProductsInfo

ATTRIBUTE

TYPE

DESCRIPTION

name*

string

name of combined items

Last updated