2

I have been reading over the Square Connect API and messing around with the catalog portion.

I am unable to find how to retrieve all items and their data associated with a particular category. Can someone please point me in the right direction.

I thought it was the

BatchRetrieveCatalogObjects endpoint

I was using the category ID but it was only returning the catalog's data. I need each of the IDs of the items to retrieve their individual data.

I was looking to propagate a list of all the items and their data in one request in JSON.

JSON data to be passed to endpoint:

data = {
                "object_ids": [
                    "category id"
                ],
                "include_related_objects": True
            }

My connection to the API:

 category_item_endpoint =  self.connection.post('/v2/catalog/batch-retrieve', data)

I am using python3 and the requests library.

Corey Gumbs
  • 372
  • 6
  • 13

2 Answers2

3

In order to list items in a category I found it easiest to use the /v2/catalog/search endpoint. Simply follow the documentation on what parameters are accepted. Below are the search parameters that I used to list items by category id.

let sParams: JSON = [
        "object_types": [
            "ITEM"
        ],
        "include_related_objects": true,
        "include_deleted_objects": false,
        "query": [
            "exact_query": [
                "attribute_name": "category_id",
                "attribute_value": id
            ]
        ],
        "limit": 1000
    ]
Donrickie
  • 31
  • 2
1

You'd probably have the most luck listing your entire catalog GET /v2/catalog/list and then applying filtering (in this case specific catagory_ids ) after you get the data. Based on the documentation doing what you desire doesn't seem possible with an endpoint/query combitionation.

tristansokol
  • 4,054
  • 2
  • 17
  • 32