Search code examples
amazon-product-api

How to retrieve all book categories from Amazon by ASIN?


Could anybody tell how to retrieve list of categories from a book by ASIN like this website does?


Solution

  • Use the Amazon Product Advertising API v5 for this. Create a GetItems request with the ASIN (e.g 1641521198) as ItemsId and request the BrowserNoteInfo.BrowserNodes and BrowserNoteInfo.BrowserNodes.Ancestor as ressources.

    The response will look like the following:

    {
     "ItemsResult": {
      "Items": [
       {
        "ASIN": "1641521198",
        "BrowseNodeInfo": {
         "BrowseNodes": [
          {
           "Ancestor": {
            "Ancestor": {
             "Ancestor": {
              "Ancestor": {
               "ContextFreeName": "Books",
               "DisplayName": "Books",
               "Id": "283155"
              },
              "ContextFreeName": "Subjects",
              "DisplayName": "Subjects",
              "Id": "1000"
             },
             "ContextFreeName": "Cookbooks, Food & Wine",
             "DisplayName": "Cookbooks, Food & Wine",
             "Id": "6"
            },
            "ContextFreeName": "Baking",
            "DisplayName": "Baking",
            "Id": "4196"
           },
           "ContextFreeName": "Bread Baking",
           "DisplayName": "Bread",
           "Id": "4197",
           "IsRoot": false
          },
          {
           "Ancestor": {
            "Ancestor": {
             "Ancestor": {
              "Ancestor": {
               "ContextFreeName": "Books",
               "DisplayName": "Books",
               "Id": "283155"
              },
              "ContextFreeName": "Subjects",
              "DisplayName": "Subjects",
              "Id": "1000"
             },
             "ContextFreeName": "Cookbooks, Food & Wine",
             "DisplayName": "Cookbooks, Food & Wine",
             "Id": "6"
            },
            "ContextFreeName": "Cooking by Ingredient",
            "DisplayName": "Cooking by Ingredient",
            "Id": "4208"
           },
           "ContextFreeName": "Natural Food Cooking",
           "DisplayName": "Natural Foods",
           "Id": "4340",
           "IsRoot": false
          },
          {
           "Ancestor": {
            "Ancestor": {
             "Ancestor": {
              "Ancestor": {
               "ContextFreeName": "Books",
               "DisplayName": "Books",
               "Id": "283155"
              },
              "ContextFreeName": "Subjects",
              "DisplayName": "Subjects",
              "Id": "1000"
             },
             "ContextFreeName": "Cookbooks, Food & Wine",
             "DisplayName": "Cookbooks, Food & Wine",
             "Id": "6"
            },
            "ContextFreeName": "Main Courses & Side Dishes",
            "DisplayName": "Main Courses & Side Dishes",
            "Id": "4234"
           },
           "ContextFreeName": "Garnishing Meals",
           "DisplayName": "Garnishes",
           "Id": "7696136011",
           "IsRoot": false
          }
         ]
        },
        "DetailPageURL": "https://www.amazon.com/dp/1641521198?tag=getabstractcom&linkCode=ogi&th=1&psc=1"
       }
      ]
     }
    }
    

    With that data you should be able to determinate the categories such as Books » Cookbooks, Food & Wine » Baking » Bread Baking or Books » Cookbooks, Food & Wine » Main Courses & Side Dishes » Garnishing Meals

    More information about the PAAPI5 you find here. There exists as well some SDK for different programming languages such as Java, PHP, Node or Python.