How to get Amazon Orders using API

You can create straightforward applications that only retrieve the order information you require using the Orders API section of the Amazon Marketplace Web Service (Amazon MWS). This makes it possible for you to create unique applications quickly, easily, and adaptably in fields like demand-based decision support tools, order synchronisation, and order research.

Important: The role Amazon assigns you after you submit the Developer Registration and Assessment form determines your access to Amazon MWS data. See Registering to Use Amazon MWS for more details.

Objective of the blog

After reading this blog, you will be able to understand how sellers can get the Amazon orders using API.

Let’s know about the order’s API

Amazon orders API helps the sellers to get the order’s details and synchronized the Amazon orders on their custom application. This is very helpful for retrieving order updates in real-time and the sellers can also get the order status (shipped or unshipped) information easily for all orders by using API.

How to synchronized Amazon orders on custom application

First of all, you need the credential of Amazon MWS (Market Place Web Service) API. If you still don’t have, you can get the help from this blog

To fetch Amazon orders on your end, you need to follow the below steps:

1. List Orders – In this step, you need to send a request to Amazon to get the orders from Amazon for a particular time interval.

You need to send the following data given below in the request:

mws.amazonservices.co.uk/Orders/2013-09-01
?AWSAccessKeyId=XXXXXXXXXXXXXXX
&Action=ListOrders
&SellerId= XXXXXXXXXXXXXX                                // Here write your merchant id
&SignatureVersion=2                                             // Here write your signature version
&Timestamp= gmdate("Y-m-d\TH:i:s\Z", time())     // Write the time stamp &Version=2013-09-01
&Signature=1234Knowband1234example1234                              // Here you need to write the signature
&SignatureMethod=HmacSHA256                     // Here write your signature method
&LastUpdatedAfter=date("Y-m-d\TH:i:s\Z", strtotime('-24 hour'));  //request to get orders for last 24 hours only from Amazon
&OrderStatus.Status.1=Unshipped                // Here you need to add the status for which you want to fetch the orders
&OrderStatus.Status.2=PartiallyShipped         
&OrderStatus.Status.3=Shipped                     
&MarketplaceId.Id.1= XXXXXXXXXXXXX  
AWSAccessKeyId=XXXXXXXXXXXXXXXXXXXX

In the response, you will get an order feed file which will contain the list of orders which are placed on Amazon in the last 24 hours and have the requested order status.
Here is the sample order feed file.

<?xml version="1.0"?>
<ListOrdersResponse xmlns="https://mws.amazonservices.com/Orders/2013-09-01”>
    <ListOrdersResult>
        <Orders>
            <Order>
                <LatestShipDate>2018-03-09T07:59:59Z</LatestShipDate>
                <OrderType>StandardOrder</OrderType>
                <PurchaseDate>2018-03-07T01:15:57Z</PurchaseDate>
                <AmazonOrderId>112-5028700-7051869</AmazonOrderId>
                <BuyerEmail>knowband@marketplace.amazon.com</BuyerEmail>
                <IsReplacementOrder>false</IsReplacementOrder>
                <LastUpdateDate>2018-03-07T10:05:30Z</LastUpdateDate>
                <NumberOfItemsShipped>1</NumberOfItemsShipped>
                <ShipServiceLevel>Std US D2D Intl</ShipServiceLevel>
                <OrderStatus>Shipped</OrderStatus>
                <SalesChannel>Amazon.com</SalesChannel>
                <ShippedByAmazonTFM>false</ShippedByAmazonTFM>
                <IsBusinessOrder>false</IsBusinessOrder>
                <LatestDeliveryDate>2018-04-06T06:59:59Z</LatestDeliveryDate>
                <NumberOfItemsUnshipped>0</NumberOfItemsUnshipped>
                <PaymentMethodDetails>
                    <PaymentMethodDetail>Standard</PaymentMethodDetail>
                </PaymentMethodDetails>
                <BuyerName>George</BuyerName>
                <EarliestDeliveryDate>2018-03-21T07:00:00Z</EarliestDeliveryDate>
                <OrderTotal>
                    <CurrencyCode>USD</CurrencyCode>
                    <Amount>49.44</Amount>
                </OrderTotal>
                <IsPremiumOrder>false</IsPremiumOrder>
                <EarliestShipDate>2018-03-07T08:00:00Z</EarliestShipDate>
                <MarketplaceId>ATVPDKIKX0DER</MarketplaceId>
                <FulfillmentChannel>MFN</FulfillmentChannel>
                <PaymentMethod>Other</PaymentMethod>
                <ShippingAddress>
                    <City>Hong Kong</City>
                    <Phone>XXXXXXXXXX</Phone>
                    <CountryCode>HK</CountryCode>
                    <Name>Khattak Muhammad S.B</Name>
                    <AddressLine1>D, Block 2, Example </AddressLine1>
                    <AddressLine2>H Address Example</AddressLine2>
                </ShippingAddress>
                <IsPrime>false</IsPrime>
                <ShipmentServiceLevelCategory>Standard</ShipmentServiceLevelCategory>
        </Order>
        <Order>
            <LatestShipDate>2018-03-09T07:59:59Z</LatestShipDate>
            <OrderType>StandardOrder</OrderType>
            <PurchaseDate>2018-03-06T20:23:38Z</PurchaseDate>
            <AmazonOrderId>114-8648933-7253863</AmazonOrderId>
            <BuyerEmail>knowband1@marketplace.amazon.com</BuyerEmail>
            <IsReplacementOrder>false</IsReplacementOrder>
            <LastUpdateDate>2018-03-07T10:05:31Z</LastUpdateDate>
            <NumberOfItemsShipped>2</NumberOfItemsShipped>
            <ShipServiceLevel>Std US D2D Dom</ShipServiceLevel>
            <OrderStatus>Shipped</OrderStatus>
            <SalesChannel>Amazon.com</SalesChannel>
            <ShippedByAmazonTFM>false</ShippedByAmazonTFM>
            <IsBusinessOrder>false</IsBusinessOrder>
            <LatestDeliveryDate>2018-04-06T06:59:59Z</LatestDeliveryDate>
            <NumberOfItemsUnshipped>0</NumberOfItemsUnshipped>
            <PaymentMethodDetails>
                <PaymentMethodDetail>Standard</PaymentMethodDetail>
            </PaymentMethodDetails>
            <BuyerName>George</BuyerName>
            <EarliestDeliveryDate>2018-03-21T07:00:00Z</EarliestDeliveryDate>
            <OrderTotal>
            <CurrencyCode>USD</CurrencyCode>
            <Amount>98.87</Amount>
            </OrderTotal>
            <IsPremiumOrder>false</IsPremiumOrder>
            <EarliestShipDate>2018-03-07T08:00:00Z</EarliestShipDate>
            <MarketplaceId>ATVPDKIKX0DER</MarketplaceId>
            <FulfillmentChannel>MFN</FulfillmentChannel>
            <PaymentMethod>Other</PaymentMethod>
            <ShippingAddress>
                <City>Hobe Sound</City>
                <AddressType>Residential</AddressType>
                <PostalCode>2101</PostalCode>
                <StateOrRegion>FL</StateOrRegion>
                <Phone>XXXXXXXXXX</Phone>
                <CountryCode>US</CountryCode>
                <Name> SMITH</Name>
                <AddressLine1>Knowband </AddressLine1>
            </ShippingAddress>
            <IsPrime>false</IsPrime>
            <ShipmentServiceLevelCategory>Standard</ShipmentServiceLevelCategory>
        </Order>
        <LastUpdatedBefore>2018-03-08T06:58:45Z</LastUpdatedBefore>
    </ListOrdersResult>
    <ResponseMetadata>
    <RequestId>7fc9364b-a296-4380-954d-1b0355b9ccea</RequestId>
    </ResponseMetadata>
</ListOrdersResponse>

2. List Order Items – From the first step, you will only get order details (like Amazon orders id, purchase date, etc) not order item details (ordered product detail). To get the order’s item details, you will need to send a separate request to Amazon. You need to send request corresponding to each order. If you need details for 5 Amazon orders then you will need to send 5 requests.

The request is given below:

e.g $Amazon_order_id = 112-5028700-7051869

mws.amazonservices.co.uk/Orders/2013-09-01  
?AWSAccessKeyId=XXXXXXXXXXXXXXXXXXXX
&Action= ListOrderItems
&SellerId=‘XXXXXXXXXXXXXX’;           // Here write your merchant id,
&'AmazonOrderId'=$Amazon_order_id       // Here write the order id for which you want to get detail
// Here you need to write the signature, when you send HTTP requests to AWS, you need to sign the requests so that AWS can identify who sent the request
&Signature=1234Knowband1234example1234  
&SignatureVersion=2                                 // Here write your signature version
&SignatureMethod=HmacSHA256               // Here write your signature method
&Timestamp=gmdate("Y-m-d\TH:i:s\Z", time())      // Write the time stamp
&Version=2013-09-01

In response of the request, you will get the descriptive detail of the order. The sample is given below:

mws.amazonservices.co.uk/Orders/2013-09-01  
<?xml version="1.0"?>
<ListOrderItemsResponse xmlns="https://mws.amazonservices.com/Orders/2013-09-01&quot;>
  <ListOrderItemsResult>
    <OrderItems>
      <OrderItem>
        <QuantityOrdered>1</QuantityOrdered>
        <Title>Manchester United Kids Third Shorts 2017/18</Title>
        <ShippingTax>
          <CurrencyCode>USD</CurrencyCode>
          <Amount>0.00</Amount>
        </ShippingTax>
        <PromotionDiscount>
          <CurrencyCode>USD</CurrencyCode>
          <Amount>0.00</Amount>
        </PromotionDiscount>
        <ConditionId>New</ConditionId>
        <IsGift>false</IsGift>
        <ASIN>B072N7QV69</ASIN>
        <SellerSKU>x-96909-266</SellerSKU>
        <OrderItemId>22621871528658</OrderItemId>
        <ProductInfo>
          <NumberOfItems>1</NumberOfItems>
        </ProductInfo>
        <GiftWrapTax>
          <CurrencyCode>USD</CurrencyCode>
          <Amount>0.00</Amount>
        </GiftWrapTax>
        <QuantityShipped>0</QuantityShipped>
        <ShippingPrice>
          <CurrencyCode>USD</CurrencyCode>
          <Amount>19.95</Amount>
        </ShippingPrice>
        <GiftWrapPrice>
          <CurrencyCode>USD</CurrencyCode>
          <Amount>0.00</Amount>
        </GiftWrapPrice>
        <ConditionSubtypeId>New</ConditionSubtypeId>
        <ItemPrice>
          <CurrencyCode>USD</CurrencyCode>
          <Amount>29.49</Amount>
        </ItemPrice>
        <ItemTax>
          <CurrencyCode>USD</CurrencyCode>
          <Amount>0.00</Amount>
        </ItemTax>
        <ShippingDiscount>
          <CurrencyCode>USD</CurrencyCode>
          <Amount>0.00</Amount>
        </ShippingDiscount>
      </OrderItem>
    </OrderItems>
    <AmazonOrderId>112-5028700-7XXX</AmazonOrderId>
  </ListOrderItemsResult>
  <ResponseMetadata>
    <RequestId>7b5d934c-cce7-45e6-ab99-d49da35c0a41</RequestId>
  </ResponseMetadata>
</ListOrderItemsResponse>

3. Create Orders – This step is the final step and from step 1 & 2, you got all the details of the Amazon orders which you need to create orders on your application. By parsing the above XML feeds (list order and list order item), you can create orders on your application.

If an Amazon order is already created on your application then you can use the step 1 to update the order status of that order.

If you require any assistance or custom development, please feel free to reach us at support@knowband.com.

You can also check out marketplaces integration modules for Prestashop, Opencart, Magento, and Magento 2 here.

Convert your store into a native Android and iOS app with our No Code Mobile App Builder solution. Know more here:

 

How to Change Fulfillment Latency & Inventory for Products on Amazon Using API?

Objective:

After reading this blog, you will be able to understand how the seller can change inventory and fulfillment latency for products on Amazon using API.

Let’s know about the Fulfillment Latency

Fulfillment latency is the number of days in which the seller needs to dispatch the order after getting the order from Amazon. It can also be defined as the maximum time available to the seller to dispatch the parcel. The fulfillment time is set by the seller corresponding to each product. Fulfillment latency is also known as handling time.

Amazon fulfillment API helps the seller to set the product’s inventory and fulfillment latency time on Amazon.

How do change the Fulfillment Latency & Inventory for products using API?

Let us know about the fields that you will need to send in the request to Amazon:

Action

This field specifies the action which needs to be performed on the request and this helps to determine what parameter should be in the request.

Signature: Whenever you send the HTTP request to Amazon, you need to add the signature with the URL. By checking the signature, Amazon can identify the merchant from whom the request has been received. We use a hash value (HmacSHA256), some data of the request, and a secret access key to create a signature.

Signature Versions

2 signature versions are supported and these versions are:

(1)Version 4:
(2)Version 2:

Both versions can be used to sign the request but we recommend you to sign your request with Signature Version 4 in this blog, signature version 2 is used.

Purge and replace

The purge and replace field replaces the existing listing of products from Amazon if its value is true. So you always need to set its value to false in the request if don’t want to remove listingsting from AmazFreeTypeType

Feed type specifies how the data should be processed. To change fulfillment latency and inventory, you need to specify the feed type “_POST_INVENTORY_AVAILABILITY_DATA_”.

Signature Method

Signature methods hash-based based protocols and you need to apply these methods to calculate signatures. E.g. HmacSHA256

Timestamp

In this field, you need to add the time at which you are making the request.

To change the fulfillment latency and inventory of the product, you need to send the following data in the request to Amazon:
$url =

https://mws.amazonservices.co.uk                               // Here you need to write the End point
/?AWSAccessKeyId=XXXXXXXXXXXXXXXXXXXX              // Here write your AWS Access Key
&Action=SubmitFeed                                        // Action should be SubmitFeed   &FeedType=_POST_INVENTORY_AVAILABILITY_DATA_  // Feed Type    
&MarketplaceIdList.Id.1= XXXXXXXXXXXXXX                 // Here write your marketplace list id
&Merchant=XXXXXXXXXXXXXX                                     // Here write your seller id or merchant id
&Signature=1234Knowband1234example1234         // Here you need to write the signature
&SignatureMethod=HmacSHA256                                  // Hash method which used to create signature
&SignatureVersion=2
&Timestamp=gmdate("Y-m-d\TH:i:s\Z",time()))
&Version=2009-01-01
&PurgeAndReplace=false                                            // Always set purgeAndReplace Value as false   
                                                                                   // else it will replace all the existing product data

You will also need to create the XML file which will contain inventory and fulfillment latency details of those SKUs for which you want to change the fulfillment latency and inventory. The sample feed is given below:

$xml_file = Full path of the XML file on the server

$xml_data is given below

<AmazonEnvelope xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>XXXX-XXXX-XXXX</MerchantIdentifier>
</Header>
<MessageType>Inventory</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Inventory>
<SKU>p-25976-MB</SKU>
<Quantity>0</Quantity>
<FulfillmentLatency>2</FulfillmentLatency>
</Inventory>
</Message>
<Message>
<MessageID>2</MessageID>
<OperationType>Update</OperationType>
<Inventory>
<SKU>p-25976-XSB</SKU>
<Quantity>0</Quantity>
<FulfillmentLatency>2</FulfillmentLatency>
</Inventory>
</Message>
<Message>
<MessageID>3</MessageID>
<OperationType>Update</OperationType>
<Inventory>
<SKU>p-25976-X-L</SKU>
<Quantity>0</Quantity>
<FulfillmentLatency>2</FulfillmentLatency>
</Inventory>
</Message>
<Message>
<MessageID>4</MessageID>
<OperationType>Update</OperationType>
<Inventory>
<SKU>p-25976-SB</SKU>
<Quantity>0</Quantity>
<FulfillmentLatency>2</FulfillmentLatency>
</Inventory>
</Message>
<Message>
<MessageID>5</MessageID>
<OperationType>Update</OperationType>
<Inventory>
<SKU>p-25976-LB</SKU>
<Quantity>0</Quantity>
<FulfillmentLatency>2</FulfillmentLatency>
</Inventory>
</Message>
</AmazonEnvelope>

You need to send the request UXML XML data and header together in a request. The header values are used by the server for an end-to-end check on the data and for detecting unintentional modifications to the data further in the transition.

$headers = array (
          'Expect: ',
          'Accept: ',
         'Transfer-Encoding: chunked',
         'Content-Type: application/x-www-form-urlencoded; charset=utf-8',
         'Content-MD5: ' . base64_encode(md5_file($xml_file, true))        //encode the xml file
 );

 

$options = array(
         CURLOPT_URL                  => $url,
        CURLOPT_POST                    => 1,
                       CURLOPT_FOLLOWLOCATION => true, // follow redirects
           CURLOPT_RETURNTRANSFER => true, // return web page             
         CURLOPT_POSTFIELDS          => $xml_data,
         CURLOPT_HTTPHEADER         => $headers,
         CURLOPT_ENCODING             => "UTF-8",       // handle all encodings
           CURLOPT_AUTOREFERER        => true, // set referer on redirect
           CURLOPT_CONNECTTIMEOUT  => 120, // timeout on connect
                CURLOPT_TIMEOUT                => 120, // timeout on response
           CURLOPT_SSL_VERIFYHOST    => 2,
           CURLOPT_SSL_VERIFYPEER     => false, // disable certificate checking
           CURLOPT_FILE                   => "$fp"
           );
$ch = curl_init( $url );
@curl_setopt_array( $ch, $options );
$content = curl_exec( $ch );

In the response, you will get the number of the SKU which are successfully processed (means fulfillment latency and inventory have been changed) and the number of SKU tis is not processed due to error, as given in the screenshot of the response feed below:

 

Summary

After reading this document, you (seller) can easily change the fulfillment latency and inventory of products on Amazon using Amazon MWS API.

Knowband offers eCommerce development services and can assist you in creating a brand-new eCommerce website. To provide our customers with the greatest and most efficient post-sale service, we have a dedicated support team that is constantly on hand to help them. We continue to fulfill our duties to clients that want help with urgent website issues even on the weekends.

The best Magento, Opencart, Prestashop, and Magento 2 modules are also available. One Page SuperCheckout, Multi-Vendor Marketplace, Mobile App Builder, Spin and Win Module, Abandoned Cart, and more popular modules are just a few of what Knowband has to offer. You can reach us at support@knowband.com if you have any questions.

How to Use Environments in Postman?

What are Environments?

When working with APIs, you will often need to have different configurations. For example, your local machine, the development server, or the production API. Environments provide the ability to customize requests using variables. This way, you can easily switch between different settings without changing your requests. You won’t have to worry about remembering all these values once they’re in Postman. Environments can be downloaded and saved as JSON files and loaded later.

Steps to Create a New Environment

Click the Environments section in the left menu.

Click the Add button or Create Environment to create a new environment.

Click the Add button to create a new environment.

Provide the environment name such as local/development or production.

Each environment is a set of key-value pairs, with the key as the variable name.

for example, here we create two keys that can be used when triggering APIs

API_URL

APP_VERSION

We can also define global variables that can be accessible in all environments. Click on the global button. 

Set the key values as previously defined when creating an environment and click the save button.

Steps to Use Environment

Select an active environment

Click the drop-down menu in the top right corner of the Postman app to select an active environment, or type the environment name. After selecting an environment, you can access variables in the scope of the active environment.

Access Environment Variables

Once you’ve chosen the platform, you can easily access the variable in the Body, Headers, or Request URL.

Note: The variable name will be enclosed in double braces. for example, {{API_URL}}. You can also get the variable suggestion by typing simple braces ‘{‘

In the screenshot below, we have used variables in Request Url and Body parameters.

Note: Global and environment variables will always be stored as strings. If you are storing objects/arrays, be sure to JSON.stringify() before storing them and JSON.parse() during retrieval.

For any queries, please feel free to reach us at support@knowband.com.

You can also take a look at the best eCommerce modules provided by Knowband for Prestashop, Opencart, Magento, and Magento 2.

Check out our top selling Modules:

Prestashop Android and iOS Mobile App Builder Addon

Android and iOS App Maker for Opencart

One Page checkout addon for Prestashop

Knowband Mobile App Builder

Get the mobile app created for your store in a few hours with the Knowband Mobile App Builder Module.

Learn More