amazon-paapi
amazon-paapi copied to clipboard
Need help with usage
Hello,
I am trying to use the amazon-paapi.
If I call the paapi and print the result to the terminal, I am getting following response.
exports { ItemsResult: exports { Items: [ [exports] ] } }
How can I get and use the api response? Do you have an example that shows how to call the code and how to get the result in json format?
Sorry. I forgot to mention that I am trying to use the searchItems example
Hello,
I use Marketplace www.amazon.de (Germany) and I have the same problem :-(
Hope someone can help us!
Thanks a lot!
Hi, were you able to get a solution? If you could send your code here so we can check? Thanks!
Yes, I found a solution. This is the code I ended up using:
amazonPaapi.js
`const amazonPaapi = require("amazon-paapi");
const commonParameters = { AccessKey: "XXXXXXX", SecretKey: "XXXXXXX", PartnerTag: "XXXXXX", PartnerType: "Associates", Marketplace: "www.amazon.de", };
let requestParameters = { SearchIndex: "All", ItemCount: 5, Resources: [ "Images.Primary.Large", "ItemInfo.Title", "Offers.Listings.Price", "Offers.Listings.Availability.Type", "CustomerReviews.StarRating", "BrowseNodeInfo.BrowseNodes.SalesRank", "ItemInfo.Features", "ItemInfo.ProductInfo", "ItemInfo.TechnicalInfo", ], };
exports.getItemsFromAmazonByKeyword = (productsArray) => { return new Promise(async (resolve) => { requestParameters.Keywords = productsArray; try { let data = await amazonPaapi.SearchItems( commonParameters, requestParameters ); resolve(data); } catch (error) { console.log("paapi Error: " + error); reject(error); } }); };`
app.js
... `async function searchProductsByKeyword(keyword) { let data = await AmazonUtils.getItemsFromAmazonByKeyword(keyword);
return data; }` ...
Please let me know if there is a more elegant way.
@RapahelS I'm having the same issue. How did you manage the import of getItemsFromAmazonByKeyword in app.js?
I'm having the same issue. Have you fix?
Using console.log directly on the response object does not display the full structure because contains nested objects, possibly with non-enumerable properties.
To better inspect the entire response object, you need to use JSON.stringify() to convert the object into a readable string format. Use this instead:
console.log(JSON.stringify(data, null, 2));
This did it for me.