HomeGuidesAPI Reference
Log In

Cart Search SDK Embedded

Getting your SDK Key


  • To get an API key, book a meeting with us and sign the license agreement. Book a meeting by visiting here

Cart search

Example images

Cart search:


Example checkout:

Minimum: passing name and query

At a minimum, you need to pass your company name and the query. For extra options see "Additional optional query parameters" further down on this page.

Basic query

Basic query is simply a list of items and the quantity you want.

For example:
https://sdk.mealme.ai/cart-search?api=YOUR_NAME&query="Eggs":1,"Milk":1

⚠️ Note: YOUR_NAME will be the name of your company, for sandbox orders use YOUR_NAME-sandbox

Advanced query

With advanced query, you can specify additional parameters such as unit size and package type. The items are passed as an array with objects in JSON format. You may have to encode the query with for example encodeURIComponentin javascript to make it work for all situations. For readability all the following examples will not be encoded.

For example:

https://sdk.mealme.ai/cart-search?api=YOUR_NAME&query=[{"search_term": "Almond Milk", "unit_size": 32, "unit_measurement": "fl oz", "unit_size_filter": "gte"},{"search_term": "Avocado", "unit_size": 2, "unit_measurement": "pound", "unit_package":"bag"}]

Just the query in a more readable format:

[
  {"search_term": "Almond Milk", "unit_size": 32, "unit_measurement": "fl oz", "unit_size_filter": "gte"},
  {"search_term": "Avocado", "unit_size": 2, "unit_measurement": "pound", "unit_package":"bag"}
]

The supported unit_size_filtervalues are the following.

gt, (is greater than)
gte, (is greater than or equal to)
lt, (is less than)
lte, (is less than or equal to)
eq (is equal to)

If nothing is passed, equality (eq) is the default.

The supported unit_measurement values are:

gb
gigabyte
lb
lbs
pound
pounds
unitPound
oz
ozs
ounce
ounces
tsp
tsps
teaspoon
teaspoons
tbsp
tbsps
tablespoon
tablespoons
c
cs
cup
cups
g
gs
gm
gms
gram
grams
mg
mgs
milligram
milligrams
kg
kgs
kilogram
kilograms
pinch
l
liter
litre
litres
liters
ml
mls
milliliter
milliliters
qt
qts
quart
quarts
gal
gals
gallon
gallons
pt
pts
pint
pints
fl
floz
fluid ounce
fluid ounces
ct
cts
count
counts

The supported values for unit_package are:

clove  
cloves 
sprig  
sprigs 
stalk  
stalks 
floret 
florets
can
cans
box
boxes
pc
piece
pieces
pk
pack
packs
package
packages
bag
bags
container
containers
jar
jars
rack
racks
ball
balls
basket
baskets
btl
bottle
bottles
family  
bundle
bundles
bundled
kit
kits
packet
packets
parcel
parcels
assortment
assortments
batch
batches
unit
units
carton
cartons
crate
crates
bowl
bowls
jug
jugs
tub
tubs 

Passing location

If you already have the user's location you can pass that information, this way they would not have to enter their location

Example with location parameters:

https://sdk.mealme.ai/cart-search?api=YOUR_NAME&latitude=LONGITUDE_HERE&longitude=LONGITUDE_HERE&streetNumber=REPLACE&streetName=REPLACE&city=REPLACE&state=REPLACE&zipcode=REPLACE&country=REPLACE&query="Eggs":1,"Milk":1

Additional optional query parameters

  • isPickup - default value of the pickup toggle, true means it's a pickup order, false means it will be a delivery order
  • isOpen - default value of the open toggle, true means searching for only open stores, false means to search for all stores
  • hidePickupToggle - passing true will hide the pickup toggle
  • hideOpenToggle - passing true will hide the open toggle
  • title - If passed, it will show a title above the cart search user interface
  • logoUrl- If passed, a logo will be added, in the top left by default
  • logoHeight- If passed it will change the width of the logo, the default value is 30
  • logoAlignment- Can be used to change the alignment of the logo, accepted values are left, center, and right
  • searchRadius- Normally we gradually increase the radius until we find enough stores, pass if you want to override this and just do one specific search radius, is capped at 10 miles
  • sort- Can be cheapest, fastest, rating, distance, or relevance. The default value if nothing is passed is relevance
  • fullCartsOnly - only show full carts, it's defaulted to false
  • userId- Use your own identifier for userId if you want an order to be related to a certain user or group
  • userEmail- Will prefill the email field in checkout if passed
  • userName- Will prefill the name field in checkout if passed
  • userPhone- Will prefill the phone field in checkout if passed
  • userApartmentNumber- Will prefill the apartment number field in checkout if passed
  • checkoutNotes- Will prefill the notes field in checkout if passed
  • storeType- Pass restaurant for restaurant items, pass grocery for grocery items, or leave empty or exclude to search for both
  • pinCheckoutButton- If passing truethis will pin the checkout button to the bottom element instead of having a floating button
  • combineServiceAndDeliveryFee- If passing true this will combine both the delivery fee and service fee on checkout, both will be listed under the category "Service fee"

Example embed

<iframe 
	src='https://sdk.mealme.ai/cart-search?api=YOUR_NAME&query="Eggs":1,"Milk":1'
	allow="geolocation; payment" 
	title="Mealme Web SDK" 
	style="border: none;height: 100vh;margin-bottom: 0px;position: relative;z-index: 100;margin-top: 40px;width: 100%;">
</iframe>

Capturing events

We fire events that you can catch if you want to read the data.

The events fired from the cart-search checkout flow are the following:

  • Checkout success
  • Checkout failure

If you want to capture events while having the SDK in an App, please follow these instructions, instead of the web examples given below.

Success event

Code to capture success event

window.onmessage = (event) => {
  if (event.data.id === "mealme-checkout-success") {
    // Your code using event.data
  }
}; 

Example data for success event:

{
  success: true,
  orderId: "123",
  items: [
    {
      product_id: "gAAA",
      item_name: "NESCAFÉ Dark Roast Instant Coffee",
      image: "https://cdn-img.mealme.ai/...",
      description: "",
      category: "Coffee",
      price: 1299,
      formatted_price: "$12.99",
      upc_codes: [],
      unit_size: 10.5,
      unit_of_measurement: "oz",
      should_fetch_customizations: true,
    },
    {
      product_id: "gAAAA",
      item_name: "Lactaid Whole Milk",
      image: "https://cdn-img.mealme.ai/...",
      description: "",
      category: "Milk",
      price: 579,
      formatted_price: "$5.79",
      upc_codes: [],
      unit_size: 0.5,
      unit_of_measurement: "gal",
      should_fetch_customizations: true,
    },
  ],
  trackingLink: "https://tracking.mealme.ai/tracking?tracking_id=123",
};

Fail event

Code to capture fail event

window.onmessage = (event) => {
  if (event.data.id === "mealme-checkout-fail") {
    // Your code using event.data
  }
}; 

Example data for fail event:

{
  success: false,
  message: "Something went wrong",
}