1

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'}
Luuklag
  • 3,897
  • 11
  • 38
  • 57
Fen
  • 37
  • 1
  • 6

1 Answers1

0

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)

Nick
  • 677
  • 1
  • 11
  • 25
  • Hello, you get a correct response. However, when I add siteid to yaml nothing changes. I do it like that: # Trading API - https://www.x.com/developers/ebay/products/trading-api api.ebay.com: compatibility: 719 appid: -Listingt-PRD-3eaa5c961-f0d... certid: PRD-eaa5c9617195-1a5b-48a9-a8.... devid: 418bf355-9def-4aaa-b85c-17c6cb.. siteid: 3 token: AgAAAA**AQAAAA**aAAAAA**lMixXA**nY+ Is this correct way? – Fen May 11 '19 at 13:49
  • @Fen That seems the same as me. The only difference I can see is: `compatibility: 967`. However, this call should not be affected by that. What could help is to get the API call with the `debug=True` then if you can post the `headers` from the logs. It should be the 3rd line from the logs. – Nick May 12 '19 at 14:19
  • thanks for help, managed to get it work adding "siteid" into connection parameter, not into yaml, like this: api = Connection(config_file="ebay.yaml", domain="api.ebay.com", siteid=3, debug=True) – Fen May 19 '19 at 08:25