Giter Club home page Giter Club logo

amazon-affiliate-api's Introduction

NodeJS Amazon Affiliate API Client


THIS PROJECT IS NO LONGER MAINTAINED

I have lost my affiliate api key, and can no longer maintain this project (I can't test).

If you find this library useful, I would love to transfer the whole repo to you - simply ask me. However, please don't ask for updates.

YOUR OPTIONS

Amazon Webservices has released a Product Advertising API for node - webservices.amazon.com/paapi5


Build Status Dependency Status

Amazon Product API

"amazon-affiliate-api" is just a thin wrapper around Amazon's API.

The intent is to simplify the request process by automatically handling request signatures, performing the HTTP requests, processing the responses and parsing the XML.

The result is that you feel like you're working directly with the API, but you don't have to worry about some of the more tedious tasks.

This library impliments Q promises, and supports callbacks.

Installation

Install using npm:

npm install amazon-affiliate-api

Usage

Require library

amazon = require('amazon-affiliate-api');

Create client

var client = amazon.createClient({
  awsId: "aws ID",
  awsSecret: "aws Secret",
  awsTag: "aws Tag"
});

Now you can search for items on amazon:

Search Items

using promises:

client.itemSearch({
  director: 'Quentin Tarantino',
  actor: 'Samuel L. Jackson',
  searchIndex: 'DVD',
  audienceRating: 'R',
  responseGroup: 'ItemAttributes,Offers,Images'
}).then(function(results){
  console.log(results);
}).catch(function(err){
  console.log(err);
});

using a callback:

client.itemSearch({
  director: 'Quentin Tarantino',
  actor: 'Samuel L. Jackson',
  searchIndex: 'DVD',
  audienceRating: 'R',
  responseGroup: 'ItemAttributes,Offers,Images'
}, function(err, results) {
  if (err) {
    console.log(err);
  } else {
    console.log(results);
  }
});
Search query options:

You can add any available params for the itemSearch method.

condition: availiable options - 'All', 'New', 'Used', 'Refurbished', 'Collectible'. Defaults to 'All'.

keywords: Defaults to ''.

responseGroup: You can use multiple values by separating them with comma (e.g responseGroup: 'ItemAttributes,Offers,Images'). Defaults to'ItemAttributes'

searchIndex: Defaults to 'All'.

itemPage: Defaults to '1'.

sort: Valid values include 'salesrank','psrank','titlerank','-price','price'.

domain: Defaults to 'webservices.amazon.com'.

Lookup Item

using promises:

client.itemLookup({
  idType: 'UPC',
  itemId: '884392579524'
}).then(function(results) {
  console.log(results);
}).catch(function(err) {
  console.log(err);
});

using a callback:

client.itemLookup({
  idType: 'UPC',
  itemId: '635753490879',
  responseGroup: 'ItemAttributes,Offers,Images'
}, function(err, results) {
  if (err) {
    console.log(err);
  } else {
    console.log(results);
  }
});
LookupItem query options:

You can add any available params for the ItemLookup method.

condition: options - 'All', 'New', 'Used', 'Refurbished', 'Collectible'. Defaults to 'All'

idType: Type of item identifier used to look up an item. options - 'ASIN', 'SKU', 'UPC', 'EAN', 'ISBN'. Defaults to 'ASIN'.

includeReviewsSummary: options - 'True','False'. Defaults to 'True'.

itemId: One or more (up to ten) positive integers that uniquely identify an item.

responseGroup: You can use multiple values by separating them with comma (e.g responseGroup: 'ItemAttributes,Offers,Images'). Defaults to 'ItemAttributes'

searchIndex: Defaults to 'All'.

truncateReviewsAt: Defaults to '1000'. To return complete reviews, specify '0'.

variationPage: Defaults to 'All'.

domain: Defaults to 'webservices.amazon.com'.

SimilarityLookup

using promises:

client.similarityLookup({
  itemId: '8416904626,0670921602', 
  SimilarityType: 'Random',
  responseGroup: 'ItemAttributes,Offers,Images'
}).then(function(results) {
  console.log(results);
}).catch(function(err) {
  console.log(err);
});

using a callback:

client.similarityLookup({
  itemId: '8416904626,0670921602', 
  SimilarityType: 'Random',
  responseGroup: 'ItemAttributes,Offers,Images'
}, function(err, results) {
  if (err) {
    console.log(err);
  } else {
    console.log(results);
  }
});
SimilarityLookup query options:

You can add any available params for the SimilarityLookup method.

condition: options - 'All', 'New', 'Used', 'Refurbished', 'Collectible'. Defaults to 'All'

itemId: One or more (up to ten) ASINs identifying an item.

responseGroup: You can use multiple values by separating them with comma (e.g responseGroup: 'ItemAttributes,Offers,Images'). Defaults to 'ItemAttributes'

MerchantId: By default returns items sold by various merchants including Amazon. Use 'Amazon' as value to return only items sold by Amazon.

SimilarityType: 'Intersection' returns the intersection of items that are similar to all ASINs specified. 'Random' returns the union of items that are similar to alll ASINs specified picking them randomly. Default is 'Intersection'.

domain: Defaults to 'webservices.amazon.com'.

Browse Node Lookup

using promises:

client.browseNodeLookup({
  browseNodeId: '549726',
  responseGroup: 'NewReleases'
}).then(function(results) {
  console.log(results);
}).catch(function(err) {
  console.log(err);
});

using a callback:

client.browseNodeLookup({
  browseNodeId: '549726',
  responseGroup: 'NewReleases'
}, function(err, results) {
  if (err) {
    console.log(err);
  } else {
    console.log(results);
  }
});
BrowseNodeLookup query options:

You can add any available params for the BrowseNodeLookup method.

browseNodeId: A positive integer assigned by Amazon that uniquely identifies a product category.

responseGroup: You can use multiple values by separating them with comma (e.g responseGroup: 'MostGifted,NewReleases,MostWishedFor,TopSellers'). Defaults to 'BrowseNodeInfo'

Now you can manipulate amazon remote shopping-cart:

PLEASE NOTE

Most methods for Cart require both CartId and HMAC, which are returned by CartCreate.

Cart Create

You must include at least one item on cart creation. cartCreate returns "CartId" and "HMAC", which are required by all subsiquent requests to this cart.

using promises

client.cartCreate({
  items:[{
    ASIN: "B00LZTHUH6",
    Quantity: 1
  }, {
    ASIN: "B00OZTLE8Y",
    Quantity: 1
  }]
}).then(function(results){
  console.log(results);
}).fail(
  console.log(results);
});

using callbacks

client.cartCreate({
  items:[{
    ASIN: "B00LZTHUH6",
    Quantity: 1
  }, {
    ASIN: "B00OZTLE8Y",
    Quantity: 1
  }]
}, function (err, results ){
	console.log(err, results);
});
cartCreate query options:

You can add any available params for the CartCreate method.

items: an array of items to add to the cart; must include Quantity and one of ASIN or OfferListingId.

responseGroup: You can use multiple values by separating them with comma (e.g responseGroup: 'MostGifted,NewReleases,MostWishedFor,TopSellers'). Defaults to 'Cart'

Cart Clear

using promises

client.cartClear({
  'CartId': <results.Cart.CartId>,
  'HMAC': <results.Cart.HMAC>
}).then(function(results){
  console.log(results);
}).fail(
  console.log(results);
});

using callbacks

client.cartCreate({
  'CartId': <results.Cart.CartId>,
  'HMAC': <results.Cart.HMAC>
}, function (err, results ){
	console.log(err, results);
});
cartClear query options:

You must supply the CartId and HMAC returned from the cartCreate method.

You can add any available params for the CartClear method.

responseGroup: You can use multiple values by separating them with comma (e.g responseGroup: 'MostGifted,NewReleases,MostWishedFor,TopSellers'). Defaults to 'Cart'

Cart Add Item

using promises

client.cartAdd({
  'CartId': <results.Cart.CartId>,
  'HMAC': <results.Cart.HMAC>,
  items:[{
    ASIN: "B00LZTHUH6",
    Quantity: 1
  }, {
    ASIN: "B00OZTLE8Y",
    Quantity: 1
  }]
}).then(function(results){
  console.log(results);
}).fail(
  console.log(results);
});

using callbacks

client.cartAdd({
  'CartId': <results.Cart.CartId>,
  'HMAC': <results.Cart.HMAC>,
  items:[{
    ASIN: "B00LZTHUH6",
    Quantity: 1
  }, {
    ASIN: "B00OZTLE8Y",
    Quantity: 1
  }]
}, function (err, results ){
	console.log(err, results);
});
cartAdd query options:

You must supply the CartId and HMAC returned from the cartCreate method.

You can add any available params for the CartAdd method.

items: an array of items to add to the cart; must include Quantity and one of ASIN or OfferListingId.

responseGroup: You can use multiple values by separating them with comma (e.g responseGroup: 'MostGifted,NewReleases,MostWishedFor,TopSellers'). Defaults to 'Cart'

Get Cart

using promises

client.cartGet({
  'CartId': <results.Cart.CartId>,
  'HMAC': <results.Cart.HMAC>
}).then(function(results){
  console.log(results);
}).fail(
  console.log(results);
});

using callbacks

client.cartAdd({
  'CartId': <results.Cart.CartId>,
  'HMAC': <results.Cart.HMAC>,
}, function (err, results ){
	console.log(err, results);
});
cartGet query options:

You must supply the CartId and HMAC returned from the cartCreate method.

You can add any available params for the CartGet method.

responseGroup: You can use multiple values by separating them with comma (e.g responseGroup: 'MostGifted,NewReleases,MostWishedFor,TopSellers'). Defaults to 'Cart'

Modify Cart

using promises

client.cartModify({
  'CartId': <results.Cart.CartId>,
  'HMAC': <results.Cart.HMAC>,
  items:[{
      CartItemId: <results.Cart.CartItems.CartItem[0].CartItemId>,
      Quantity: 0
  }, {
      CartItemId: <results.Cart.CartItems.CartItem[0].CartItemId>,
      Quantity: 0
  }]
}).then(function(results){
  console.log(results);
}).fail(
  console.log(results);
});

using callbacks

client.cartModify({
  'CartId': <results.Cart.CartId>,
  'HMAC': <results.Cart.HMAC>,
  items:[{
      CartItemId: <results.Cart.CartItems.CartItem[0].CartItemId>,
      Quantity: 0
  }, {
      CartItemId: <results.Cart.CartItems.CartItem[0].CartItemId>,
      Quantity: 0
  }]
}, function (err, results ){
	console.log(err, results);
});
cartModify query options:

You must supply the CartId and HMAC returned from the cartCreate method.

You can add any available params for the CartModify method.

items: an array of items to modify in the cart; must include Quantity and one of CartItemId (which cab be found in cartGet responses).

responseGroup: You can use multiple values by separating them with comma (e.g responseGroup: 'MostGifted,NewReleases,MostWishedFor,TopSellers'). Defaults to 'Cart'

Credits: (amazon-affiliate-api is a shameless ripoff of t3chnoboys's original work amazon-product-api)

amazon-affiliate-api's People

Contributors

christophby avatar cmincarelli avatar drag0s avatar nedstankus avatar sciences44 avatar sp-sap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

amazon-affiliate-api's Issues

The similarityLookup runs endless for unknown products

Hey could you help me with that? The similarityLookup never stops when the item is not found. I think theres a loop somewhere or the promise wont be rejected or resolved caused by another problem..

    client.similarityLookup({
      itemId: 'aa',
      SimilarityType: 'Random',
      responseGroup: 'ItemAttributes,Offers,Images,SalesRank'
    }).then(function(results) {
      // never called
    }).catch(function(err) {
      // never called
    });

different awsTag / AssociateTag for different webservices

Hi,

thank you for the great work and letting us all reuse your coding!

As fas as I understood the localization of amazon services is not only separated by the webservice itself, but also by the 'AssociateTag' used. This is especially important when querying multiple webservices after another.

So the request I am making is to move the 'AssociateTag' out of the credentials/config and add it as parameter to the query itself.

Thank you already in advance!

can you test is the cart modify works, the cart create fine, but the cart modify not working always tell me there is missing parameter items

app.get('/', function (req, res) {
client.cartCreate({
items:[{
ASIN: "B0177G3QV4",
Quantity: 1
}]
}).then(result=>{
var data = {
id:result.Cart.CartId,
id2:result.Cart.HMAC,
id3:result.Cart.CartItems.CartItem[0].CartItemId,
}
return data
}).then(result=>{
client.cartModify({
'CartId':result.id,
'HMAC':result.id2,
items:[{
CartItemId: result.id3,
Quantity: 20
}]
}).then(result=>{
console.log(res)
})
})
})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.