How can I download the complete list of Amazon categories?

Countries

Read only
Australia
Belgium
Brazil
Canada
Egypt
France
Germany
India
Italy
Japan
Mexico
Netherlands
Poland
Saudi Arabia
Singapore
Spain
Sweden
Turkey
United Arab Emirates
United Kingdom
United States
United States
imgSign in
user profile
Seller_ccsWuQoamzAa9

How can I download the complete list of Amazon categories?

Hello, I am a seller from Korea and I want to use Amazon's API. I tried to receive a list through Python, but I encountered the error 'HTTP error occurred: 400 Client Error:', and I'm having trouble calling the API. How can I resolve this issue? Below is the Python code that I am trying to use.

import requests

import pandas as pd

from datetime import datetime, timezone

client_id =

client_secret =

refresh_token =

marketplace_id = 'ATVPDKIKX0DER'

def get_access_token():

url = 'https://api.amazon.com/auth/o2/token'

payload = {

'grant_type': 'refresh_token',

'refresh_token': refresh_token,

'client_id': client_id,

'client_secret': client_secret

}

headers = {'Content-Type': 'application/x-www-form-urlencoded'}

response = requests.post(url, data=payload, headers=headers)

response.raise_for_status()

return response.json()['access_token']

def get_categories(access_token):

url = 'https://sellingpartnerapi-na.amazon.com/definitions/2020-09-01/productTypes'

headers = {

'Authorization': f'Bearer {access_token}',

'x-amz-access-token': access_token,

'x-amz-date': datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%SZ'),

'x-amz-marketplace-id': marketplace_id,

'Content-Type': 'application/json'

}

response = requests.get(url, headers=headers)

response.raise_for_status()

return response.json()

def save_categories_to_excel(categories, filename):

category_list = []

for category_name, category_info in categories.get('productTypes', {}).items():

category_list.append({

'Category Name': category_name,

'Requirements': ', '.join(category_info.get('requirements', {}).get('attributes', []))

})

df = pd.DataFrame(category_list)

df.to_excel(filename, index=False)

print(f"Categories saved to {filename}")

if __name__ == '__main__':

try:

access_token = get_access_token()

categories = get_categories(access_token)

save_categories_to_excel(categories, 'amazon_categories.xlsx')

except requests.exceptions.HTTPError as err:

print(f"HTTP error occurred: {err}")

except Exception as e:

print(f"Error: {e}")

error massage : 'HTTP error occurred: 403 Client Error: for url: https://sellingpartnerapi-na.amazon.com/definitions/2020-09-01/productTypes'

73 views
4 replies
Tags:Marketplace webservice API
00
Reply
4 replies
user profile
Rose_Amazon

Hi @taxonomy,

Thanks for the post. All sellers can download the Category Listings Report. Professional selling accounts already have access while individual sellers will need to request access from Selling Partner Support.

To generate a Category Listings Report, follow these steps:

Navigate to the Seller Central menu, and click Reports.

From the dropdown menu, select Category Listing Reports.

Select the other optional dropdowns to filter the data.

Click Download to initiate the report download process.

Best regards,

Rose_Amazon

00
Follow this discussion to be notified of new activity

Similar Discussions

user profile
Seller_BhUO02kwbs28s
user profile
Seller_o3xcUgX7rAbp5
user profile
Seller_Fbj6rdG6inQX3