如何指定Amazon Product API返回的内容

时间:2013-03-13 21:55:27

标签: api node.js amazon-web-services amazon amazon-product-api

我需要我的应用程序快速,所以我想在响应中准确指定我想要的内容,而不是在那里有大量多余的信息。我知道ResponseGroups但是没有一个组限制我得到的信息。如果你看一下my current implementation,它会发回大量与我正在寻找的产品无关的信息。真正的问题是它只是笨重。

有没有办法为每件产品指定非常具体的东西?例如:

  • 格式化价格
  • 名称
  • 链接
  • 图像
  • 描述

我不在乎别的什么。

注意:我正在使用Node-APAC来处理对Amazon Product API的请求。所以它将响应XML转换为JSON。

这是我得到的回报(批量):

{
    ItemSearchResponse: {
        $: {...},
        OperationRequest: [...],
        Items: [
            {
                Request: [...],
                TotalResults: [...],
                TotalPages: [...],
                MoreSearchResultsUrl: [...],
                Item: [
                    {
                        ASIN: [...],
                        DetailPageURL: [...],
                        ItemLinks: [...],
                        SmallImage: [...],
                        MediumImage: [...],
                        LargeImage: [...],
                        ImageSets: [...],
                        ItemAttributes: [...],
                        OfferSummary: [...]
                    },
                    {...},
                    {...},
                    {...},
                    {...}
                ]
            }
        ]
    }
}

我想回来的是:

[
  {
    FormattedPrice: 12.99,
    Name: "The Hitchhiker's Guide to the Galaxy"
    Link: "http://www.amazon.com/Hitchhikers-Guide-Galaxy-Douglas-Adams/dp/0345391802"
    Image: "http://g-ecx.images-amazon.com/images/G/01/ciu/eb/05/0663124128a0de9c79891010.L._AA300_.jpg"
    Description: "<Book-Description>"
  },
  {...},
  {...}
]

1 个答案:

答案 0 :(得分:0)

我认为没有办法明确指出你想要的东西。你必须通过ReponseGroup。在您的情况下,我建议您为ResponseGroup值传递“Small,OfferSummary”。它应该返回你需要的东西,同时保持合理的响应大小。