7

Connecting to Amazon MWS

Creating a data source for Amazon MWS (Seller Central) can be a daunting task. However, if you follow along with this step-by-step guide you should have no problem successfully pulling MWS data into Klipfolio! In this example request, we will pull a list of orders between June 1, 2017 to June 30, 2017.

For reference:

Note: If you do not have a developer account, you will need to sign up. Go to https://developer.amazonservices.com/ and click on "Sign up or manage Amazon MWS". You'll be prompted with a screen with options for your developer account. Select "I want to access my own Amazon seller account with MWS".

1. Gather the following information from your Amazon MWS account. 

- SellerID
- AccessKeyID
- SecretKey
- MarketplaceID

To obtain your MWS credentials go to the User Permissions page on Seller Central. Under Amazon MWS Developer Permissions section, in the Action Taken column click on View your credentials to view the AccessKeyID and Secret Key. 

Next, visit the MWS endpoints and MarketplaceID values page to determine which endpoint and MarketplaceID is required.


2. Use the Amazon MWS Scratchpad to test if you have the correct authentication credentials. Note that a MWSAuthToken is not required if you are the owner of the account.

3. Once you have confirmed a successful response with the MWS Scratchpad, you can construct your API call with the REST/URL connector.

4. Paste the following url in the query URL field and replace <AccessKeyID>, <MarketplaceID>, <SellerID>, and <SecretKey> with your MWS credentials:

https://mws.amazonaws.com/Orders/2013-09-01?AWSAccessKeyId=<AccessKeyID>&Action=ListOrders&CreatedAfter=2017-06-01T22%3A00%3A00Z&CreatedBefore=2017-06-30T22%3A00%3A00Z&MarketplaceId.Id.1=<MarketplaceID>&SellerId=<SellerID>&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp={date.addMinutes(10).tz('UTC').format("yyyy-MM-dd'T'HH'%3A'mm'%3A'ss'Z'");}&Version=2013-09-01&Signature={hash.append("GET").appendNewLine().append("mws.amazonaws.com").appendNewLine().append("/Orders/2013-09-01").appendNewLine().append("AWSAccessKeyId=<AccessKeyID>&Action=ListOrders&CreatedAfter=2017-06-01T22%3A00%3A00Z&CreatedBefore=2017-06-30T22%3A00%3A00Z&MarketplaceId.Id.1=<MarketplaceID>&SellerId=<SellerID>&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp="+date.addMinutes(10).tz('UTC').format("yyyy-MM-dd'T'HH'%3A'mm'%3A'ss'Z'")+"&Version=2013-09-01").encodeHmacSha256("<SecretKey>").encodeBase64().encodeURL().printDigest();}

- In addition:
- Set the Data Format to XML
- Set Method to GET
- Click Get Resource
- If you are satisfied with the data returned, click Continue.

5. Notes:
- Both the Request and Signature sections of the query must be entered alphabetically.
- Lines beginning with capital letters come before lines beginning with lower case letters. For example, AWSAccessKeyID= comes before Action=
- Pay attention to Klipfolio's method of adding new lines in the signature. For example, .appendNewLine().
- Make sure that there are NO SPACES in your query.

If you have any issues creating a successful request after following these instructions, let the Klipfolio team know and we'll be more than happy to help you out!

-Adam

12 comments

  • 1
    Avatar
    John Rhoads

    One million thumbs up to Adam for this!

    For dynamic dates:

    &CreatedAfter={date.start().yesterday.format("yyyy-MM-dd'T'HH'%3A'mm'%3A'ss'Z'")}&CreatedBefore={date.end().yesterday.format("yyyy-MM-dd'T'HH'%3A'mm'%3A'ss'Z'")}

    and

    &CreatedAfter="+date.start().yesterday.format("yyyy-MM-dd'T'HH'%3A'mm'%3A'ss'Z'")+"&CreatedBefore="+date.end().yesterday.format("yyyy-MM-dd'T'HH'%3A'mm'%3A'ss'Z'")+"&MarketplaceId.Id.1=...

  • 0
    Avatar
    Adam Doogan-Smith

    Hi John,

    Glad your found this tutorial useful! Also, thank you for the snippets for dyanmic date ranges. I'm sure many people will find that useful :)

    -Adam

  • 0
    Avatar
    Pravin Singh

    Hi Adam & John,

    Super helpful post for MWS connection! I used it and it worked fine for orders data basic pull.

    Just needed your help in few more aspects of this which I've described in 3 questions below:

    1. Dynamic dates pull: I'm trying to use John's query but just not working and throwing errors since it's a long query and I'm probably not using it right. Also, the query is just using "yesterday" only - not getting how that's dynamic. Kindly clear it out and give an example so we can test it out again.

    2. For any other MWS API like Products, Reports and other APIs listed on there docs, how exactly do we create a query like the above one you did for Orders?http://docs.developer.amazonservices.com/en_CA/dev_guide/index.html 

    I can see the queries in their documentation and it's massively different from the one you have written above. Can you please explain the differences and how we can pull the other APIs data also?

     

    If you could just answer these questions and share your thoughts, it would be super helpful! 

  • 0
    Avatar
    Josh Cohen-Collier

    Hi Pravin,

    Thanks for posting in our Community!

    For the query you are using here;
    https://mws.amazonaws.com/Orders/2013-09-01?AWSAccessKeyId=XXXXXXXXXX&Action=ListOrders&CreatedAfter={date.start().yesterday.format("yyyy-MM-dd'T'HH'%3A'mm'%3A'ss'Z'")}&CreatedBefore={date.end().yesterday.format("yyyy-MM-dd'T'HH'%3A'mm'%3A'ss'Z'")}&MarketplaceId.Id.1=XXXXXXXXX&SellerId=XXXXXXXX&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp={date.add...

    it looks like part of the query is missing, or ends early.
    Was there anything else that you were trying to add at the end?

    When he says the date is dynamic, what he means is that the value for yesterday will be recalculated every day, using our date and time query functions.
    If you want to pass in Klipfolio variables, you can do this using the following syntax;
    &createdAfter={props.startDate}

    You can follow this documentation here for more info.

    Hope this helps!

    Warm regards,
    Joshua

  • 0
    Avatar
    Pravin Singh

    Thanks Joshua, I've sent the latest query to support email - kindly check it out.

     

    Also, please let us know your thoughts on question #2 please

    2. For any other MWS API like Products, Reports and other APIs listed on there docs, how exactly do we create a query like the above one you did for Orders?http://docs.developer.amazonservices.com/en_CA/dev_guide/index.html 

    I can see the queries in their documentation and it's massively different from the one you have written above. Can you please explain the differences and how we can pull the other APIs data also?

  • 0
    Avatar
    David Cabasso

    How do i increase the number of results? In the scratchpad i try to do last month sales but it does not give full results. Only 200 results. any ideas? 

  • 0
    Avatar
    Adam Doogan-Smith

    Hi David,

    The max amount of records MWS allows per page is 200 and since they use token based pagination we are unfortunately not able to pull more than the 200 per API call.

    If you have more than 200 within the time frame inputted into the query, you might have to make a smaller time frame and then create multiple data sources to cover that particular time frame. From there you can use ARRAY() to "stitch" the multiple data sources together in a klip to return all the intended data.

    -Adam

  • 0
    Avatar
    David Cabasso

    Oh man! I had a feeling that would be the answer. thanks! Trying to build a chart with sales by month and then item sales by month. i guess i can use the same data sets to build both, correct? 

    If i do this, how do i not duplicate? 

  • 0
    Avatar
    David Cabasso

    Actually, I'll just download past months by XML and upload them

  • 0
    Avatar
    Adam Doogan-Smith

    Hi David,

    Yes you are correct. You can take a count of the amount of records of sales items for the month in one series and in the other series take a sum of the sales amounts.

    -Adam

  • 0
    Avatar
    Oscar Rocha

    Hey, thanks for this guide and example

    Its working for me substituting <AccessKeyID>, <MarketplaceID>, <SellerID>, and <SecretKey> directly with my MWS credentials as plain text

     

    Now Im planning on make it dynamically for clients dashboards on dates and value of variables

    but when im trying to use as enviroment variables at properties like {props.AWSAccessKeyId} etc  seems not working on Signature parameter when I replace it.   Do you know if is possible to use property variables on there too?

     

     

  • 1
    Avatar
    Oscar Rocha

    oh nevermind on Signature you must put this syntaxis for <AccessKeyID>, <MarketplaceID>, <SellerID>,

    &MWSAuthToken="+(props.MWSAuthToken)+"

    and for <SecretKey>

    encodeHmacSha256((props.SecretKey)).

Please sign in to leave a comment.