question

Alexey avatar image
Alexey asked zgreathouse Deactivated commented

How to get the whole menu?

Hello, I've checked out API docs and found out that it's impossible to get the whole menu with a few requests. First, I should get Categories, then get Items by each Category, then get ModifierGroups for each Item, then get Modifiers for each ModifierGroup. If I'll have at least 3 categories with 10 items inside, 3 modifierGroups inside each item, and 3 modifiers inside modifierGroup it's gonna be about 300 requests.

How can I get it faster?

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ commented ·

It should be noted that Clover doesn't have the concept of a "menu" per se. IT has inventory, which may or may not correspond to items the merchant has for sale.

0 Likes 0 ·
brokenoval avatar image
brokenoval answered Alexey commented

Use the GET /v3/merchants/{mId}/items API. Modifiers are only different variations of items rather than items themselves.

Expand the fields for modifierGroups (within the same api) and set the limit at 1000 (the max). If you need to expand your menu to include modifiers like 'large', 'small' etc you will have to do this in a separate call ( /v3/merchants/{mId}/modifier_groups).

If the menu is longer than 1000 items you will have to loop through it adjusting the offset by 1000 on each loop. Bearing in mind that you can only do this 16 times per second - so getting multiple menus across different merchants will be difficult, particularity if you expect a few people to be using this. And if its 1 menu with over 10,000 items (I've seen this) you're going to be getting very close to that limit pretty quickly.

Ultimate solution is to maintain your own database of a Merchants inventory and update periodically.

Short version - loop through this: https://api.clover.com/v3/merchants/{...

increment the offset by 1000 for each query, and stop running it when you count[elements] < 1000. If you need the modifiers (with price etc) you'll have to run a second query to get the modifiers and add them to an array you're building on the front end.

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Alexey avatar image Alexey commented ·

Thanks! .

0 Likes 0 ·
sam avatar image
sam Deactivated answered zgreathouse Deactivated commented

You can grab the entire 'menu' [inventory items] with a single request by using the expand params such as categories, modifierGroups, etc on the get all inventory api call. You can get the full list by clicking the expandfield in the api reference: https://sandbox.dev.clover.com/api_do...

example expanded api call: https://apisandbox.dev.clover.com/v3/...

example expanded response:

{
  "elements": [
    {
      "id": "50E499R0QHYRE",
      "hidden": false,
      "itemGroup": {
        "id": "807GYENKD7KVG"
      },
      "name": "Blue Shirt",
      "alternateName": "",
      "code": "4646",
      "sku": "",
      "price": 100,
      "priceType": "FIXED",
      "defaultTaxRates": true,
      "unitName": "",
      "isRevenue": true,
      "modifierGroups": {
        "elements": []
      },
      "categories": {
        "elements": []
      },
      "modifiedTime": 1476298484000
    },
...
3 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ahsan avatar image ahsan commented ·

Hey sam, can you send me the expanded api call. The complete call is not visible on your answer?

0 Likes 0 ·
ahsan avatar image ahsan commented ·

@Sam can you send me the expanded api call. The complete call is not visible on your answer? The api to get complete menu in one call

0 Likes 0 ·
zgreathouse avatar image zgreathouse ahsan commented ·

Ahsan, please refer to our API reference docs here:
https://docs.clover.com/clover-platform/reference#getitems-1

0 Likes 0 ·

Welcome to the
Clover Developer Community