Call the SearchCatalogObjects Endpoint

Applies to: Catalog API

Learn how to programmatically search for objects of any type.

Link to section

Overview

You can call the SearchCatalogObjects endpoint to search for catalog objects of any type using the following query filters assigned as a query parameter value:

  • An exact_query filter of the CatalogQueryExact type returns any types of objects matching a specified attribute name and value exactly.
  • A prefix_query filter of the CatalogQueryPrefix type returns any types of objects matching a specified prefix of a given attribute value.
  • A range_query filter of the CatalogQueryRange type returns any types of objects matching a specified numerical range of a given attribute value.
  • A text_query filter of the CatalogQueryText type returns any types of objects matching specified keywords against searchable attribute values. Searchable attributes include name and description.
  • A sorted_attribute_query expression of the CatalogQuerySortedAttribute type sorts returned results in a specified order by a specified attribute.
  • An items_for_tax_query filter of the CatalogQueryItemsForTax type returns items with specified tax payer IDs.
  • An items_for_modifier_list_query filter of the CatalogQueryItemsForModifierList type returns items enabled with specified modifier lists as identified by their IDs.
  • An items_for_item_options filter of the CatalogQueryItemsForItemOptions type returns items with specified item options as identified by their IDs.
  • An items_variations_for_item_option_values_query filter of the CatalogQueryItemVariationsForItemOptionValues type returns item variations with specified item option values as identified by their IDs.

In addition, you can call the SearchCatalogObjects endpoint to search for catalog objects by matching values of the following system attributes:

  • A begin_time attribute returns objects last modified since the specified time.
  • An include_deleted_objects attribute of a Boolean value returns objects that include deleted objects (true) or not (false) matching other specified query filters.
  • An include_related_objects attribute of a Boolean flag returns (true) or not (false) objects related to those matching other specified query filters.
  • An object_types attribute returns objects of the specified types matching other specified query filters.

Unlike with the SearchCatalogItems endpoint, you cannot call SearchCatalogObjects while using any custom attribute query filters.

Link to section

Search with an exact query filter

To search for catalog objects of a known attribute name and value, call the SearchCatalogObjects endpoint while supplying the exact_query filter in the query parameter.

This is illustrated in the following cURL examples.

Link to section

Request

The following cURL example searches for catalog objects with the name attribute having a value of coffee:

Search catalog objects

With the exact query filter, attribute names of objects are matched against the specified attribute name exactly. However, matching the values of objects against the specified attribute value isn't case-sensitive.

Link to section

Response

The successful response returns the result similar to the following, if queried objects are found. Otherwise, the response payload is an empty JSON object.

Link to section

Search with a combination of query filters

You can combine a query with other search conditions to return the result that satisfies all the specified query expressions and search conditions.

Link to section

Request

The following cURL example shows how to call the SearchCatalogObjects endpoint to search for objects of the ITEM_VARIATION type matching their name attribute value to coffee, without including any related object:

Search catalog objects

Link to section

Response

Because the include_related_objects flag is set to true, the related_objects is included in the result. If this flag isn't set or set to false, the related items aren't returned.

Link to section

Search with a prefix query filter

To search for catalog objects with a given attribute value starting with a specified text string, call SearchCatalogObject while supplying a prefix_query filter in the query parameter.

Link to section

Request

The following example searches for objects whose name attribute starts with the text of "sma":

Search catalog objects

Link to section

Response

The response returns the Small item variation available for search at the time of the call. Notice that matching against the specified attribute value is case-insensitive.

Link to section

Request

As another example, try to search for objects with "happy" as a prefix to the name attribute value:

Search catalog objects

Link to section

Response

This call returns a catalog pricing rule object named Happy Hour, which is the only matching object in this catalog.

Link to section

Search with a text query filter

Search with a text_query filter is like free-text search that returns objects by matching searchable attribute values of objects against the specified list of keywords. The search result doesn't depend on the order of the keywords specified.

Link to section

Request

The following example uses a text_query filter to search for objects containing the words "one", "free", and "drink" in any of their searchable attributes:

Search catalog objects

Link to section

Response

The result is a CatalogPricingRule object named "Buy One Drink Get One Free Pricing". Apparently, this is the only object matching the query filter in this particular catalog.

Link to section

Search with items for a modifier list filter

The SearchCatalogObjects endpoint also supports searching for catalog items with the specified modifier list enabled. To do so, use the items_for_modifier_list_query filter in the query parameter. The filter defines the IDs of modifier lists enabled for the items.

Link to section

Request

The following example searches for the catalog items that have a specific modifier list (["ZVSGY6U63IGCZQL4IOPZAKYW"]) enabled. The specified modifier list is named Milk Options and contains two modifiers defined for the Skim Milk and Whole Milk variations enabled for the item.

Search catalog objects

Link to section

Response

The successful response returns the result similar to the following, if the queried objects are found:

The search returns the Coffee item for which the specified modifier list (as identified by the modifier list ID of ZVSGY6U63IGCZQL4IOPZAKYW) is enabled.

Link to section

Search for deleted objects

When a catalog object is deleted, its is_deleted attribute is set to true. To retrieve a deleted object, you can set include_deleted_objects to true when calling the SearchCatalogObjects endpoint and then inspect the result to filter those with "is_deleted": true.

Link to section

Request

The following example searches for the catalog items that can include the deleted ones:

Search catalog objects

Link to section

Response

The successful response returns deleted catalog items, if any, along with active ones. This is shown in the following example: