jorgerosal / amazon-paapi

šŸ”„Amazon Product Advertising API for NodeJs. A PAAPI 5.0 sdk wrapper.
https://webservices.amazon.com/paapi5/documentation/
MIT License
76 stars 19 forks source link
amazon-itemlookup amazon-product-advertising-api aws-associate paapi5

amazon-paapi

npm version NPM

Amazon Associate Product Advertising API for NodeJs. A PAAPI 5.0 Extension.

A clean wrapper for amazon's NodeJs SDK. Main purpose of this module is to jumpstart development with easy to understand and clean syntax inspired with the amazon scratchpad-like operation.

Amazon Product API

Installation

npm install amazon-paapi --save

Quickstart

const amazonPaapi = require('amazon-paapi');

const commonParameters = {
  AccessKey: '<YOUR  ACCESS  KEY>',
  SecretKey: '<YOUR  SECRET  KEY>',
  PartnerTag: '<YOUR  PARTNER  TAG>', // yourtag-20
  PartnerType: 'Associates', // Default value is Associates.
  Marketplace: 'www.amazon.com', // Default value is US. Note: Host and Region are predetermined based on the marketplace value. There is no need for you to add Host and Region as soon as you specify the correct Marketplace value. If your region is not US or .com, please make sure you add the correct Marketplace value.
};

const requestParameters = {
  ASIN: 'B07H65KP63',
  Resources: [
    'ItemInfo.Title',
    'Offers.Listings.Price',
    'VariationSummary.VariationDimension',
  ],
};

/** Promise */
amazonPaapi
  .GetVariations(commonParameters, requestParameters)
  .then((data) => {
    // do something with the success response.
    console.log(data);
  })
  .catch((error) => {
    // catch an error.
    console.log(error);
  });

Usage

const amazonPaapi = require('amazon-paapi');

const commonParameters = {
  AccessKey: '<YOUR  ACCESS  KEY>',
  SecretKey: '<YOUR  SECRET  KEY>',
  PartnerTag: '<YOUR  PARTNER  TAG>', // yourtag-20
  PartnerType: 'Associates', // Default value is Associates.
  Marketplace: 'www.amazon.com', // Default value is US. Note: Host and Region are predetermined based on the marketplace value. There is no need for you to add Host and Region as soon as you specify the correct Marketplace value. If your region is not US or .com, please make sure you add the correct Marketplace value.
};

GetBrowseNodes

Lookup information for a Browse Node. Please see sample script here.

const requestParameters = {
  BrowseNodeIds: ['3040', '3045'],
  LanguagesOfPreference: ['es_US'],
  Resources: ['BrowseNodes.Ancestor', 'BrowseNodes.Children'],
};

/** Promise */
amazonPaapi
  .GetBrowseNodes(commonParameters, requestParameters)
  .then((data) => {
    // do something with the success response.
    console.log(data);
  })
  .catch((error) => {
    // catch an error.
    console.log(error);
  });

GetItems

Lookup item information for an item. Please see sample script here.

Note: This operation only supports ASIN as id Type. If you need to lookup using UPC or EAN, you can do so under SearchItems operation.

const requestParameters = {
  ItemIds: ['B00X4WHP5E', 'B00ZV9RDKK'],
  ItemIdType: 'ASIN',
  Condition: 'New',
  Resources: [
    'Images.Primary.Medium',
    'ItemInfo.Title',
    'Offers.Listings.Price',
  ],
};

/** Promise */
amazonPaapi
  .GetItems(commonParameters, requestParameters)
  .then((data) => {
    // do something with the success response.
    console.log(data);
  })
  .catch((error) => {
    // catch an error.
    console.log(error);
  });

GetVariations

Lookup information for variations. Please see sample script here.

const requestParameters = {
  ASIN: 'B07H65KP63',
  Resources: [
    'Images.Primary.Medium',
    'ItemInfo.Title',
    'Offers.Listings.Price',
    'VariationSummary.VariationDimension',
  ],
};

/** Promise */
amazonPaapi
  .GetVariations(commonParameters, requestParameters)
  .then((data) => {
    // do something with the success response.
    console.log(data);
  })
  .catch((error) => {
    // catch an error.
    console.log(error);
  });

SearchItems

Searches for items on Amazon. Please see sample script here.

const requestParameters = {
  Keywords: 'Harry Potter',
  SearchIndex: 'Books',
  ItemCount: 2,
  Resources: [
    'Images.Primary.Medium',
    'ItemInfo.Title',
    'Offers.Listings.Price',
  ],
};

/** Promise */
amazonPaapi
  .SearchItems(commonParameters, requestParameters)
  .then((data) => {
    // do something with the success response.
    console.log(data);
  })
  .catch((error) => {
    // catch an error.
    console.log(error);
  });

Common Request Parameters

V4.0 to V5.0 Mapping

Due to major change from V4.0 to V5.0, most of the legacy application may not work properly since V4.0 is not supported anymore.

We're currently working on mapping some commonly used operations from the V4.0 and make it available soon to work with the V5.0.

In the mean time, please check amazon documentation on how to map.

FAQ

Donation

If this somehow makes your job a bit easier, please consider dropping few bucks. Your contribution allows me to spend more time improving features of this project.

Donate

License

MIT