t3chnoboy / amazon-product-api

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

Setting locale #32

Closed brycemolder closed 7 years ago

brycemolder commented 8 years ago

I didn't see instructions on how to set the Locale. Can I do:

    var client = AmazonShopping.createClient({
        awsId: "AKIAIZWLasdfasdfasdfasdfd",
        awsSecret: "yzOAltW4asdfasdfasdf",
        awsTag: "xxxxxxx",
        locale : "Mexico"
    });
adamrogas commented 8 years ago

The Product Advertising API is available in the following locales:

Locale URL

Brazil
http://webservices.amazon.com.br

Canada
http://webservices.amazon.ca

China
http://webservices.amazon.cn

France
http://webservices.amazon.fr

Germany http://webservices.amazon.de

India
http://webservices.amazon.in/

Italy
http://webservices.amazon.it

Japan
http://webservices.amazon.co.jp

Mexico
http://webservices.amazon.com.mx

Spain
http://webservices.amazon.es

United Kingdom
http://webservices.amazon.co.uk/

United States
http://webservices.amazon.com

So this would probably work:

client.itemLookup({

      browseNodeId: '549726',
      responseGroup: 'NewReleases',
      domain: 'webservices.amazon.com.mx'

    }, function (err, results) {
      if (err) {
        console.log(err);
      } else {
        console.log(results);
      }
sreeraghuparuchuri-zz commented 8 years ago

Hi @brycemolder @adamrogas

I am working on similar lines.. can you guys confirm if this worked?

sreeraghuparuchuri-zz commented 8 years ago

Update : I tried and it worked. domain: "required domain"

jaribu commented 8 years ago

Hi, I tried this code and I get : [ { Error: [ [Object], [Object] ] } ] `client.itemLookup({

browseNodeId: '549726', responseGroup: 'NewReleases', domain: 'webservices.amazon.com.mx'

}, function (err, results) { if (err) { console.log(err); } else { console.log(results); } });`

Can you explain me how to do this ?

masterT commented 8 years ago

Hi there,

To use a different endpoint in your request, you need the choose it from the Endpoints list. Then pass the domain of the endpoint in the domain params of your query.

Example:

I want to query the Canadian store 🇨🇦 . The endpoint is https://webservices.amazon.ca/onca/xml. The domain of the endpoint is webservices.amazon.ca.

var query = {
  artist: 'Radiohead',
  searchIndex: 'Music',
  sort: 'relevancerank',
  itemPage: 1,
  availability: 'Available',
  responseGroup: 'OfferFull,Large,Images',
  domain: 'webservices.amazon.ca'
};
client.itemSearch(query, function (error, results) {
  if (error) {
    console.log(error);
  } else {
    console.log(results);
  }
})

Note: when you use a different locales, the available params values change. Checkout the doc.

masterT commented 8 years ago

@jaribu maybe the error is not a domain problem. Can you log the error message?

masterT commented 7 years ago

Add how to specify the endpoint in the README.md.