t3chnoboy / amazon-product-api

:credit_card: Amazon Product Advertising API client
366 stars 104 forks source link

Feature request - Support BrowseNodeLookup #17

Closed Codepoet77 closed 9 years ago

Codepoet77 commented 9 years ago

Would it be too much effort to add BrowseNodeLookup? This is a method I need to call. I'm a .NET developer and am just starting out with Node.js. I would do it myself but it may be a little too time consuming for me. I was hoping that someone might be able to make that change more quickly than I would be able to. Looking at the source code the majority of it is done. The hardest part is creating the signature (which looks like it is already done). I am also guessing that IteamSearch would need to be updated as well to take BrowseNodeId as a parameter.

Thanks in advance. This is a high priority feature request for us.

masterT commented 9 years ago

ItemSearch now support all the params, including BrowseNodeId.

kaue commented 9 years ago

+1 @masterT What about the BrowseNodeLookup support? I need to use this operation with the ResponseGroup=NewReleases

kaue commented 9 years ago

@Codepoet77 @masterT I just submited a PR to support the BrowseNodeLook operation https://github.com/t3chnoboy/amazon-product-api/pull/19

Codepoet77 commented 9 years ago

Hi,

Also is the awstag required? I don't see it in the documentation but I see it in the url that is built up in util.js

I'm new to aws but I think this means that we need to be an affiliate which I would want to avoid if possible as the docs for item search don't seem to state it is a prerequisite.

Please let me know if I'm incorrect.

Thanks, Andrew

masterT commented 9 years ago

From the AWSECommerceService doc

AssociateTag

The AssociateTag parameter is a required parameter in Product Advertising API requests. When you register as an Amazon Associate, an Associate tag is sent to you by return email. An Associate tag, also known as an Associate ID, is an automatically generated unique identifier that you will need to make requests through the Product Advertising API. When you log in to the Amazon Associates website for your locale, the page that you are directed to includes a message that says "Signed in as" followed by your Associate tag.

Once a cart is associated with an Associate Tag, you must use it in every other cart operation related to that shopping cart. Otherwise, you will receive an error.

If you do not include an Associate Tag in the CartCreate request, your request will fail.

AssociateTag is locale-specific, that is, for each locale in which you want to earn Associate revenue, you must get an Associate Tag. If you try to use a US-locale Associate Tag, for example, in the JP locale, you will not earn Associate revenue.

Be careful when specifying an AssociateTag because errors are not returned for incorrect values.

Codepoet77 commented 9 years ago

http://docs.aws.amazon.com/AWSECommerceService/latest/DG/BrowseNodeLookup.html

Interesting I just didnt see any mention of the AWS Tag in the sample request that is listed on this page and I actually thought that made sense because I am not trying to advertise or interact with a cart I just want to find items.

Example from this page: http://docs.aws.amazon.com/AWSECommerceService/latest/DG/BrowseNodeLookup.html

http://webservices.amazon.com/onca/xml? Service=AWSECommerceService& AWSAccessKeyId=[AWS Access Key ID]& Operation=BrowseNodeLookup& BrowseNodeId=163357 &Timestamp=[YYYY-MM-DDThh:mm:ssZ] &Signature=[Request Signature]

Have you ever attempted to make the call without the awstag for the 3 methods that are currently supported. The documentation that you are referencing appears to be accurate for the cart method.

http://docs.aws.amazon.com/AWSECommerceService/latest/DG/CartCreate.html

AssociateTag is documented as required field for this particular call.

According to the documentation this is not necessarily true for BrowseNodeLookup, ItemSearch and ItemLookUp. It is not listed as a required field

http://docs.aws.amazon.com/AWSECommerceService/latest/DG/ItemSearch.html

http://docs.aws.amazon.com/AWSECommerceService/latest/DG/BrowseNodeLookup.html

http://docs.aws.amazon.com/AWSECommerceService/latest/DG/ItemLookup.html

Please let me know what you find. Would be nice to only have to supply the required fields for all 3 calls and also have the ability to supply the optional fields listed in the docs.

Codepoet77 commented 9 years ago

You can ignore my last question. Through trial and error and I was able to successfully make the ItemSearch call. I did have to use the awstag as you had suggested. At this point I just need access to the recent changes for BrowseNodeLookup and use of BrowseNodeId in ItemSearch.

Im new to Node.js and Express was trying to pull them down via npm using the "npm update --save" command in Expressjs app. I am assuming they are not yet available.

Thanks again for your help.

masterT commented 9 years ago

The PR #19 is not merge in master branch of the projet yet. When it will be merged you will be able to npm update --save. But for the moment you can use the version in the branch of @kauegimenes but you will need to uninstall the other one. So npm uninstall amazon-product-api and then npm install kauegimenes/amazon-product-api

masterT commented 9 years ago

@Codepoet77 did you set the awsTag to an empty string or you removed it from the request params?

masterT commented 9 years ago

@Codepoet77 @kauegimenes PR #19 is merged and published.

Codepoet77 commented 9 years ago

@masterT

Thanks for the npm tips as I am new to github and the npm world. :)

I tried removing the awsTag from the request params. Please try it yourself though because I tested it out quickly. I initially set it to an empty string before realizing that I needed to also remove it from the URL that is being built up. So I did both but would be good to have you confirm it as well. I still find it odd that the docs explicitly state it as being required for the cartCreate but not for the itemLookup, itemSearch and browseNodeLookup.

Thanks again!

masterT commented 9 years ago

@Codepoet77 I would have opened another issue for this, because it is not related to this issue, but I tried it and it didn't work.

First it change generateQueryString to add the AssociateTag only when it's defined.

if (typeof credentials.awsTag != "undefined") {
   params['AssociateTag'] = credentials.awsTag;
}

Without AssociateTag

var client = amazon.createClient({  
  awsId: process.env.AWS_ID,
  awsSecret: process.env.AWS_SECRET
});

client.itemSearch({
  keywords: 'Pulp fiction',
  searchIndex: 'DVD',
  responseGroup: 'ItemAttributes,Offers,Images',
  itemPage: '3'
}, function(err, results) {
  if (err) {
    console.log("ERROR");
    console.log(err);
  } else {
    console.log("SUCCESS");
    console.log(results);
  }
});

// result in the console
// => Success
// undefined

With blank AssociateTag

var client = amazon.createClient({
  awsTag: '',
  awsId: process.env.AWS_ID,
  awsSecret: process.env.AWS_SECRET
});

client.itemSearch({
  keywords: 'Pulp fiction',
  searchIndex: 'DVD',
  responseGroup: 'ItemAttributes,Offers,Images',
  itemPage: '3'
}, function(err, results) {
  if (err) {
    console.log("=> Error");
    console.log(err);
  } else {
    console.log("=> Success");
    console.log(results);
  }
});

// result in the console
// => Success
// undefined

I will close this issue. If there is anything else open a new issue. :sunglasses: