I'll help you create a Python script to fetch all auction descriptions from your eBay account and save them to an Excel file. Here's a complete solution:
First, you'll need to install the required packages:
pip install ebaysdk pandas openpyxl
Here's the Python script:
import pandas as pd
from ebaysdk.trading import Connection as Trading
from datetime import datetime
import os
class eBayAuctionExporter:
def __init__(self, app_id, cert_id, dev_id, token):
"""
Initialize eBay connection with credentials
"""
self.api = Trading(
appid=app_id,
certid=cert_id,
devid=dev_id,
token=token,
config_file=None,
domain='api.ebay.com', # Use 'api.sandbox.ebay.com' for sandbox
warnings=True
)
def get_all_active_listings(self):
"""
Fetch all active listings from the account
"""
all_listings = []
page_number = 1
has_more_pages = True
while has_more_pages:
try:
# Call GetMyeBaySelling API
response = self.api.execute('GetMyeBaySelling', {
'ActiveList': {
'Include': True,
'Pagination': {
'EntriesPerPage': 200,
'PageNumber': page_number
}
},
'OutputSelector': [
'ActiveList.ItemArray.Item.ItemID',
'ActiveList.ItemArray.Item.Title',
'ActiveList.ItemArray.Item.SKU',
'ActiveList.ItemArray.Item.CurrentPrice',
'ActiveList.ItemArray.Item.ListingType',
'ActiveList.PaginationResult'
]
})
# Extract items from response
active_list = response.dict().get('ActiveList', {})
items = active_list.get('ItemArray', {}).get('Item', [])
# Handle single item case (eBay returns dict instead of list)
if isinstance(items, dict):
items = [items]
all_listings.extend(items)
# Check pagination
pagination = active_list.get('PaginationResult', {})
total_pages = int(pagination.get('TotalNumberOfPages', 1))
if page_number >= total_pages:
has_more_pages = False
else:
page_number += 1
except Exception as e:
print(f"Error fetching page {page_number}: {str(e)}")
has_more_pages = False
return all_listings
def get_item_description(self, item_id):
"""
Get full description for a specific item
"""
try:
response = self.api.execute('GetItem', {
'ItemID': item_id,
'OutputSelector': ['Item.Description']
})
item = response.dict().get('Item', {})
return item.get('Description', '')
except Exception as e:
print(f"Error fetching description for item {item_id}: {str(e)}")
return ''
def export_to_excel(self, output_filename='ebay_listings.xlsx'):
"""
Export all listings with descriptions to Excel
"""
print("Fetching active listings...")
listings = self.get_all_active_listings()
print(f"Found {len(listings)} active listings")
# Prepare data for Excel
data = []
for idx, listing in enumerate(listings, 1):
print(f"Processing listing {idx}/{len(listings)}...")
item_id = listing.get('ItemID')
description = self.get_item_description(item_id)
data.append({
'Item ID': item_id,
'Title': listing.get('Title', ''),
'SKU': listing.get('SKU', ''),
'Current Price': listing.get('CurrentPrice', {}).get('value', ''),
'Currency': listing.get('CurrentPrice', {}).get('_currencyID', ''),
'Listing Type': listing.get('ListingType', ''),
'Description': description
})
# Create DataFrame and save to Excel
df = pd.DataFrame(data)
# Create Excel writer with xlsxwriter engine for better formatting
with pd.ExcelWriter(output_filename, engine='openpyxl') as writer:
df.to_excel(writer, sheet_name='eBay Listings', index=False)
# Auto-adjust column widths
worksheet = writer.sheets['eBay Listings']
for idx, col in enumerate(df.columns):
max_length = max(
df[col].astype(str).map(len).max(),
len(col)
) + 2
# Cap the width for description column
if col == 'Description':
max_length = min(max_length, 50)
worksheet.column_dimensions[chr(65 + idx)].width = max_length
print(f"Successfully exported {len(data)} listings to {output_filename}")
return output_filename
# Configuration
if __name__ == "__main__":
# eBay API Credentials (you need to get these from eBay Developer Program)
APP_ID = "YOUR_APP_ID"
CERT_ID = "YOUR_CERT_ID"
DEV_ID = "YOUR_DEV_ID"
USER_TOKEN = "YOUR_USER_TOKEN"
# Create exporter instance
exporter = eBayAuctionExporter(APP_ID, CERT_ID, DEV_ID, USER_TOKEN)
# Export to Excel
filename = f"ebay_listings_{datetime.now().strftime('%Y%m%d_%H%M%S')}.xlsx"
exporter.export_to_excel(filename)
To use this script, you'll need to:
-
Get eBay Developer Credentials:
-
Replace the placeholder credentials in the script with your actual credentials
-
Run the script:
python ebay_export.py
The script will:
- Connect to your eBay account using the Trading API
- Fetch all active listings with pagination support
- Retrieve the full HTML description for each listing
- Save everything to an Excel file with proper formatting
The Excel file will contain columns for:
- Item ID
- Title
- SKU
- Current Price
- Currency
- Listing Type
- Full Description (HTML)
If you need to modify this script to handle specific requirements (like filtering certain types of listings, handling different listing statuses, or parsing HTML descriptions), let me know!