views:

374

answers:

1

I'm using the amazon-ecs gem to get product details from Amazon, using the itemlookup function (passing the ASIN). While I'm able to get all product details from this function, I'm not sure how to get the product's top level category - for example, if I have a children's book, I want the category as 'book' not fiction or children's book etc.

A: 

I'm not exactly sure how this gets exposed in the amazon-ecs gem, but Amazon's docs state that the BrowseNodes response group will return a list of ancestor nodes, the deepest of which will be the top level category.

    <Item>
  <ASIN>0976925524</ASIN> 
  <BrowseNodes>
    <BrowseNode>
      <BrowseNodeId>69825</BrowseNodeId> 
      <Name>High School</Name> 
      <Ancestors>
        <BrowseNode>
          <BrowseNodeId>10605</BrowseNodeId> 
          <Name>Education</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>

You can check it out here: http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/index.html?FindingBrowseNodes.html

Chris Sears