How filter item data using search api?

public static function catalogSyncAPI($squareAccount, $objectTypes = null, $cursor = null) {
$squareApi = new Api($squareAccount->getAccessToken());

	$params = [
		"include_deleted_objects" => false,
		"include_related_objects" => true,
		"limit" => 50,
		"object_types" => $objectTypes ? [$objectTypes] : ["CATEGORY"],
	];

	if ($objectTypes === "CATEGORY" || (isset($params['object_types']) && in_array("CATEGORY", $params['object_types']))) {
		$params["query"] = [
			"prefix_query" => [
				"attribute_name" => "name",
				"attribute_prefix" => "CA "
			]
		];
	}

	if ($cursor !== null) {
		$params["cursor"] = $cursor;
	}

	$combinedDetails = $squareApi->searchSquareCatalogObjects($params);

	if ($combinedDetails['status'] === 200) {
		if (isset($combinedDetails['data'])) {
			SplunkLog('Square', "Catalog Data Fetched");
			return $combinedDetails['data'];
		} else {
			$response = $combinedDetails['error'];
			SplunkLog('Square', [
				'error' => $response['errors'][0]['detail'],
				'message' => 'Failed to fetch Square catalog'
			]);
			return null;
		}
	}
	return null;
}

catergories=Map:getbyObject(“CATEGORY”);

Filter Square Catalog Item using Category Ids Using Search Api

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Catalog API
Retrieve Catalog Objects
Call the SearchCatalogItems Endpoint

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

To filter Square Catalog Items using Category IDs, you can use the SearchCatalogObjects endpoint of the Catalog API. You can specify the category_ids filter in the query parameters to filter items by their associated category IDs.

Here is a sample request:

{
  "object_types": ["ITEM"],
  "query": {
    "exact_query": {
      "attribute_name": "category_id",
      "attribute_value": "YOUR_CATEGORY_ID"
    }
  }
}

Replace YOUR_CATEGORY_ID with the ID of the category you want to filter by. This will return all items that are associated with the specified category.

If you want to filter by multiple category IDs, you can use the or_query filter:

{
  "object_types": ["ITEM"],
  "query": {
    "or_query": {
      "filters": [
        {
          "exact_query": {
            "attribute_name": "category_id",
            "attribute_value": "CATEGORY_ID_1"
          }
        },
        {
          "exact_query": {
            "attribute_name": "category_id",
            "attribute_value": "CATEGORY_ID_2"
          }
        }
        // Add more filters as needed
      ]
    }
  }
}

Replace CATEGORY_ID_1 and CATEGORY_ID_2 with the IDs of the categories you want to filter by. This will return all items that are associated with any of the specified categories.

This answer was reviewed by @Bryan-Square.