paapi5-product-lookup
v1.0.3
Published
implementing aws paapi5
Downloads
8
Maintainers
Readme
paapi5-product-lookup
This package creates a wrapper around paapi5-amazon-sdk for the GetItems, SearchItems, GetBrowseNodes and GetVariations request.
Installation
npm install paapi5-product-lookup
Table of Content
- Basic Implementation of all method
- Creating a Lookup object
- Get Items details from ASIN
- Search Item using keywords
Basic Implementation of all method
Check all allowed operations in PAAPI5 - https://webservices.amazon.com/paapi5/documentation/operations.html
const ProductLookup = require('paapi5-product-lookup');
let args = {
'AccessKey': 'Your Access Key',
'SecretKey': 'Your Secret Key',
'PartnerType': 'Associates',
'PartnerTag': 'Your Partner Tag or Storeid',
'Host': 'webservices.amazon.in',
'Region': 'eu-west-1'
//Resources:['ItemInfo.Title', 'Offers.Listings.Price']
}
const Lookup = new ProductLookup(args);
Lookup.getItems({
ItemIds: ['B07H6NJX5F','B07H6NJX5Z'],
Resources: ['ItemInfo.Title']//will override the existing Resources if passed in the Request object
}).then( (result) => {
console.log('response'+ JSON.stringify(result,null,1));
}).catch( (error) => {
console.log("request error = "+ error);
});
Lookup.searchItems({
"Keywords": 'iphone 6S',
"SearchIndex": 'Electronics',
"ItemCount": 3,//default:10
"SortBy": "Relevance",//default:None
"Availability":"IncludeOutOfStock",//default:Available
"Condition": "New" //default:Any
}).then( (result) => {
console.log('response'+ JSON.stringify(result,null,1));
}).catch( (error) => {
console.log("request error = "+ error);
});
Lookup.getBrowseNodes({
"ASIN":"B07DJD1RTM",
'Resources': ['Images.Primary.Medium', 'ItemInfo.Title', 'Offers.Listings.Price',"VariationSummary.VariationDimension"]
}).then( (result) => {
console.log('response'+ JSON.stringify(result,null,1));
}).catch( (error) => {
console.log("request error = "+ error);
});
Lookup.getBrowseNodes({
"BrowseNodeIds": ["1389401031","2"],
//Resources are added by default as it has only two resource values
}).then( (result) => {
console.log('response'+ JSON.stringify(result,null,1));
}).catch( (error) => {
console.log("request error = "+ error);
})
Create a Lookup object
const ProductLookup = require('paapi5-product-lookup');
let args = {
'AccessKey': 'Your Access Key',
'SecretKey': 'Your Secret Key',
'PartnerType': 'Associates',
'PartnerTag': 'Your Partner Tag or Storeid',
'Host': 'webservices.amazon.in',
'Region': 'eu-west-1'
//Resources:['Value1','Value2'] can be pass at the time of object creation. It'll act as a default Resources for all future requests.
}
const Lookup = new ProductLookup(args);
Find your PAAPI Host and Region by clicking here.
Get Items details from ASIN
Getting Items details by passing ASIN, Resources and other params to getItems
method.
var requestParams = {
ItemIds: ['B07H6NJX5F','B07H6NJX5Z'],
Resources: ['ItemInfo.Title', 'Offers.Listings.Price']
//Condition: default - Any
//OfferCount: default - 1
}
Lookup.getItems(requestParams).then( (result) => {
console.log('response'+ JSON.stringify(result,null,1));
}).catch( (error) => {
console.log("request error = "+ error);
});
Output:
{
"Items": {
"B07H6NJX5F": {
"ASIN": "B07H6NJX5F",
"DetailPageURL": "https://www.amazon.in/dp/B07H6NJX5F?tag=mysm-21&linkCode=ogi&th=1&psc=1",
"ItemInfo": {
"Title": {
"DisplayValue": "Poco F1 by Xiaomi (Armored Edition, 8GB RAM, 256GB Storage) - Extra 2,000 Off on Exchange & Upto 6 Months No Cost EMI",
"Label": "Title",
"Locale": "en_IN"
}
},
"Offers": {
"Listings": [
{
"Id": "qNft0S0qJgBKa7yu58xs%2BPvEjk4iln5WlWd9zeo9qPEELTaANW1ykrZqfaopS4S%2FDv46%2BlrOMgayEGHCcrG6vcea%2BkVPtSmPTSPXF6G%2FxU68W0mKxWtEyQsl69YPgLp1",
"Price": {
"Amount": 16999,
"Currency": "INR",
"DisplayAmount": "₹ 16,999.00",
"Savings": {
"Amount": 14000,
"Currency": "INR",
"DisplayAmount": "₹ 14,000.00 (45%)",
"Percentage": 45
}
},
"ViolatesMAP": false
}
]
}
}
},
"Errors": [
{
"Code": "InvalidParameterValue",
"Message": "The ItemId B07H6NJX5Z provided in the request is invalid."
}
]
}
Search Item using keywords
var requestParams = {
"Keywords": 'iphone 6S',
"SearchIndex": 'Electronics',
"ItemCount": 3,//default:10
"SortBy": "Relevance",//default:None
"Availability":"IncludeOutOfStock",//default:Available
"Condition": "New", //default:Any
"Resources": ['ItemInfo.Title']
};
Lookup.searchItems(requestParams).then( (result) => {
console.log('response'+ JSON.stringify(result,null,1));
}).catch( (error) => {
console.log("request error = "+ error);
})
Output:
{
"Items": {
"B016QBU4S4": {
"ASIN": "B016QBU4S4",
"DetailPageURL": "https://www.amazon.in/dp/B016QBU4S4?tag=mysm-21&linkCode=osi&th=1&psc=1",
"ItemInfo": {
"Title": {
"DisplayValue": "Apple iPhone 6s (128GB) - Gold",
"Label": "Title",
"Locale": "en_IN"
}
}
},
"B01LXF3SP9": {
"ASIN": "B01LXF3SP9",
"DetailPageURL": "https://www.amazon.in/dp/B01LXF3SP9?tag=mysm-21&linkCode=osi&th=1&psc=1",
"ItemInfo": {
"Title": {
"DisplayValue": "Apple iPhone 6s (32GB) - Rose Gold",
"Label": "Title",
"Locale": "en_IN"
}
}
},
"B016QBTYIK": {
"ASIN": "B016QBTYIK",
"DetailPageURL": "https://www.amazon.in/dp/B016QBTYIK?tag=mysm-21&linkCode=osi&th=1&psc=1",
"ItemInfo": {
"Title": {
"DisplayValue": "Apple iPhone 6s (128GB) - Space Grey",
"Label": "Title",
"Locale": "en_IN"
}
}
}
}
}