I need to get suggested categories for my items. However, when I make a request I get a reply for the US site. How to get it for the UK?
my code:
from ebaysdk.trading import Connection
api = Connection(config_file="ebay.yaml",
domain="api.ebay.com", debug=True)
response = api.execute('GetSuggestedCategories', {'Query': 'INTERNAZIONALE
1999/2000 AWAY FOOTBALL SHIRT MAGLIA JERSEY NIKE'})
for items in reply.dict()['SuggestedCategoryArray']['SuggestedCategory']:
print(items)
Response:
{'Category': {'CategoryID': '2887', 'CategoryName': 'Soccer-International
Clubs', 'CategoryParentID': ['64482', '24409'], 'CategoryParentName':
['Sports Mem, Cards & Fan Shop', 'Fan Apparel & Souvenirs']},
'PercentItemFound': '89'}
{'Category': {'CategoryID': '2891', 'CategoryName': 'Soccer-National
Teams', 'CategoryParentID': ['64482', '24409'], 'CategoryParentName':
['Sports Mem, Cards & Fan Shop', 'Fan Apparel & Souvenirs']},
'PercentItemFound': '6'}
{'Category': {'CategoryID': '123490', 'CategoryName': 'Men',
'CategoryParentID': ['888', '159049', '20862', '159178', '33485'],
'CategoryParentName': ['Sporting Goods', 'Team Sports', 'Soccer',
'Clothing, Shoes & Accessories', 'Clothing']}, 'PercentItemFound':
'3'}
I read somewhere (The SiteID table) that you have to set up the header with 'X-EBAY-API-SITEID'
in order for it to return the relevant results. The code for UK is 3, so what most likely is the solution to your problem is simply add :
siteid: 3
to the ebay.yml
file you use. If you like to manipulate further the headers/see what else can be added to the ebay.yml
file you might want to refer to the build_request_headers
function in the traing/__init__.py
module.
Hope that solves your issue!
As I tried your code I also noticed that you use response
to get the result but reply
in the for loop, typo I guess. Anyway the result I got with adding the siteid
is:
{'Category': {'CategoryID': '112976', 'CategoryName': 'Italian Clubs',
'CategoryParentID': ['64482', '53597', '112972'], 'CategoryParentName':
['Sports Memorabilia', 'Football Shirts', 'Overseas Clubs']}, 'PercentItemFound': '70'}
{'Category': {'CategoryID': '106485', 'CategoryName': 'English Clubs',
'CategoryParentID': ['64482', '53597'], 'CategoryParentName':
['Sports Memorabilia', 'Football Shirts']}, 'PercentItemFound': '12'}
{'Category': {'CategoryID': '112992', 'CategoryName': 'Scottish Clubs', 'CategoryParentID': ['64482', '53597'],
'CategoryParentName': ['Sports Memorabilia', 'Football Shirts']}, 'PercentItemFound': '5'}
.
.
.
EDIT:
Adding another way of manipulating headers.
As @Fen pointed out, another way of changing the siteid
in headers is by adding it to the connection class within the script like he did it:
api = Connection(config_file="ebay.yaml", domain="api.ebay.com", siteid=3, debug=True)