eBay SDK for Python

2.2.0 · maintenance · verified Fri Apr 17

The eBay SDK for Python provides a comprehensive interface for interacting with various eBay APIs, including Trading, Finding, Shopping, and Merchandising. It simplifies API calls and response parsing by converting XML to Python dictionaries. The current version is 2.2.0, with the last release in April 2020, indicating a maintenance-only cadence.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to search for items using the eBay Finding API. Ensure you have your eBay App ID configured either as an environment variable `EBAY_APPID` or directly replace the placeholder in the `appid` argument. It explicitly bypasses `ebay.yaml` for simplicity and catches potential API connection errors.

import os
from ebaysdk.finding import Connection as FindingConnection
from ebaysdk.exception import ConnectionError

try:
    api = FindingConnection(
        domain='svcs.ebay.com', # Use 'svcs.sandbox.ebay.com' for sandbox environment
        config_file=None, # Explicitly disable config file for this example
        appid=os.environ.get('EBAY_APPID', 'YOUR_EBAY_APPID') # Replace 'YOUR_EBAY_APPID' with your actual App ID or set EBAY_APPID env var
    )
    
    # Make a call to find items by keywords
    response = api.execute('findItemsByKeywords', {'keywords': 'star wars lego'})
    
    if response.reply and response.reply.searchResult and response.reply.searchResult.item:
        print(f"Found {response.reply.searchResult['@count']} items:")
        for item in response.reply.searchResult.item[:3]: # print first 3 items
            print(f"- {item.title} (Current Price: {item.sellingStatus.currentPrice.value} {item.sellingStatus.currentPrice['currencyId']})")
    else:
        print("No items found or response malformed.")
        
except ConnectionError as e:
    print(f"API Connection Error: {e.response.dict()}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

view raw JSON →