DEV Community

Cover image for Get eBay Sold Listings with Python (Without Building a Scraper)
Marc Andrew
Marc Andrew

Posted on Originally published at compsniper.com

Get eBay Sold Listings with Python (Without Building a Scraper)

If your Python application needs resale prices, active eBay listings are the wrong input. You need
completed sales: what buyers actually paid, when the item sold, its condition, and enough evidence to
calculate a useful range.

Here is the smallest working request with CompSniper:

import os
import requests

response = requests.get(
    "https://api.compsniper.com/v1/scrape",
    headers={"Authorization": f"Bearer {os.environ['COMPSNIPER_API_KEY']}"},
    params={"keyword": "shure sm7b", "count": 240, "itemCondition": "used"},
    timeout=75,
)
response.raise_for_status()
data = response.json()

print(data["summary"]["median"], data["summary"]["currency"])
print(data["summary"]["p25"], data["summary"]["p75"])
Enter fullscreen mode Exit fullscreen mode

The response includes up to 240 sold rows and a summary with median, mean, minimum, maximum, p25, p75,
average shipping, currency, and sample size.

Do not retry every 429

There are two distinct cases:

  • rate_limited is temporary. Wait for Retry-After, add a little jitter, and cap the number of attempts.
  • quota_exceeded lasts until reset or upgrade. Stop immediately. Retrying it only creates more errors.

The full guide includes filters, pagination, a real raw-versus-cleaned sample, and bounded Python retry
code:

https://compsniper.com/guides/ebay-sold-listings-api-python

The complete Python, Node.js, cURL, pagination, retry, and Card Batch examples are public here:

https://github.com/CompSniper/compsniper-api-examples

CompSniper includes 100 requests per month without a credit card. It is an independent product and is
not affiliated with eBay.

Top comments (0)