amazon-paapi icon indicating copy to clipboard operation
amazon-paapi copied to clipboard

Need help with usage

Open RapahelS opened this issue 3 years ago • 7 comments

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?

RapahelS avatar Jan 02 '22 21:01 RapahelS

Sorry. I forgot to mention that I am trying to use the searchItems example

RapahelS avatar Jan 02 '22 21:01 RapahelS

Hello,

I use Marketplace www.amazon.de (Germany) and I have the same problem :-(

Hope someone can help us!

Thanks a lot!

hardcore avatar Feb 11 '22 21:02 hardcore

Hi, were you able to get a solution? If you could send your code here so we can check? Thanks!

jorgerosal avatar Aug 30 '22 05:08 jorgerosal

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 avatar Aug 30 '22 07:08 RapahelS

@RapahelS I'm having the same issue. How did you manage the import of getItemsFromAmazonByKeyword in app.js?

marco910 avatar Sep 29 '22 11:09 marco910

I'm having the same issue. Have you fix?

EliaTolin avatar Oct 17 '22 16:10 EliaTolin

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.

tka85 avatar Sep 23 '23 20:09 tka85