Amazon API
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[ビジネス>Business]] > [[アフィリエイト]] > [[Amazonア...
#contents
//===== ===== ===== ===== ===== ===== ===== ===== ===== =...
* Amazon APIとは? [#x5f48524]
[[Amazonアソシエイト]]の機能を外部から利用するための[[API...
正式には「Amazon Product Advertising API」と言います。
** 公式サイト [#wcd14b92]
-[[アソシエイト・セントラル - Product Advertising API>htt...
//===== ===== ===== ===== ===== ===== ===== ===== ===== =...
* Tips [#d1ea122c]
** Amazon APIの更新 [#o691eace]
Amazon APIがバージョンアップして、最新のバージョンは5にな...
古いバージョン4はもう使えないので入れ替えが必要です。(面...
-PA-API v5 PHP - Google 検索 https://www.google.com/searc...
-移行ガイド アソシエイト・セントラル https://affiliate.am...
-What's New in PA-API 5.0 · Product Advertising API 5.0 h...
-4.0から大きく変わった「PA-API v5.0(Amazon API)」の使い...
** ASINから商品データを取得する方法 [#i61d139d]
これらのデータを取得するにはどうしたら良いのだろうか?
+ 商品名
+ 商品画像
+ 本の著者名
+ 本の出版社名
+ 発売日
+ 価格
(参考)
- 4.0から大きく変わった「PA-API v5.0(Amazon API)」の使...
- GetItems · Product Advertising API 5.0 https://webservi...
>Examples
The following is the sample json payload for GetItems req...
{
"ItemIds": ["B0199980K4","B000HZD168","B01180YUXS...
"ItemIdType": "ASIN",
"LanguagesOfPreference": ["en_US"],
"Marketplace": "www.amazon.com",
"PartnerTag": "xyz-20",
"PartnerType": "Associates",
"Resources": ["Images.Primary.Small","ItemInfo.Ti...
}
この例では、欲しいデータの内容をJSON形式で指定する方法に...
PHPのSDKのサンプルコードでは、PHPの配列の形式で指定する方...
JSONではなく、PHPの配列で指定するにはどうすればいいのか?...
*** SampleGetItemsApi.php [#nae9e8ed]
function getItems()の中で、
# Request initialization
# Choose item id(s)
$itemIds = ["059035342X", "B00X4WHP55", "1401263119"];
/*
* Choose resources you want from GetItemsResource enum
* For more details, refer: https://webservices.amazo...
*/
$resources = [
GetItemsResource::ITEM_INFOTITLE,
GetItemsResource::OFFERSLISTINGSPRICE];
# Forming the request
$getItemsRequest = new GetItemsRequest();
$getItemsRequest->setItemIds($itemIds);
$getItemsRequest->setPartnerTag($partnerTag);
$getItemsRequest->setPartnerType(PartnerType::ASSOCIA...
$getItemsRequest->setResources($resources);
という部分がある。
この$resourcesを編集すればOKだ。
「ITEM_INFOTITLE」などの定数が定義されている箇所にジャン...
SDKの中にある「GetItemsResource.php」を見る。
(src\com\amazon\paapi5\v1\GetItemsResource.php)
この中で定数が定義されていた。
/**
* Possible values of this enum
*/
const BROWSE_NODE_INFOBROWSE_NODES = 'BrowseNodeInfo....
const BROWSE_NODE_INFOBROWSE_NODESANCESTOR = 'BrowseN...
const BROWSE_NODE_INFOBROWSE_NODESSALES_RANK = 'Brows...
const BROWSE_NODE_INFOWEBSITE_SALES_RANK = 'BrowseNod...
const CUSTOMER_REVIEWSCOUNT = 'CustomerReviews.Count';
const CUSTOMER_REVIEWSSTAR_RATING = 'CustomerReviews....
const IMAGESPRIMARYSMALL = 'Images.Primary.Small';
const IMAGESPRIMARYMEDIUM = 'Images.Primary.Medium';
const IMAGESPRIMARYLARGE = 'Images.Primary.Large';
const IMAGESVARIANTSSMALL = 'Images.Variants.Small';
const IMAGESVARIANTSMEDIUM = 'Images.Variants.Medium';
const IMAGESVARIANTSLARGE = 'Images.Variants.Large';
const ITEM_INFOBY_LINE_INFO = 'ItemInfo.ByLineInfo';
const ITEM_INFOCONTENT_INFO = 'ItemInfo.ContentInfo';
const ITEM_INFOCONTENT_RATING = 'ItemInfo.ContentRati...
const ITEM_INFOCLASSIFICATIONS = 'ItemInfo.Classifica...
const ITEM_INFOEXTERNAL_IDS = 'ItemInfo.ExternalIds';
const ITEM_INFOFEATURES = 'ItemInfo.Features';
const ITEM_INFOMANUFACTURE_INFO = 'ItemInfo.Manufactu...
const ITEM_INFOPRODUCT_INFO = 'ItemInfo.ProductInfo';
const ITEM_INFOTECHNICAL_INFO = 'ItemInfo.TechnicalIn...
const ITEM_INFOTITLE = 'ItemInfo.Title';
const ITEM_INFOTRADE_IN_INFO = 'ItemInfo.TradeInInfo';
const OFFERSLISTINGSAVAILABILITYMAX_ORDER_QUANTITY = ...
const OFFERSLISTINGSAVAILABILITYMESSAGE = 'Offers.Lis...
const OFFERSLISTINGSAVAILABILITYMIN_ORDER_QUANTITY = ...
const OFFERSLISTINGSAVAILABILITYTYPE = 'Offers.Listin...
const OFFERSLISTINGSCONDITION = 'Offers.Listings.Cond...
const OFFERSLISTINGSCONDITIONSUB_CONDITION = 'Offers....
const OFFERSLISTINGSDELIVERY_INFOIS_AMAZON_FULFILLED ...
const OFFERSLISTINGSDELIVERY_INFOIS_FREE_SHIPPING_ELI...
const OFFERSLISTINGSDELIVERY_INFOIS_PRIME_ELIGIBLE = ...
const OFFERSLISTINGSDELIVERY_INFOSHIPPING_CHARGES = '...
const OFFERSLISTINGSIS_BUY_BOX_WINNER = 'Offers.Listi...
const OFFERSLISTINGSLOYALTY_POINTSPOINTS = 'Offers.Li...
const OFFERSLISTINGSMERCHANT_INFO = 'Offers.Listings....
const OFFERSLISTINGSPRICE = 'Offers.Listings.Price';
const OFFERSLISTINGSPROGRAM_ELIGIBILITYIS_PRIME_EXCLU...
const OFFERSLISTINGSPROGRAM_ELIGIBILITYIS_PRIME_PANTR...
const OFFERSLISTINGSPROMOTIONS = 'Offers.Listings.Pro...
const OFFERSLISTINGSSAVING_BASIS = 'Offers.Listings.S...
const OFFERSSUMMARIESHIGHEST_PRICE = 'Offers.Summarie...
const OFFERSSUMMARIESLOWEST_PRICE = 'Offers.Summaries...
const OFFERSSUMMARIESOFFER_COUNT = 'Offers.Summaries....
const PARENT_ASIN = 'ParentASIN';
const RENTAL_OFFERSLISTINGSAVAILABILITYMAX_ORDER_QUAN...
const RENTAL_OFFERSLISTINGSAVAILABILITYMESSAGE = 'Ren...
const RENTAL_OFFERSLISTINGSAVAILABILITYMIN_ORDER_QUAN...
const RENTAL_OFFERSLISTINGSAVAILABILITYTYPE = 'Rental...
const RENTAL_OFFERSLISTINGSBASE_PRICE = 'RentalOffers...
const RENTAL_OFFERSLISTINGSCONDITION = 'RentalOffers....
const RENTAL_OFFERSLISTINGSCONDITIONSUB_CONDITION = '...
const RENTAL_OFFERSLISTINGSDELIVERY_INFOIS_AMAZON_FUL...
const RENTAL_OFFERSLISTINGSDELIVERY_INFOIS_FREE_SHIPP...
const RENTAL_OFFERSLISTINGSDELIVERY_INFOIS_PRIME_ELIG...
const RENTAL_OFFERSLISTINGSDELIVERY_INFOSHIPPING_CHAR...
const RENTAL_OFFERSLISTINGSMERCHANT_INFO = 'RentalOff...
この定義の右辺の部分(BrowseNodeInfo.BrowseNodesなど)が...
(参考)GetItems · Product Advertising API 5.0 https://we...
以上から、
| 欲しいデータ | 対応するResources Parameter | SDKのPHPサ...
| 商品名 | ItemInfo.Title | ITEM_INFOTITLE |
| 商品画像(小)"Height": 75 | Images.Primary.Small | IMA...
| 商品画像(中)"Height": 160 | Images.Primary.Medium | I...
| 商品画像(大)"Height": 500 | Images.Primary.Large | IM...
| 本の著者名 | ItemInfo.ByLineInfo | ITEM_INFOBY_LINE_INFO|
| 本の出版社名 | ItemInfo.ByLineInfo | ITEM_INFOBY_LINE_I...
| 発売日 | ItemInfo.ContentInfo | ITEM_INFOCONTENT_INFO |
| 価格 | Offers.Listings.Price | OFFERSLISTINGSPRICE |
という項目をセットしてリスエストすれば、欲しいデータが得...
PHPの配列で指定すると、以下のようになりました。
$resources = [
GetItemsResource::ITEM_INFOTITLE,
GetItemsResource::IMAGESPRIMARYSMALL ,
GetItemsResource::IMAGESPRIMARYMEDIUM ,
GetItemsResource::IMAGESPRIMARYLARGE ,
GetItemsResource::ITEM_INFOBY_LINE_INFO ,
GetItemsResource::ITEM_INFOCONTENT_INFO ,
GetItemsResource::OFFERSLISTINGSPRICE ,
];
これで、試しにASIN「4863542224」の本のデータを取得してみ...
-基礎からわかる Elm | 鳥居 陽介 |本 | 通販 | Amazon https...
返ってきたレスポンスのJSONは、以下のようになっていました。
#code(json){{{
API called successfully Complete Response: {
"ItemsResult": {
"Items": [
{
"ASIN": "4863542224",
"DetailPageURL": "https:\/\/www.amazon.co...
"Images": {
"Primary": {
"Small": {
"URL": "https:\/\/m.media-ama...
"Height": 75,
"Width": 53
},
"Medium": {
"URL": "https:\/\/m.media-ama...
"Height": 160,
"Width": 113
},
"Large": {
"URL": "https:\/\/m.media-ama...
"Height": 500,
"Width": 352
}
}
},
"ItemInfo": {
"ByLineInfo": {
"Contributors": [
{
"Locale": "ja_JP",
"Name": "\u9ce5\u5c45 \u9...
"Role": "\u8457",
"RoleType": "author"
}
],
"Manufacturer": {
"DisplayValue": "\u30b7\u30fc...
"Label": "Manufacturer",
"Locale": "ja_JP"
}
},
"ContentInfo": {
"Languages": {
"DisplayValues": [
{
"DisplayValue": "\u65...
"Type": "\u767a\u884c...
}
],
"Label": "Language",
"Locale": "ja_JP"
},
"PagesCount": {
"DisplayValue": 224,
"Label": "NumberOfPages",
"Locale": "en_US"
},
"PublicationDate": {
"DisplayValue": "2019-02-27T0...
"Label": "PublicationDate",
"Locale": "en_US"
}
},
"Title": {
"DisplayValue": "\u57fa\u790e\u30...
"Label": "Title",
"Locale": "ja_JP"
}
},
"Offers": {
"Listings": [
{
"Id": "%259DZs7G3(中略)%F0I...
"Price": {
"Amount": 2893,
"Currency": "JPY",
"DisplayAmount": "\uffe52...
},
"ViolatesMAP": false
}
]
}
}
]
}
} Printing all item information in ItemsResult: Printing ...
}}}
次の工程では、JSONをパースして必要な項目のデータを取り出...
//===== ===== ===== ===== ===== ===== ===== ===== ===== =...
* 参考書 [#xeaefee4]
#html{{
<!--
<td> </td>
<hr>
-->
}}
//----------------------------------------
~
~
~
//----------------------------------------
// create 2020/05/05
終了行:
[[ビジネス>Business]] > [[アフィリエイト]] > [[Amazonア...
#contents
//===== ===== ===== ===== ===== ===== ===== ===== ===== =...
* Amazon APIとは? [#x5f48524]
[[Amazonアソシエイト]]の機能を外部から利用するための[[API...
正式には「Amazon Product Advertising API」と言います。
** 公式サイト [#wcd14b92]
-[[アソシエイト・セントラル - Product Advertising API>htt...
//===== ===== ===== ===== ===== ===== ===== ===== ===== =...
* Tips [#d1ea122c]
** Amazon APIの更新 [#o691eace]
Amazon APIがバージョンアップして、最新のバージョンは5にな...
古いバージョン4はもう使えないので入れ替えが必要です。(面...
-PA-API v5 PHP - Google 検索 https://www.google.com/searc...
-移行ガイド アソシエイト・セントラル https://affiliate.am...
-What's New in PA-API 5.0 · Product Advertising API 5.0 h...
-4.0から大きく変わった「PA-API v5.0(Amazon API)」の使い...
** ASINから商品データを取得する方法 [#i61d139d]
これらのデータを取得するにはどうしたら良いのだろうか?
+ 商品名
+ 商品画像
+ 本の著者名
+ 本の出版社名
+ 発売日
+ 価格
(参考)
- 4.0から大きく変わった「PA-API v5.0(Amazon API)」の使...
- GetItems · Product Advertising API 5.0 https://webservi...
>Examples
The following is the sample json payload for GetItems req...
{
"ItemIds": ["B0199980K4","B000HZD168","B01180YUXS...
"ItemIdType": "ASIN",
"LanguagesOfPreference": ["en_US"],
"Marketplace": "www.amazon.com",
"PartnerTag": "xyz-20",
"PartnerType": "Associates",
"Resources": ["Images.Primary.Small","ItemInfo.Ti...
}
この例では、欲しいデータの内容をJSON形式で指定する方法に...
PHPのSDKのサンプルコードでは、PHPの配列の形式で指定する方...
JSONではなく、PHPの配列で指定するにはどうすればいいのか?...
*** SampleGetItemsApi.php [#nae9e8ed]
function getItems()の中で、
# Request initialization
# Choose item id(s)
$itemIds = ["059035342X", "B00X4WHP55", "1401263119"];
/*
* Choose resources you want from GetItemsResource enum
* For more details, refer: https://webservices.amazo...
*/
$resources = [
GetItemsResource::ITEM_INFOTITLE,
GetItemsResource::OFFERSLISTINGSPRICE];
# Forming the request
$getItemsRequest = new GetItemsRequest();
$getItemsRequest->setItemIds($itemIds);
$getItemsRequest->setPartnerTag($partnerTag);
$getItemsRequest->setPartnerType(PartnerType::ASSOCIA...
$getItemsRequest->setResources($resources);
という部分がある。
この$resourcesを編集すればOKだ。
「ITEM_INFOTITLE」などの定数が定義されている箇所にジャン...
SDKの中にある「GetItemsResource.php」を見る。
(src\com\amazon\paapi5\v1\GetItemsResource.php)
この中で定数が定義されていた。
/**
* Possible values of this enum
*/
const BROWSE_NODE_INFOBROWSE_NODES = 'BrowseNodeInfo....
const BROWSE_NODE_INFOBROWSE_NODESANCESTOR = 'BrowseN...
const BROWSE_NODE_INFOBROWSE_NODESSALES_RANK = 'Brows...
const BROWSE_NODE_INFOWEBSITE_SALES_RANK = 'BrowseNod...
const CUSTOMER_REVIEWSCOUNT = 'CustomerReviews.Count';
const CUSTOMER_REVIEWSSTAR_RATING = 'CustomerReviews....
const IMAGESPRIMARYSMALL = 'Images.Primary.Small';
const IMAGESPRIMARYMEDIUM = 'Images.Primary.Medium';
const IMAGESPRIMARYLARGE = 'Images.Primary.Large';
const IMAGESVARIANTSSMALL = 'Images.Variants.Small';
const IMAGESVARIANTSMEDIUM = 'Images.Variants.Medium';
const IMAGESVARIANTSLARGE = 'Images.Variants.Large';
const ITEM_INFOBY_LINE_INFO = 'ItemInfo.ByLineInfo';
const ITEM_INFOCONTENT_INFO = 'ItemInfo.ContentInfo';
const ITEM_INFOCONTENT_RATING = 'ItemInfo.ContentRati...
const ITEM_INFOCLASSIFICATIONS = 'ItemInfo.Classifica...
const ITEM_INFOEXTERNAL_IDS = 'ItemInfo.ExternalIds';
const ITEM_INFOFEATURES = 'ItemInfo.Features';
const ITEM_INFOMANUFACTURE_INFO = 'ItemInfo.Manufactu...
const ITEM_INFOPRODUCT_INFO = 'ItemInfo.ProductInfo';
const ITEM_INFOTECHNICAL_INFO = 'ItemInfo.TechnicalIn...
const ITEM_INFOTITLE = 'ItemInfo.Title';
const ITEM_INFOTRADE_IN_INFO = 'ItemInfo.TradeInInfo';
const OFFERSLISTINGSAVAILABILITYMAX_ORDER_QUANTITY = ...
const OFFERSLISTINGSAVAILABILITYMESSAGE = 'Offers.Lis...
const OFFERSLISTINGSAVAILABILITYMIN_ORDER_QUANTITY = ...
const OFFERSLISTINGSAVAILABILITYTYPE = 'Offers.Listin...
const OFFERSLISTINGSCONDITION = 'Offers.Listings.Cond...
const OFFERSLISTINGSCONDITIONSUB_CONDITION = 'Offers....
const OFFERSLISTINGSDELIVERY_INFOIS_AMAZON_FULFILLED ...
const OFFERSLISTINGSDELIVERY_INFOIS_FREE_SHIPPING_ELI...
const OFFERSLISTINGSDELIVERY_INFOIS_PRIME_ELIGIBLE = ...
const OFFERSLISTINGSDELIVERY_INFOSHIPPING_CHARGES = '...
const OFFERSLISTINGSIS_BUY_BOX_WINNER = 'Offers.Listi...
const OFFERSLISTINGSLOYALTY_POINTSPOINTS = 'Offers.Li...
const OFFERSLISTINGSMERCHANT_INFO = 'Offers.Listings....
const OFFERSLISTINGSPRICE = 'Offers.Listings.Price';
const OFFERSLISTINGSPROGRAM_ELIGIBILITYIS_PRIME_EXCLU...
const OFFERSLISTINGSPROGRAM_ELIGIBILITYIS_PRIME_PANTR...
const OFFERSLISTINGSPROMOTIONS = 'Offers.Listings.Pro...
const OFFERSLISTINGSSAVING_BASIS = 'Offers.Listings.S...
const OFFERSSUMMARIESHIGHEST_PRICE = 'Offers.Summarie...
const OFFERSSUMMARIESLOWEST_PRICE = 'Offers.Summaries...
const OFFERSSUMMARIESOFFER_COUNT = 'Offers.Summaries....
const PARENT_ASIN = 'ParentASIN';
const RENTAL_OFFERSLISTINGSAVAILABILITYMAX_ORDER_QUAN...
const RENTAL_OFFERSLISTINGSAVAILABILITYMESSAGE = 'Ren...
const RENTAL_OFFERSLISTINGSAVAILABILITYMIN_ORDER_QUAN...
const RENTAL_OFFERSLISTINGSAVAILABILITYTYPE = 'Rental...
const RENTAL_OFFERSLISTINGSBASE_PRICE = 'RentalOffers...
const RENTAL_OFFERSLISTINGSCONDITION = 'RentalOffers....
const RENTAL_OFFERSLISTINGSCONDITIONSUB_CONDITION = '...
const RENTAL_OFFERSLISTINGSDELIVERY_INFOIS_AMAZON_FUL...
const RENTAL_OFFERSLISTINGSDELIVERY_INFOIS_FREE_SHIPP...
const RENTAL_OFFERSLISTINGSDELIVERY_INFOIS_PRIME_ELIG...
const RENTAL_OFFERSLISTINGSDELIVERY_INFOSHIPPING_CHAR...
const RENTAL_OFFERSLISTINGSMERCHANT_INFO = 'RentalOff...
この定義の右辺の部分(BrowseNodeInfo.BrowseNodesなど)が...
(参考)GetItems · Product Advertising API 5.0 https://we...
以上から、
| 欲しいデータ | 対応するResources Parameter | SDKのPHPサ...
| 商品名 | ItemInfo.Title | ITEM_INFOTITLE |
| 商品画像(小)"Height": 75 | Images.Primary.Small | IMA...
| 商品画像(中)"Height": 160 | Images.Primary.Medium | I...
| 商品画像(大)"Height": 500 | Images.Primary.Large | IM...
| 本の著者名 | ItemInfo.ByLineInfo | ITEM_INFOBY_LINE_INFO|
| 本の出版社名 | ItemInfo.ByLineInfo | ITEM_INFOBY_LINE_I...
| 発売日 | ItemInfo.ContentInfo | ITEM_INFOCONTENT_INFO |
| 価格 | Offers.Listings.Price | OFFERSLISTINGSPRICE |
という項目をセットしてリスエストすれば、欲しいデータが得...
PHPの配列で指定すると、以下のようになりました。
$resources = [
GetItemsResource::ITEM_INFOTITLE,
GetItemsResource::IMAGESPRIMARYSMALL ,
GetItemsResource::IMAGESPRIMARYMEDIUM ,
GetItemsResource::IMAGESPRIMARYLARGE ,
GetItemsResource::ITEM_INFOBY_LINE_INFO ,
GetItemsResource::ITEM_INFOCONTENT_INFO ,
GetItemsResource::OFFERSLISTINGSPRICE ,
];
これで、試しにASIN「4863542224」の本のデータを取得してみ...
-基礎からわかる Elm | 鳥居 陽介 |本 | 通販 | Amazon https...
返ってきたレスポンスのJSONは、以下のようになっていました。
#code(json){{{
API called successfully Complete Response: {
"ItemsResult": {
"Items": [
{
"ASIN": "4863542224",
"DetailPageURL": "https:\/\/www.amazon.co...
"Images": {
"Primary": {
"Small": {
"URL": "https:\/\/m.media-ama...
"Height": 75,
"Width": 53
},
"Medium": {
"URL": "https:\/\/m.media-ama...
"Height": 160,
"Width": 113
},
"Large": {
"URL": "https:\/\/m.media-ama...
"Height": 500,
"Width": 352
}
}
},
"ItemInfo": {
"ByLineInfo": {
"Contributors": [
{
"Locale": "ja_JP",
"Name": "\u9ce5\u5c45 \u9...
"Role": "\u8457",
"RoleType": "author"
}
],
"Manufacturer": {
"DisplayValue": "\u30b7\u30fc...
"Label": "Manufacturer",
"Locale": "ja_JP"
}
},
"ContentInfo": {
"Languages": {
"DisplayValues": [
{
"DisplayValue": "\u65...
"Type": "\u767a\u884c...
}
],
"Label": "Language",
"Locale": "ja_JP"
},
"PagesCount": {
"DisplayValue": 224,
"Label": "NumberOfPages",
"Locale": "en_US"
},
"PublicationDate": {
"DisplayValue": "2019-02-27T0...
"Label": "PublicationDate",
"Locale": "en_US"
}
},
"Title": {
"DisplayValue": "\u57fa\u790e\u30...
"Label": "Title",
"Locale": "ja_JP"
}
},
"Offers": {
"Listings": [
{
"Id": "%259DZs7G3(中略)%F0I...
"Price": {
"Amount": 2893,
"Currency": "JPY",
"DisplayAmount": "\uffe52...
},
"ViolatesMAP": false
}
]
}
}
]
}
} Printing all item information in ItemsResult: Printing ...
}}}
次の工程では、JSONをパースして必要な項目のデータを取り出...
//===== ===== ===== ===== ===== ===== ===== ===== ===== =...
* 参考書 [#xeaefee4]
#html{{
<!--
<td> </td>
<hr>
-->
}}
//----------------------------------------
~
~
~
//----------------------------------------
// create 2020/05/05
ページ名: