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

amazon-pa-api50

v0.2.0

Published

Amazon Product Advertising API v5.0 for JavasScript & NodeJs

Downloads

256

Readme

Amazon Product Advertising (Affiliate) API v5 for NodeJS

amazon-pa-api50 v0.2.0

This Nodejs package use Amazon's NodeJS SDK to make the development simpler, in less time and use the power of NPM.

Learn more about Product Advertising API v5.

Installation

Github

git clone [email protected]:arifulhb/amazon-pa-api50.git

NPM

npm install amazon-pa-api50 --save

Connect with Amazon Product Affiliate API.

Import the Config module and Api client.

const Api = require('amazon-pa-api50')
const Config = require('amazon-pa-api50/lib/config')

Optional loading of modules All of these are optional. Depends on what you want to search or fetch.

const resources = require('amazon-pa-api50/lib/options').Resources // Optional for different resources
const condition = require('amazon-pa-api50/lib/options').Condition // for product condition
const country = require('amazon-pa-api50/lib/options').Country // Optional for different country
const searchIndex = require('amazon-pa-api50/lib/options').SearchIndex // for Search Index

Create Config instance

// By Default all resources and will connect to United States
let myConfig = new Config();

// if you want other country then united states.
let myConfig = new Config(undefined, country.UnitedKingdom);

// if you want custom resources.
// this custom `resources.Offers` will be set default to all of your search. You can customize the resources in your search specific function also.
let myConfig = new Config(resources.Offers);

// if you want custom resources with different country
let myConfig = new Config(resources.ItemInfo, country.Canada);

Configure the Config class

/**
 * Add your Credentials Here
 */
myConfig.accessKey = '<ACCESS_KEY>'
myConfig.secretKey = '<SECRET_KEY>' 
myConfig.partnerTag = '<PARTNER_TAG>' 

After adding the credentials in myConfig, Create Api instance

const api = new Api(myConfig)

If all of your credentials are valid, you must be able to serach in Amazon now.

  console.log(' ===== find by Item ids =====')
  let resourceList = resources.getItemInfo
  resourceList = resourceList
    .concat(resources.getImagesPrimary)

  api.getItemById(['B079JD7F7G'], {
    parameters: resourceList,
    condition: condition.Any
  }).then((response) => {
    console.log('data', response.data)
  }, (error) => {
    console.log('Error: ', error)
  })

Usage

api have four main functions to fetch data from amazon. Each function has 2 parameters and return promise.

  • api.getItemById(['asin1', 'asin2'], {})
  • api.search('keyword', {})
  • api.getVariations('asin1', {})
  • api.getBrowseNodes(['nodeid1', 'nodeid2'], {})

Inside then, block of the promise, response object contain response.data and response.response as full faw response from Amazon.

Sample tutorial for how to use this library is given in ./demo/index.js file.

Get a single or array of Products via ASIN

getItemById(['ASIN1', 'ASIN2'], params)
console.log(' ===== find by Item ids =====')
let resourceList = parameters.getItemInfo
resourceList = resourceList
  .concat(parameters.getImagesPrimary)

api.getItemById(['B079JD7F7G'], {
  parameters: resourceList,
  condition: condition.Any
}).then((response) => {
  console.log('data', response.data)
}, (error) => {
  console.log('Error: ', error)
})

Search Products

search('keyword', params)
console.log(' ===== search result =====')
let resourceList = parameters.getItemInfo
resourceList = resourceList
  .concat(parameters.getImagesPrimary)

api.search("Cowin E8", {
  parameters: resourceList,
  searchIndex: searchIndex.Electronics
}).then((response) => {
  console.log('data', response.data)
}, (error) => {
  console.log('Error: ', error)
})

Inside then, response object contain response.data and response.response as full faw response from Amazon.

Get Product Variations

getVariations('asin1', params)
console.log(' ===== search result =====')
const resourceList = parameters.getVariationSummary

api.getVariations("B079JD7F7G", {
  parameters: resourceList,
  condition: condition.Any
}).then((response) => {
  console.log('data', response.data)
}, (error) => {
  console.log('Error: ', error)
})

Get Browser Node

getBrowseNodes(['asin1'], params)
console.log(' ===== getBrowserNode =====')
const resourceList = parameters.getBrowserNodes

api.getBrowseNodes(['284507'], {
  parameters: resourceList
}).then((response) => {
  console.log('data', response.data)
}, (error) => {
  console.log('Error: ', error)
})

Contributing

We'd love to have your helping hand on amazon-pa-api50! We are preparing the contributing guideline and todo list. Meanwhile, please install, test and use this to find bugs or any creative ideas.

License

amazon-pa-api50 is an open source library licensed as MIT.