Traversing the Browse Node Hierarchy
As we have seen, you traverse down the hierarchy to make your search more targeted. You might also traverse up the tree to find, for example, the root category of a product. For example, if you have an item, such as a carving knife, you might find the node it is associated with and go up the hierarchy to find the root product category of knives and then, in another request, use the TopSellers response group to return the top sellers in the product category. These top sellers might be of interest to your customer.
BrowseNodeLookup operation is the most direct way of traversing the browse node hierarchy. When you supply it a browse node ID, it returns the name of the browse node as well as its direct descendants and a lineage of ancestors. Look at the response to the following request.
http://ecs.amazonaws.com/onca/xml?
Service=AWSECommerceService&
AWSAccessKeyId=[Access Key ID&
Operation=BrowseNodeLookup
&
BrowseNodeId=11232&
ResponseGroup=BrowseNodeInfo
A snippet of its response follows.
<Item> <ASIN>0131856340</ASIN> <BrowseNodes> <BrowseNode> <BrowseNodeId>11232</BrowseNodeId> <Name> Social Sciences</Name> <Ancestors> <BrowseNode> <BrowseNodeId>53</BrowseNodeId> <Name>Nonfiction</Name> <Ancestors> <BrowseNode> <BrowseNodeId>1000</BrowseNodeId> <Name>Subjects</Name> <Ancestors> <BrowseNode> <BrowseNodeId>283155</BrowseNodeId> <Name>Books</Name> </BrowseNode> </Ancestors> </BrowseNode> </Ancestors> </BrowseNode> </Ancestors> <Children> <BrowseNode> <BrowseNodeId>11233</BrowseNodeId> <Name>Anthropology</Name> </BrowseNode> <BrowseNode> <BrowseNodeId>11242</BrowseNodeId> <Name>Archaeology</Name> </BrowseNode> <BrowseNode> <BrowseNodeId>3048861</BrowseNodeId> <Name>Children's Studies</Name> </BrowseNode> </Children> </BrowseNodes>
Traversing down the tree is easy enough: select the browse node ID that is
relevant and repeat the BrowseNodeLookup
operation until you
descend to the appropriate browse node.
Traversing up the tree is similar. Although the BrowseNodeLookup operation, by default, returns the complete ancestral lineage of the subject browse node, there is a limitation: the request only returns one parent browse node for each node. That is, if a node has more than one parent, the response will only show one of the parent nodes. Which one it returns is arbitrary. For that reason, you might want to traverse up the browse node hierarchy one level at a time.
Related Topics