amazon-product-api - 如何在 Amazon PAAPI5 中获取替代版本的图书列表(获取精装、纸质包装、大众市场版本的图书列表)?
问题描述
亚马逊产品广告 API 的第 4 版让您可以使用 AlternateVersions 响应组来获取相关产品,对于书籍,您可以获取书籍列表的所有不同格式(精装本、平装本、大众市场等)
由于某种原因,API 的第 5 版没有 AlternateVersions。有什么方法可以在 PAAPI5 中获得不同版本的书吗?
解决方案
我有同样的问题。就我而言,我只需要一本书的精装版和 Kindle 版。
GetVariations
( 的继任者AlternateVersions
) 出于某种原因不适用于书籍,并且不返回任何结果。
我知道的唯一可能的方法是执行两个 API 请求(SearchItems),包括用于书籍的特定搜索索引Books和用于 Kindle 文件的KindleStore 。不指定搜索索引通常只会返回图书搜索索引的硬拷贝。
要区分书籍和 kindle 版本,请检查ItemInfo.Classifications.ProductGroup.DisplayValue
或ItemInfo.Classifications.Binding.DisplayValue
由于某些未知原因(至少对我而言),API 在未指定搜索索引时仅返回结果的子集(在下面的示例中为 kindle)
例子
在以下示例中,我通过执行 SearchItem 请求来查找 ISBN 为 9780262043649 的书籍的硬拷贝或 kindle。
a) 具有给定搜索索引的硬拷贝
有效载荷
{
"Keywords": "9780262043649",
"Resources": [
"ItemInfo.Classifications",
"ItemInfo.Title"
],
"SearchIndex": "Books",
"PartnerTag": "*******",
"PartnerType": "Associates",
"Marketplace": "www.amazon.com",
"Operation": "SearchItems"
}
回复
{
"SearchResult": {
"Items": [
{
"ASIN": "0262043645",
"DetailPageURL": "https://www.amazon.com/dp/0262043645?tag=getabstractcom&linkCode=osi&th=1&psc=1",
"ItemInfo": {
"Classifications": {
"Binding": {
"DisplayValue": "Hardcover",
"Label": "Binding",
"Locale": "en_US"
},
"ProductGroup": {
"DisplayValue": "Book",
"Label": "ProductGroup",
"Locale": "en_US"
}
},
"Title": {
"DisplayValue": "Novacene: The Coming Age of Hyperintelligence (The MIT Press)",
"Label": "Title",
"Locale": "en_US"
}
}
}
],
"SearchURL": "https://www.amazon.com/s?k=9780262043649&i=stripbooks&rh=p_n_availability%3A-1&tag=getabstractcom&linkCode=osi",
"TotalResultCount": 1
}
}
b) 具有给定搜索索引的 Kindle
有效载荷
{
"Keywords": "9780262043649",
"Resources": [
"ItemInfo.Classifications",
"ItemInfo.Title"
],
"SearchIndex": "KindleStore",
"PartnerTag": "******",
"PartnerType": "Associates",
"Marketplace": "www.amazon.com",
"Operation": "SearchItems"
}
回复
{
"SearchResult": {
"Items": [
{
"ASIN": "B08BT4MM18",
"DetailPageURL": "https://www.amazon.com/dp/B08BT4MM18?tag=getabstractcom&linkCode=osi&th=1&psc=1",
"ItemInfo": {
"Classifications": {
"Binding": {
"DisplayValue": "Kindle Edition",
"Label": "Binding",
"Locale": "en_US"
},
"ProductGroup": {
"DisplayValue": "Digital Ebook Purchas",
"Label": "ProductGroup",
"Locale": "en_US"
}
},
"Title": {
"DisplayValue": "Novacene: The Coming Age of Hyperintelligence",
"Label": "Title",
"Locale": "en_US"
}
}
}
],
"SearchURL": "https://www.amazon.com/s?k=9780262043649&i=digital-text&rh=p_n_availability%3A-1&tag=getabstractcom&linkCode=osi",
"TotalResultCount": 1
}
}
c) 没有特定的搜索索引
有效载荷
{
"Keywords": "9780262043649",
"Resources": [
"ItemInfo.Classifications",
"ItemInfo.Title"
],
"PartnerTag": "*******",
"PartnerType": "Associates",
"Marketplace": "www.amazon.com",
"Operation": "SearchItems"
}
回复
{
"SearchResult": {
"Items": [
{
"ASIN": "B08BT4MM18",
"DetailPageURL": "https://www.amazon.com/dp/B08BT4MM18?tag=getabstractcom&linkCode=osi&th=1&psc=1",
"ItemInfo": {
"Classifications": {
"Binding": {
"DisplayValue": "Kindle Edition",
"Label": "Binding",
"Locale": "en_US"
},
"ProductGroup": {
"DisplayValue": "Digital Ebook Purchas",
"Label": "ProductGroup",
"Locale": "en_US"
}
},
"Title": {
"DisplayValue": "Novacene: The Coming Age of Hyperintelligence",
"Label": "Title",
"Locale": "en_US"
}
}
}
],
"SearchURL": "https://www.amazon.com/s?k=9780262043649&rh=p_n_availability%3A-1&tag=getabstractcom&linkCode=osi",
"TotalResultCount": 1
}
}
您可以在 API 的暂存器中尝试这些示例。
有关产品广告 API 的搜索索引的更多信息,请参阅此处的官方文档
推荐阅读
- python - 处理图像和创建数据的函数
- c# - 将调试编译为 32 位并发布为 64 位 c#
- java - 在 Runnable 类中终止 Java Fx 应用程序 While 循环
- ruby-on-rails - 配置更改后资产丢失/未在 Elastic Beanstalk 上编译
- python - Django:models.py 中的 def save()
- node.js - 在 Google Cloud 中更改 sql 实例
- python - python-docx:提取文本以及标题和子标题编号
- python - Pybind11:在 C++ 函数中返回一个大数组显着增加了 python 中的计算时间
- c++ - 错误的 Qt 库链接
- php - 无法解析数据库字段中定义的 Php 变量