npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

paapi5-product-lookup

v1.0.3

Published

implementing aws paapi5

Downloads

8

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

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"
    }
   }
  }
 }
}