Search code examples
pythonebay-api

Error while working with Ebay API


I'm trying to access the Ebay API by using the ebaysdk module. I'm using the example code given in the documentation and have registered on Ebay Developer's site to generate the required App ID. Here's the source code of my program:

ebaay.py

from ebaysdk.finding import Connection as Finding

api = Finding(appid="123456789")
response = api.execute('findItemsAdvanced', {'keywords': 'Python'})
print(response.dict())

YAML file (assuming my app id is 123456789)

# eBay SDK Defaults
name: ebay_api_config
# Trading API Sandbox - https://www.x.com/developers/ebay/products/trading-api
api.sandbox.ebay.com:
compatability: 719
appid: 123456789
certid: ENTER_YOUR_CERTID_HERE
devid: ENTER_YOUR_DEVID_HERE
token: ENTER_YOUR_TOKEN_HERE

# Trading API - https://www.x.com/developers/ebay/products/trading-api
api.ebay.com:
version: 719
appid: 123456789
certid: ENTER_YOUR_CERTID_HERE
devid: ENTER_YOUR_DEVID_HERE
token: ENTER_YOUR_TOKEN_HERE

# Finding API - https://www.x.com/developers/ebay/products/finding-api
svcs.ebay.com:
appid: 123456789
version: 1.0.0

# Shopping API - https://www.x.com/developers/ebay/products/shopping-api
open.api.ebay.com:
appid: 123456789
version: 671
# Optional affiliate tracking
# http://developer.ebay.com/DevZone/shopping/docs/Concepts/ShoppingAPI_FormatOverview.html#StandardURLParameters
trackingid: ENTER_YOUR_TRACKINGID_HERE
trackingpartnercode: ENTER_YOUR_PARTNERCODE_HERE 

However, when I try to run my Python script, I encounter the following error:

Traceback (most recent call last):
  File "E:/Python27/Web Scraping/ebaay.py", line 3, in <module>
    api = Finding(appid="123456789")
  File "C:\Python27\lib\site-packages\ebaysdk\finding\__init__.py", line 70, in __init__
    config_file=kwargs.get('config_file', 'ebay.yaml'))
  File "C:\Python27\lib\site-packages\ebaysdk\config.py", line 39, in __init__
    self._populate_yaml_defaults()
  File "C:\Python27\lib\site-packages\ebaysdk\config.py", line 50, in _populate_yaml_defaults
    for k, val in dataobj.get(self.domain, {}).items():
AttributeError: 'NoneType' object has no attribute 'items'

What seems to be wrong with my code ?


Solution

  • You need to indent each API field:

    # eBay SDK Defaults
    name: ebay_api_config
    # Trading API Sandbox - https://www.x.com/developers/ebay/products/trading-api
    api.sandbox.ebay.com:
        compatability: 719
        appid: 123456789
        certid: ENTER_YOUR_CERTID_HERE
        devid: ENTER_YOUR_DEVID_HERE
        token: ENTER_YOUR_TOKEN_HERE
    
    # Trading API - https://www.x.com/developers/ebay/products/trading-api
    api.ebay.com:
        version: 719
        appid: 123456789
        certid: ENTER_YOUR_CERTID_HERE
        devid: ENTER_YOUR_DEVID_HERE
        token: ENTER_YOUR_TOKEN_HERE
    
    # Finding API - /developers/ebay/products/finding-api
    svcs.ebay.com:
        appid: 123456789
        version: 1.0.0
    
    # Shopping API - /developers/ebay/products/shopping-api
    open.api.ebay.com:
        appid: 123456789
        version: 671
    

    Also, its not necessary put the appid in your Finding() call in ebaay.py if you have it in the ebay.yaml file. api = Finding() will work.