AmazonのPAAPI(Product Advertising API)を使おうと思ったら、
便利なライブラリ(node-apac)があったので、試したときの備忘録。
インストール
$ npm install apac
使い方
const {OperationHelper} = require('apac'); const opHelper = new OperationHelper({ awsId: '[YOUR AWS ID HERE]', awsSecret: '[YOUR AWS SECRET HERE]', assocId: '[YOUR ASSOCIATE TAG HERE]' }); public async search(keyword: string) { const res = await opHelper.execute('ItemSearch', { 'SearchIndex': 'Books', 'Keywords': keyword, 'ResponseGroup': 'ItemAttributes,Offers', 'ItemPage': 1 // ページ数: 1〜10 })) return res; }
例1: 出品者がAmazonの在庫あり新品のみを検索
{ 'SearchIndex': 'Books', 'Condition': "New", // 新品 'Availability': "Available", // 在庫あり 'MerchantId': "Amazon", // 出品者がAmazon 'Keywords': keyword, }
例2: Kindle版以外の書籍のみを検索
{ 'SearchIndex': 'Books', 'Power': `keywords:${keyword} and binding:not kindle`, }
Power検索でbinding:not kindle
を指定する。
例3: Kindle版の書籍のみを検索
{ 'SearchIndex': 'KindleStore', 'Keywords': keyword, }
SearchIndexでKindleStore
を指定する
注意:作ってもすぐには使えない。。
2019年01月23日にPA-APIの利用ポリシーの変更があったらしい。。。
アフィリエイトでの購入実績が無いと使えないっぽい。。
売上実績の発生がない場合は、PA-APIの利用開始はできません。
また、発送済み商品売上が過去30日以内に発生していない場合、PA-APIをご利用いただけなくなる恐れがございます。
以上!!
参考にしたサイト様
- node.jsでamazon apiを叩く時にapac.jsで気をつけること。 - Qiita
- dmcquay/node-apac: node-apac - Node.js client for the Amazon Product Advertising API, including support of Request Signatures
- Product Advertising API
- Amazon Product Advertising API を使った書籍検索 API をサクッと作る - Qiita
- JavaScriptからAmazon Product Advertising APIを叩くときのサンプルです。URLの構築まで(後はajaxでGETで飛ばせば結果が得られる)。CryptoJSとjQueryに依存してます。
- Product Advertising API Scratchpad (beta)
- Amazon Product Advertising APIでKindle版の書籍を絞り込む・除外する・判定する - Programming