I need the API to create product on Amazon Seller account from API for a python project. How to do that. Can anyone please help.
Yes, Amazon provides an API called the Amazon Marketplace Web Service (Amazon MWS) that allows you to programmatically manage your Amazon Seller account, including adding products. Here's a brief overview of the steps you need to take:
Register for Amazon MWS:
Access API Keys:
Choose the Appropriate API Section:
The operations related to managing products (including adding) fall under the "Feeds" section of the Amazon MWS API.
Use the SubmitFeed Operation:
Feed Types for Products:
Make API Requests:
Sign Requests:
Handle Responses:
Here is some sample code on how to do it (replace placeholders like 'YourAccessKey', 'YourSecretKey', etc., with your actual Amazon MWS credentials and data):
import requests
import hashlib
import base64
import hmac
import time
def generate_amazon_mws_signature(secret_key, service_url, params):
canonical_query_string = '&'.join([f'{key}={params[key]}' for key in sorted(params)])
string_to_sign = f"POST\n{service_url}\n/\n{canonical_query_string}"
signature = base64.b64encode(hmac.new(secret_key.encode(), string_to_sign.encode(), hashlib.sha256).digest()).decode()
return signature
def submit_feed(access_key, secret_key, merchant_id, marketplace_id, feed_type, feed_content):
service_url = 'https://mws.amazonservices.com'
endpoint = '/Feeds/2009-01-01'
params = {
'AWSAccessKeyId': access_key,
'Action': 'SubmitFeed',
'Merchant': merchant_id,
'MWSAuthToken': 'YourMWSAuthToken', # If applicable
'FeedType': feed_type,
'MarketplaceIdList.Id.1': marketplace_id,
'PurgeAndReplace': 'false', # Set to 'true' if you want to replace existing data
'SignatureMethod': 'HmacSHA256',
'SignatureVersion': '2',
'Timestamp': time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()),
'Version': '2009-01-01',
}
signature = generate_amazon_mws_signature(secret_key, service_url + endpoint, params)
params['Signature'] = signature
headers = {'Content-Type': 'text/xml'}
response = requests.post(f'{service_url}{endpoint}', params=params, headers=headers, data=feed_content)
# Process the response as needed
print(response.text)
# Example usage
access_key = 'YourAccessKey'
secret_key = 'YourSecretKey'
merchant_id = 'YourMerchantID'
marketplace_id = 'YourMarketplaceID'
feed_type = '_POST_PRODUCT_DATA_' # Or other appropriate feed type
feed_content = 'YourFeedContent' # Actual product data in XML or flat file format
submit_feed(access_key, secret_key, merchant_id, marketplace_id, feed_type, feed_content)
If you want to learn more about it, use the link below
https://docs.developer.amazonservices.com/en_US/dev_guide/index.html