pymws package¶
pymws¶
-
class
pymws.pymws.
MWS
(marketplace, merchant_id=None, access_key_id=None, secret_key=None, auth_token=None)[source]¶ Primary client class that acts as a gateway to all of the functionality offered by this package.
Example usage:
client = MWS( marketplace="US", merchant_id="1234", access_key_id="key", secret_key="secret", auth_token="token" ) client.reports.get_reports_list()
Parameters: - marketplace – marketplace to connect to.
- merchant_id – Amazon merchant it.
- access_key_id – Access key of your app
- secret_key – Secret key of your app
- auth_token – Token obtained by the merchant after installing your app.
-
orders
¶ Fetch the order API client Returns an instance of
pymws.orders.Orders
-
products
¶ Fetch the products API client. Returns an instance of
pymws.products.Products
-
reports
¶ Fetch the reports API client Returns an instance of
pymws.reports.Reports
orders¶
-
class
pymws.orders.
Orders
(client)[source]¶ Implements an order API client for Amazon MWS
response = client.orders.list_orders(CreatedAfter=start_date) for order in response.Orders.getchildren(): print(order.AmazonOrderId)
for other attributes of the order, refer to the Amazon MWS documentation.
To fetch the next page of orders:
response = client.orders.list_orders(CreatedAfter=start_date) page2 = client.orders.list_orders_by_next_token( response.NextToken )
-
get_order
(AmazonOrderId)[source]¶ Returns orders based on the AmazonOrderId values that you specify.
-
list_order_items
(AmazonOrderId)[source]¶ Returns order items based on the AmazonOrderId that you specify.
-
list_order_items_by_next_token
(NextToken)[source]¶ Returns the next page of order items using the NextToken parameter.
-
list_orders
(**kwargs)[source]¶ Returns orders created or updated during a time frame that you specify.
-
product¶
fulfillment¶
-
class
pymws.fulfillment.outbound_shipment.
OutboundShipment
(client)[source]¶ Implements outbound shipment client for Amazon MWS
client.fulfillment_outbound_shipment.create_fulfillment_order( MarketplaceId='A2Q3Y263D00KWC', SellerFulfillmentOrderId='SO3421', FulfillmentAction='Ship', DisplayableOrderId='SO3421', DisplayableOrderDateTime=datetime.utcnow(), DisplayableOrderComment='Some comment', ShippingSpeedCategory='Standard', DestinationAddress={ 'Name': 'John Doe', 'Line1': 'Random street', 'StateOrProvinceCode': 'CA', 'CountryCode': 'US', }, Items=[{ 'SellerSKU': 'SKU-1', 'SellerFulfillmentOrderItemId': 'SO3421-1', 'Quantity': 1, }], )
for other attributes refer to the Amazon MWS documentation.
-
create_fulfillment_order
(**kwargs)[source]¶ Requests that Amazon ship items from the seller’s inventory in Amazon’s fulfillment network to a destination address.
-
reports¶
-
class
pymws.reports.
Reports
(client)[source]¶ Implements a report client for Amazon MWS.
The report API works differently from other APIs and it is important to have a good understanding of how this API works from MWS reports overview
-
get_report
(ReportId)[source]¶ Returns the contents of a report and the Content-MD5 header for the returned report body.
-
get_report_count
(**kwargs)[source]¶ Returns a count of the reports, created in the previous 90 days, with a status of _DONE_ and that are available for download.
-
get_report_list
(**kwargs)[source]¶ Returns a list of reports that were created in the previous 90 days.
-
get_report_list_by_next_token
(NextToken)[source]¶ Returns a list of reports using the NextToken, which was supplied by a previous request to either GetReportListByNextToken or GetReportList, where the value of HasNext was true in the previous call.
-
get_report_request_count
(**kwargs)[source]¶ Returns a count of report requests that have been submitted to Amazon MWS for processing.
-
get_report_request_list
(**kwargs)[source]¶ Returns a list of report requests that you can use to get the ReportRequestId for a report.
-
get_report_request_list_by_next_token
(NextToken)[source]¶ Returns a list of report requests using the NextToken, which was supplied by a previous request to either GetReportRequestListByNextToken or GetReportRequestList, where the value of HasNext was true in that previous request.
-
exceptions¶
All errors and exceptions
-
exception
pymws.exceptions.
AccessDenied
[source]¶ Bases:
pymws.exceptions.MWSError
Access was denied
-
exception
pymws.exceptions.
MWSError
[source]¶ Bases:
pymws.exceptions.MWSException
Parent class of all Amazon returned Errors.
-
exception
pymws.exceptions.
MWSException
[source]¶ Bases:
Exception
Parent class of all exceptions this package handles
-
exception
pymws.exceptions.
QuotaExceeded
[source]¶ Bases:
pymws.exceptions.MWSError
The total number of requests in an hour was exceeded.
-
exception
pymws.exceptions.
RequestThrottled
[source]¶ Bases:
pymws.exceptions.MWSError
The frequency of requests was greater than allowed..
-
exception
pymws.exceptions.
SignatureDoesNotMatch
[source]¶ Bases:
pymws.exceptions.MWSError
The signature used does not match the server’s calculated signature value.
utils¶
-
pymws.utils.
MARKETPLACES
= [Marketplace(code='BR', currency='BRL', id='A2Q3Y263D00KWC', endpoint='https://mws.amazonservices.com', name='Amazon.com.br'), Marketplace(code='CA', currency='CAD', id='A2EUQ1WTGCTBG2', endpoint='https://mws.amazonservices.ca', name='Amazon.ca'), Marketplace(code='MX', currency='MXN', id='A1AM78C64UM0Y8', endpoint='https://mws.amazonservices.com.mx', name='Amazon.com.mx'), Marketplace(code='US', currency='USD', id='ATVPDKIKX0DER', endpoint='https://mws.amazonservices.com', name='Amazon.com'), Marketplace(code='AE', currency='AED', id='A2VIGQ35RCS4UG', endpoint='https://mws.amazonservices.ae', name='United Arab Emirates (U.A.E.)'), Marketplace(code='DE', currency='EUR', id='A1PA6795UKMFR9', endpoint='https://mws-eu.amazonservices.com', name='Amazon.de'), Marketplace(code='EG', currency='EGP', id='ARBP9OOSHTCHU', endpoint='https://mws-eu.amazonservices.com', name='Egypt'), Marketplace(code='ES', currency='EUR', id='A1RKKUPIHCS9HS', endpoint='https://mws-eu.amazonservices.com', name='Amazon.es'), Marketplace(code='FR', currency='EUR', id='A13V1IB3VIYZZH', endpoint='https://mws-eu.amazonservices.com', name='Amazon.fr'), Marketplace(code='GB', currency='GBP', id='A1F83G8C2ARO7P', endpoint='https://mws-eu.amazonservices.com', name='Amazon.co.uk'), Marketplace(code='IN', currency='INR', id='A21TJRUUN4KGV', endpoint='https://mws.amazonservices.in', name='Amazon.in'), Marketplace(code='IT', currency='EUR', id='APJ6JRA9NG5V4', endpoint='https://mws-eu.amazonservices.com', name='Amazon.it'), Marketplace(code='NL', currency='EUR', id='A1805IZSGTT6HS', endpoint='https://mws-eu.amazonservices.com', name='Amazon.nl'), Marketplace(code='SA', currency='SAR', id='A17E79C6D8DWNP', endpoint='https://mws-eu.amazonservices.com', name='Saudi Arabia'), Marketplace(code='TR', currency='EUR', id='A33AVAJ2PDY3EV', endpoint='https://mws-eu.amazonservices.com', name='Turkey'), Marketplace(code='SG', currency='SGD', id='A19VAU5U5O7RUS', endpoint='https://mws-fe.amazonservices.com', name='Amazon.sg'), Marketplace(code='AU', currency='AUD', id='A39IBJ37TRP1C6', endpoint='https://mws.amazonservices.com.au', name='Amazon.com.au'), Marketplace(code='JP', currency='JPY', id='A1VC38T7YXB528', endpoint='https://mws.amazonservices.jp', name='Amazon.jp')]¶ A list of Marketplaces
-
class
pymws.utils.
Marketplace
(code, currency, id, endpoint, name)¶ -
code
¶ Alias for field number 0
-
currency
¶ Alias for field number 1
-
endpoint
¶ Alias for field number 3
-
id
¶ Alias for field number 2
-
name
¶ Alias for field number 4
-
-
pymws.utils.
flatten_dict
(kwargs, key)[source]¶ Convert a dict into URL parameters the way amazon like it.
Example:
flatten_dict( {'DestinationAddress': {'Name': 'John', 'Country': 'US'}}, 'DestinationAddress', )
Becomes:
DestinationAddress.Name=John&DestinationAddress.Country=US