CategoryQueryRq (Request)

The CategoryQueryRq request allows users to retrieve category information from the Fortune3 database. All relevant category information will be included in the response. It can be used to retrieve all of the categories in the ecommerce website, or a single category, or a group of categories based on certain conditions (Filters).

Retrieving All Categories

Although Fortune3 recommends filtering your requests in order to save bandwidth and response lengths, you can retrieve the information for all of the categories on your ecommerce shopping cart. Proceed as follows:

Sample Code:

<sendRequestXML>
<authenticate>
<APIUsername>TWmY6WBft</APIUsername>
<APIPassword>SKW8ssAmDu6xTGDl</APIPassword>
</authenticate>
<CategoryQueryRq RequestID="1" />
</sendRequestXML>

Retrieving Certain Categories (Using Filters)

You can use Filters to limit which categories you get in the response based on certain conditions, and therefore highly optimize the response by shortening it to only include your conditions. Using the <Filters> node, you can specify as many filters as you like that must be matched in order for the Category to be returned in the response. Since you can specify multiple filters within the same request, and each filter can have different settings, you must also specify individual <Filter> nodes for each filter you want to add to your request. Proceed as Follows:

Sample Code (retrieving category with Name “Entertainment”):

<sendRequestXML>
<authenticate>
<APIUsername>TWmY6WBft</APIUsername>
<APIPassword>SKW8ssAmDu6xTGDl</APIPassword>
</authenticate>
<CategoryQueryRq RequestID="1">
  <Filters>
    <Filter>
      <Name>Entertainment</Name>
    </Filter>
  </Filters>
</CategoryQueryRq>
</sendRequestXML>

Available Filters for CategoryQueryRq

Tag Name Sub-Tag Of Description Field Type Can Repeat
Filters CategoryQueryRq The Filters Activation Node Node False
Filter Filters The Current Filter Node Node True
Name Filter Matches the Category Name String True
ParentCategory Filter Matches the Parent Category Name (one level up only) String True

Using Multiple Filters

You can use multiple filters within a single request by either adding the multiple filters to the same <Filter> node, or by adding separate <Filter> nodes for each filter. By using the same <Filter> node to list multiple filters, you cannot add filtering options and you are therefore limited to the default filtering settings, which is to do an “exact” match of the filter, and to separate each filter with an “or”, so that each filter will produce a result independent of the other filters:

Sample Code (Name matches “Televisions” or Name matches “Appliances”):

<sendRequestXML>
<authenticate>
<APIUsername>TWmY6WBft</APIUsername>
<APIPassword>SKW8ssAmDu6xTGDl</APIPassword>
</authenticate>
<CategoryQueryRq RequestID="1">
  <Filters>
    <Filter>
      <Name>Televisions</Name>
      <Name>Appliances</Name>
    </Filter>
  </Filters>
</CategoryQueryRq>
</sendRequestXML>

Filtering Options

However, if you use multiple <Filter> nodes for each filter, you can specify the options for each Filter using Filtering Options.

There are 2 XML tags that you can use on each filter to specify the options for that filter, <FilterMatch> and <FilterStyle>.

The 'FilterMatch' tag is available for every filter type in the CategoryQueryRq and allows you to specify if you would like to do an “exact” match of the filter (the default), or a “contains” match of the filter, making your condition match if the value you send partially matches the result in the databse (where Name contains “Sony”).

The 'FilterStyle' tag is only used if you are using more than one <Filter> node and should only be used for the 2nd filter and on (not for the first). It allows you to specify if the current filter you are sending should be matched with an 'or' parameter when following the previous filter (the default), or an 'and' parameter. Using 'and' will make the current filter match in addition to the previous filter (which is why the first filter should not have it), whereas using 'or' (or omitting the 'FilterStyle' since this is the default value) will make the current filter match, whether or not the previous filter matched.

Tag Name Sub-Tag Of Description Field Type Allowed Values Can Repeat
FilterStyle Filter Specifies if the current filter is
independent from the previous filter
String “or”
“and”
False
FilterMatch Filter Specifies if the current filter must
be an exact match or a “like” match
String “exact”
“contains”
False

Sample Code (Name contains “Sony” or Name contains “Panasonic” and ParentCategory matches “Televisions”):

<sendRequestXML>
<authenticate>
<APIUsername>TWmY6WBft</APIUsername>
<APIPassword>SKW8ssAmDu6xTGDl</APIPassword>
</authenticate>
<CategoryQueryRq RequestID="1">
  <Filters>
    <Filter>
      <Name>Sony</Name>
      <FilterMatch>contains</FilterMatch>
    </Filter>
    <Filter>
      <Name>Panasonic</Name>
      <FilterStyle>or</FilterStyle>(optional)
      <FilterMatch>contains</FilterMatch>(optional)
    </Filter>
    <Filter>
      <ParentCategory>Televisions</ParentCategory>
      <FilterStyle>and</FilterStyle>
      <FilterMatch>exact</FilterMatch>
    </Filter>
  </Filters>
</CategoryQueryRq>
</sendRequestXML>

Using these guidelines, you can fully filter out the CategoryQueryRq response to only provide you with the categories that you need.

Next: Reading the Response (CategoryQueryRs)

Print/export