Feeds

According to Amazon’s documentation:

The Amazon MWS Feeds API section of the Amazon Marketplace Web Service (Amazon MWS) API lets you upload inventory and order data to Amazon. You can also use the Amazon MWS Feeds API section to get information about the processing of feeds.

More details on how to utilize the Feeds API per MWS requirements can be found at the above link. Below we’ll provide details on how to use this API with Feeds.

Uploading metadata for VAT invoices

Metadata for VAT invoices is processed as a FeedOptions parameter to the SubmitFeed operation, as described in Amazon’s documentation, Invoice Uploader Developer Guide (PDF) This parameter is not described in the standard MWS developer documentation, unfortunately, which can lead to some confusion.

When submitting a feed, you can either build the metadata string yourself following the above guidelines, or provide a dict to the feed_options arg for Feeds.submit_feed:

from mws import Feeds, Marketplaces

feeds_api = Feeds(MY_ACCESS_KEY, MY_SECRET_KEY, MY_ACCOUNT_ID)

feed_opts = {'orderid': '407-XXXXXX-6760332', 'invoicenumber': 51}

response = feeds_api.submit_feed(
    feed=my_invoice_file.encode(),
    feed_type='_UPLOAD_VAT_INVOICE_',
    feed_options=feed_opts,
    marketplace_ids=Marketplaces.UK.marketplace_id,
)

The above will automatically convert feed_opts into the formatted string 'metadata:orderid=407-XXXXXX-6760332;metadata:invoicenumber=51' when the request is sent. You can also send this same string as feed_options, if you wish to perform your own formatting:

response = feeds_api.submit_feed(
    feed=my_invoice_file.encode(),
    feed_type='_UPLOAD_VAT_INVOICE_',
    feed_options='metadata:orderid=407-XXXXXX-6760332;metadata:invoicenumber=51',
    marketplace_ids=Marketplaces.UK.marketplace_id,
)

Note

The format for the FeedOptions string is described in Amazon’s documentation here (PDF). You are welcome to format your own FeedOptions string, if you find that the python-amazon-mws implementation is not suitable for your specific needs.

You can find our implementation for this formatting within the source for Feeds.

Feeds API reference

class mws.Feeds(access_key, secret_key, account_id, region='US', uri='', version='', auth_token='', proxy=None, user_agent_str='', headers=None, force_response_encoding=None)[source]

Amazon MWS Feeds API.

Docs: https://docs.developer.amazonservices.com/en_US/feeds/Feeds_Overview.html

submit_feed(feed, feed_type, feed_options=None, marketplace_ids=None, amazon_order_id=None, document_type=None, content_type='text/xml', purge=False)[source]

The SubmitFeed operation. Uploads a feed for processing by Amazon MWS.

Requires feed, a file in XML or flat-file format encoded to bytes; and feed_type, a string detailing a FeedType enumeration.

All other parameters may change depending on the feed_type you select. See Amazon docs for details.

feed_options is used for feed_type “_UPLOAD_VAT_INVOICE_”, to provide FeedOption metadata. See Invoice Uploader Developer Guide (PDF), for details. Can accept a dict of simple key-value pairs, which will be converted to the proper string format automatically.

marketplace_ids accepts a list of one or more marketplace IDs where you want the feed to be applied. Can also accept a single marketplace ID as a string.

amazon_order_id and document_type are used for feed_type “_POST_EASYSHIP_DOCUMENTS_”, used for Amazon Easy Ship orders (available only in India marketplace). Provide an Amazon Order ID as a string and the type of PDF document (“ShippingLabel”, “Invoice”, or “Warranty”; or None to get all).

content_type sets the “Content-Type” request header, indicating the type of file being sent. Defaults to "text/xml".

purge enables Amazon’s “purge and replace” functionality. Set to True to purge and replace existing data, otherwise use False (the default). Only applies to product-related flat file feed types. Use only in exceptional cases. Usage is throttled to allow only one purge and replace within a 24-hour period.

get_feed_submission_list(feed_ids=None, max_count=None, feed_types=None, processing_statuses=None, from_date=None, to_date=None, next_token=None)[source]

Returns a list of all feed submissions submitted between from_date and to_date. If these params are omitted, defaults to the previous 90 days.

Pass next_token to call “GetFeedSubmissionListByNextToken” instead.

Docs: https://docs.developer.amazonservices.com/en_US/feeds/Feeds_GetFeedSubmissionList.html

get_feed_submission_list_by_next_token(token)[source]

Alias for get_feed_submission_list(next_token=token).

Docs: https://docs.developer.amazonservices.com/en_US/feeds/Feeds_GetFeedSubmissionListByNextToken.html

get_feed_submission_count(feed_types=None, processing_statuses=None, from_date=None, to_date=None)[source]

Returns a count of the feeds submitted between from_date and to_date. If these params are omitted, defaults to the previous 90 days.

Docs: https://docs.developer.amazonservices.com/en_US/feeds/Feeds_GetFeedSubmissionCount.html

cancel_feed_submissions(feed_ids=None, feed_types=None, from_date=None, to_date=None)[source]

Cancels one or more feed submissions and returns a count of the feed submissions that were canceled.

Docs: https://docs.developer.amazonservices.com/en_US/feeds/Feeds_CancelFeedSubmissions.html

get_feed_submission_result(feed_id)[source]

Returns the feed processing report and the Content-MD5 header.

Docs: https://docs.developer.amazonservices.com/en_US/feeds/Feeds_GetFeedSubmissionResult.html

class FeedProcessingStatus(value)

Enumerates all the feed processing status values that are available through the Feeds API section.

MWS Docs: FeedProcessingStatus enumeration

class FeedType(value)

Enumerates all the feed types that are available through the Feeds API section.

MWS Docs: FeedType enumeration

Please refer to MWS documentation for details on each FeedType, including usage, template files, and additional information links.